微信小程序 倒计时
来源:互联网 发布:dha哪个牌子好 知乎 编辑:程序博客网 时间:2024/06/03 21:05
微信小程序倒计时功能 可以用于短信验证码的倒计时等
方法1.
Js:
function countdown(that) { var second = that.data.countdown_time if(second == 0) { console.log("001"); // console.log("Time Out..."); that.setData({ // second: "Time Out..." showtime1: true, showtime2: false, reg_hqyzm: "重新获取", countdown_time:5, }); console.log("002"); return; } console.log("003"); var time = setTimeout(function () { that.setData({ countdown_time: second - 1 }); countdown(that); } , 1000)}Page({ /** * 页面的初始数据 */ data: { showtime1: true, showtime2: false, reg_hqyzm: "获取验证码", countdown_time: 5, }, reg_yanzhengma_huoqu:function(){ console.log("004"); this.setData({ showtime1: false, showtime2: true, }); countdown(this); // wxTimer.start(this); },});
wxml:
<view class="reg_yanzhengma"> <image class="img_yanzhenma" src="http://img.blog.csdn.net/20170527164756495?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvVUZPMDAwMDE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"></image> <input class="input_reg_yanzhengma" bindconfirm="input_reg_yanzhengma" placeholder="请输入验证码" type="number"/> <view wx:if="{{showtime1}}" class="reg_yanzhengma_time1" bindtap="reg_yanzhengma_huoqu"> {{reg_hqyzm}} </view> <view wx:if="{{showtime2}}" class="reg_yanzhengma_time2" > 倒计时:{{countdown_time}}s </view> </view>
wxss:
.reg_yanzhengma{ width: 100%; height:100rpx; margin-top: 10rpx; display: flex; background: #fff}.img_yanzhenma{ width: 10%; height:60rpx; margin-top: 20rpx; margin-left: 50rpx;}.input_reg_yanzhengma{ width: 55%; height:50rpx; margin-top: 20rpx; margin-left: 50rpx; font-size: 28rpx; }.reg_yanzhengma_time1{ width: 35%; height:100%; margin-left: 50rpx; font-size: 30rpx; background: #0f0; line-height: 100rpx; text-align: center; color: #fff;}.reg_yanzhengma_time2{ width: 35%; height:100%; margin-left: 50rpx; font-size: 30rpx; background: #777777; line-height: 100rpx; text-align: center; color: #fff;}
方法2. wxTimer 稍后再写
阅读全文
1 0
- 微信小程序-支付倒计时
- 微信小程序 倒计时
- 微信小程序 倒计时
- 微信小程序 倒计时
- 微信小程序倒计时功能
- 微信小程序倒计时组件开发
- 微信小程序中显示倒计时
- 微信小程序--发送短信倒计时
- 微信小程序_倒计时补零
- 微信小程序获取验证码倒计时
- 微信小程序获取验证码倒计时时间
- 【c++程序】倒计时程序
- javaScript倒计时程序
- c#制作倒计时程序
- [VB.NET]倒计时程序
- 倒计时小程序
- C语言倒计时程序
- javascript开发倒计时程序
- 查看tomcat管理信息
- LeetCode 104. Maximum Depth of Binary Tree和111. Minimum Depth of Binary Tree 递归
- 逆波兰表达式求值
- PHP实现数组和XML文件转换
- C语言地址概念
- 微信小程序 倒计时
- php中的类
- Android开发之实现苹果浏览器网页跳转动画
- 日常训练 腐女的生日 奥妙重重的最短路
- 1013. 数素数 (20)
- DDoS攻击进阶 混合攻击
- 向下转型
- 表单初步注册
- Android控件--TextureView