微信小程序弹出和隐藏遮罩层动画以及五星评分
参考源码:
http://www.see-source.com/weixinwidget/detail.html?wid=82
https://blog.csdn.net/pcaxb/article/details/56276180
https://developers.weixin.qq.com/miniprogram/dev/api/api-animation.html
train.wxml
<view class='train_con'> <view class='head'>
<text>{{bankname}}</text>
<text class='count'>{{index+1}}/{{allquestion.length}}</text>
</view> <view bindtouchstart="touchStart" bindtouchend="touchEnd" style='width:100%;height:100%;display: flex;flex-direction: column;justify-content: center;align-items: center;'> <view class='question_view'>
<text class='question_text'>{{questionlist.question}}</text> <view class='option_view' data-id="A" bindtap="changeColor"> <view class="letter_view {{letterid=='A'?'active':''}} {{errorid=='A'?'error':''}}">
<text class='letter'>A</text>
</view> <view class='option_text_view' >
<text class='option_text'>{{questionlist.choiceA}}</text>
</view>
</view> <view class='option_view' data-id='B' bindtap="changeColor"> <view class="letter_view {{letterid=='B'?'active':''}} {{errorid=='B'?'error':''}}">
<text class='letter'>B</text>
</view> <view class='option_text_view'>
<text class='option_text'>{{questionlist.choiceB}}</text>
</view>
</view> <view class='option_view' data-id='C' bindtap="changeColor">
<view class="letter_view {{letterid=='C'?'active':''}} {{errorid=='C'?'error':''}}">
<text class='letter'>C</text>
</view> <view class='option_text_view'>
<text class='option_text'>{{questionlist.choiceC}}</text>
</view>
</view> <view class='option_view' data-id='D' bindtap="changeColor">
<view class="letter_view {{letterid=='D'?'active':''}} {{errorid=='D'?'error':''}}">
<text class='letter'>D</text>
</view> <view class='option_text_view'>
<text class='option_text'>{{questionlist.choiceD}}</text>
</view>
</view> </view>
<!-- 答案解析 -->
<view>
<view class="analysis_view {{clickcheckid==1?'checked2':''}}">
<text>参考答案:{{questionlist.answer}}\n参考解析:{{questionlist.analysis}}</text>
</view>
</view> <view class="checkanswer_view {{clickcheckid==1?'checked':''}}" bindtap='checkanswer_click'>
<text>查看答案</text>
</view>
</view> <!-- 透明遮盖层,用于退出评分层 -->
<view bindtap="hideModal" animation="{{animationData}}" class="touming_top" wx:if="{{showModalStatus}}">
</view> <!-- 评分遮盖层 -->
<view animation="{{animationData}}" class="container-column buydes-dialog-container" wx:if="{{showModalStatus}}">
<view class="buydes-dialog-container-top">这道题对你有用吗?评个分吧</view>
<view class="container-column buydes-dialog-container-bottom">
<!-- 评分 -->
<block wx:for="{{stars}}">
<image class="star-image" style="left: {{item*80+185}}rpx" src="{{key > item ?selectedSrc : normalSrc}}">
<view class="item" style="left:0rpx" data-key="{{item+1}}" bindtap="selectRight"></view>
</image>
</block>
<view class="mark_btn" bindtap='mark_click'>
<text>确定</text>
</view>
</view>
</view> <!-- 透明遮盖层,用于退出评分层 -->
<view bindtap="hideModal" animation="{{animationData}}" class="touming" wx:if="{{showModalStatus}}">
</view> <!-- 底部栏 -->
<view class='leftandright'> <view class='bottom_view' bindtap="showModal" >
<image class="bottom_image" src='../images/score.png'></image>
</view> <view class='bottom_view' bindtap='nextquestion_click'>
<image class="bottom_image" src='../images/comment.png'></image>
</view> <button style="color: #fff; width: 80rpx;height: 80rpx;background-color: #fff;padding:0rpx; margin-left:0rpx;margin-right:0rpx;padding-left:0px;padding-right:0px;" id="shareBtn" open-type="share" class='share_btn'>
<image class="bottom_image" src='../images/share.png'></image>
</button> </view> </view>
train.js
var interval = "";//周期执行函数的对象
var time = 0;//滑动时间
var touchDot = 0;//触摸时的原点
var flag_hd = true;//判定是否可以滑动 let animationShowHeight = 300;//动画偏移高度 Page({ /**
* 页面的初始数据
*/
data: { // 遮罩层变量
animationData: "",
showModalStatus: false,
imageHeight: 0,
imageWidth: 0, // 评分变量
stars: [0, 1, 2, 3, 4],//评分数值数组
normalSrc: '../images/score.png',//空心星星图片路径
selectedSrc: '../images/fullstar.png',//选中星星图片路径
key: 0,//评分
}, //点击星星
selectRight: function (e) {
var key = e.currentTarget.dataset.key
console.log("得" + key + "分")
this.setData({
key: key
})
}, // 确定评分
mark_click: function () {
this.hideModal()
}, // 显示遮罩层
showModal: function () {
//创建一个动画实例animation。调用实例的方法来描述动画。
var animation = wx.createAnimation({
duration: 500, //动画持续时间500ms
timingFunction: "ease",//动画以低速开始,然后加快,在结束前变慢
delay: 0 //动画延迟时间0ms
})
this.animation = animation
//调用动画操作方法后要调用 step() 来表示一组动画完成
animation.translateY(animationShowHeight).step()// 在Y轴向上偏移300
this.setData({
//通过动画实例的export方法导出动画数据传递给组件的animation属性。
animationData: animation.export(),
showModalStatus: true //显示遮罩层
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export()
})
}.bind(this), 1)
}, // 隐藏遮罩层
hideModal: function () {
var animation = wx.createAnimation({
duration: 500,
timingFunction: "ease",
delay: 0
})
this.animation = animation;
animation.translateY(animationShowHeight).step()
this.setData({
animationData: animation.export(),
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export(),
showModalStatus: false
})
}.bind(this), 200)
}, // 评分按钮
score_click: function () { }, /**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) { }, /**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () { }, /**
* 生命周期函数--监听页面显示
*/
onShow: function () {
flag_hd = true; //重新进入页面之后,可以再次执行滑动切换页面代码
clearInterval(interval); // 清除setInterval
time = 0;
let that = this;
wx.getSystemInfo({
success: function (res) {
animationShowHeight = res.windowHeight;
}
})
}, /**
* 生命周期函数--监听页面隐藏
*/
onHide: function () { }, /**
* 生命周期函数--监听页面卸载
*/
onUnload: function () { }, /**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () { }, /**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () { }, /**
* 用户点击右上角分享
*/
onShareAppMessage: function () { }, })
train.wxss
page {
background-color: #fff;
} /* -----------------评分遮罩层----------------- */ /* 分享按钮 */ .share_btn::after {
border: none;
} /* 整个评分遮罩层 */ .buydes-dialog-container {
width: 100%;
height: 300rpx;
justify-content: space-between;
background-color: #fff;
position: fixed;
bottom: 101rpx;
/* z-index: 998; */
border-top: 1rpx solid #e8e8e8;
} /* 评分遮罩层顶部 */ .buydes-dialog-container-top {
height: 100rpx;
padding-top: 20rpx;
display: flex;
justify-content: center;
flex-grow:;
font-size: 32rpx;
color: #737373;
} /* 评分遮罩层底部 */ .buydes-dialog-container-bottom {
height: 150rpx;
padding-top: 20rpx;
background-color: #fff;
display: flex;
justify-content: center;
flex-grow:;
} /* 空心的星星图片 */ .star-image {
position: absolute;
top: 100rpx;
width: 60rpx;
height: 60rpx;
src: "../../images/score.png";
} /* 触发评分点击的区域 */ .item {
position: absolute;
top: 0rpx;
width: 60rpx;
height: 60rpx;
} /* 确认评分按钮 */ .mark_btn {
width: 100%;
height: 100rpx;
background-color: #fff;
color: #55c5ac;
display: flex;
justify-content: center;
align-items: center;
border-top: 1rpx solid #eaeaea;
margin-top: 60rpx;
margin-bottom: 150rpx;
font-size: 32rpx;
} /* 透明遮罩层(上) */ .touming_top {
width: 100%;
height: 900rpx;
opacity:;
position: fixed;
bottom: 402rpx;
z-index:;
} /* 透明遮罩层(下) */ .touming {
width: 100%;
height: 101rpx;
opacity:;
position: fixed;
bottom: 0rpx;
z-index:;
}
微信小程序弹出和隐藏遮罩层动画以及五星评分的更多相关文章
- 微信小程序弹出操作菜单
微信小程序弹出操作菜单 比如在页面上放一个按钮,点击按钮弹出操作菜单,那么在按钮的 bindtap 事件里,执行下面的代码即可: wx.showActionSheet({ itemList: ['A' ...
- 微信小程序弹出层点击穿透问题
问题描述:使用小程序的modal组件实现遮罩层效果时,会出现滚动穿透的问题,即遮罩层后面的页面依旧可以滚动. 解决方案: 给底层页面动态添加 position:fixed; 代码: wxml: < ...
- 微信小程序 - 弹出键盘遮挡住输入框
在开发微信小程序的时候遇到,输入用户名或者手机号以及地址,手机键盘调起来,会把输入框遮挡. 如图: 以上两张图是自己工作中遇到的,此处不要着急,一个属性帮你搞定. cursor-spacing:指定光 ...
- 使用movable-view制作可拖拽的微信小程序弹出层效果。
仿了潮汐睡眠小程序的代码.[如果有侵权联系删除 最近做的项目有个弹出层效果,类似音乐播放器那种.按照普通的做了一般感觉交互不是很优雅,设计妹子把潮汐睡眠的弹层给我看了看,感觉做的挺好,于是乘着有空仿照 ...
- 微信小程序弹出可填写框两种方法
方法一: html页面: < view class = "container" class = "zn-uploadimg" > < butt ...
- 微信小程序弹出层
1.消息提示 wx.showToast wx.showToast({ title: '成功', icon: 'success', duration: 2000 })2.模态弹窗 wx.show ...
- 微信小程序弹出框滚动穿透问题
1.在你的遮罩层最外层加 catchtouchmove="noneEnoughPeople" 里面是你的方法名2.noneEnoughPeople: function () { c ...
- 微信小程序弹出层动画特效
.rules_modal_cont{ height:800rpx; width:200rpx; -webkit-animation: showZeroAlert .3s; animation: sho ...
- 微信小程序 - 弹出层组件
需要的可以下载示例:maskalert
随机推荐
- android fragement报nullexcption错误
,这题目起的够骚情了,原创傲慢的上校哦,转载请标明:http://blog.csdn.net/aomandeshangxiao/article/details/7753421 其实有些方法也是从网上找 ...
- vs 删除行尾空格
vs 删除行尾空格 vs2010:Enter: Ctrl+H Find what: :b*$ Replace with: [Empty] Look in: Current Document Find ...
- 【图的DFS】图的DFS非递归算法
在DFS的递归算法中,DFS框架如下: 1访问起点v0 2依次以v0的未访问的连接点为起点,DFS搜索图,直至图中所有与v0路径相通的顶点都被访问. 3若该图为非连通图,则图中一定还存在未被访问的顶点 ...
- m2eclipse Error:ArtifactTransferException: Failure to transfer org.apache.felix:org.apache.felix.res
Issue: When you create and compile a project with pom.xml using m2eclipse, it may report some error ...
- django练习——博客系统优化
一直准备使用Django搭建一个个人网站,最近终于开始动手,上周已经完成了基本博客功能的搭建(http://blog.csdn.net/hcx25909/article/details/2460133 ...
- Ubuntu 16.04 LTS今日发布
Ubuntu 16.04 LTS今日发布 Ubuntu16.04 LTS 发布日期已正式确定为 2016 年 4 月 21 日,代号为 Xenial Xerus.Ubuntu16.04 将是非常受欢迎 ...
- python3爬虫 - cookie登录实战
http://blog.csdn.net/pipisorry/article/details/47948065 实战1:使用cookie登录哈工大ACM网站 获取网站登录地址 http://acm.h ...
- Android APP新的“优雅”退出方式--EventBus大显身手
最近在研究eventBus..很多小伙伴不知道他有什么用.. 前篇介绍了EventBus的基本使用 这里简单举一个例子,就是退出APP 转载请注明出处:http://blog.csdn.net/win ...
- hadoop上C++开发两种方式的例子
百度在使用Hadoop过程中同样发现了Hadoop因为Java语言带来的低效问题,并对Hadoop进行扩展. 而在此之前,百度也尝试了 Hadoop PIPES 和 Hadoop Streamming ...
- Oracle Applications DBA 基础(二)
6.OAM及系统管理 2014年9月13日 20:40 参考资料: 1.Oracle Applications System Administrator's Guide - Configuration ...