view 部分
<view class="set-row">
<view class="set-label">验证码</view>
<view class="set-cell flex-center">
<view class="flex_bd">
<input maxlength="6" type="number" class="ui-input" v-model="code" placeholder="请输入验证码" />
</view>
<view class="code-btn" v-if="verifyShow" @click="timedown(60)">{{verText}}</view>
<view class="code-btn" v-else >{{verifyTip+'s'}}</view>
</view>
</view>
data() {
return {
code:'',
verifyShow:true,
verText:'获取验证码',
verifyTip:60,
}
},
timedown:function(num){
let that = this;
if(num == 0){
that.verifyShow = true;
that.verText = '重新获取'
return clearTimeout();
}else{
that.verifyShow = false; // 是否显示获取验证码
setTimeout(function() {
that.verifyTip = num-1
that.timedown(num-1);
}, 1000);//定时每秒减一
}
},