小程序倒计时60秒以及解决ios页面晃动问题

原创 yinglsc 随笔 小程序 359阅读 2018-03-07 10:41:18 举报

1》小程序ios页面晃动问题,上下晃动是因为机子本身问题,左右问题可以解决
.container{
padding-bottom: 0;
background-repeat: no-repeat;
background-size: 100% auto;
background-position: bottom center;
}
包个container
2》小程序倒计时60秒 以及倒计时的时候按钮无法点击 ,60秒之后重新
<form bindsubmit="formSubmit" bindreset="formReset">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_input">
<view class="weui-cellhd">
<view class="weui-label">手机号</view>
</view>
<view class="weui-cell
bd">
<input class="weui-input"name="phone" placeholder="请输入手机号"/>
</view>
</view>
<view class="weui-cell weui-cell_input weui-cell_vcode">
<view class="weui-cellhd">
<view class="weui-label">验证码</view>
</view>
<view class="weui-cell
bd">
<input class="weui-input" maxlength='6' name="yzm" placeholder="请输入验证码" />
</view>
<view class="weui-cell__ft">
<view style='width:160rpx;text-align:center;font-size:34rpx' data-id="2" bindtap="getBtn" class="buttonget weui-vcode-btn">{{time}}</view>
</view>
</view>
<view class="weui-cell weui-cell_input weui-cell_vcode"></view>
</view>

<view class='xzsf_bt'>
<button class="weui-btn" formType="submit" type="primary">确定</button>
</view>
</form>

js
data: {
nickName: wx.getStorageSync('nickName'),
head: wx.getStorageSync('head'),
time:"获取验证码",
currentTime:60,
disabled: true
},
formSubmit: function (res) {
console.log(res);
var phone = res.detail.value.phone;
var yzm = res.detail.value.yzm;
var rePhone = /^1\d{10}$/;
if (!rePhone.test(phone)) {
wx.showToast({
title: '请输入正确的手机号码',
icon: 'none',
duration: 2000
})
return;
}

var reyzms = /^\d{6}$/;
if (!reyzms.test(yzm)) {
  wx.showToast({
    title: '请输入正确的验证码',
    icon: 'none',
    duration: 2000
  })
  return;
}

},
getBtn: function (options) {
var that = this;
var currentTime = that.data.currentTime;
console.log(currentTime);
//这里是60秒内不能再点击
if (that.data.disabled){
that.setData({
time: currentTime + '秒',
disabled: false
})
var interval = setInterval(function () {
that.setData({
time: (currentTime - 1) + '秒',
})
currentTime--;
if (currentTime <= 50) {
clearInterval(interval)
that.setData({
time: '重新获取',
currentTime: 60,
disabled: true
})

    }

  }, 1000)
}

},

评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复