const api = require("../../api/api"), app = getApp() Page({ data: { tle : "", codeBtnText : "获取验证码", codeBtnStat : false }, onLoad() {}, // 手机号码 tel(e){ this.setData({ tle : e.detail.value }) }, // 获取短信验证码 getCode(){ setTimeout(() => { if(this.data.tle != ''){ my.showLoading(); api.request({ url : "sms", method: "POST", data : { mobile : this.data.tle, channel : "DEFAULT" } }).then(res=>{ // 获取倒计时 this.setData({ codeBtnStat: true, codeBtnText: "重新获取60s" }) let outTimeNumber = 60 let outTime = setInterval(()=>{ if(outTimeNumber >= 1){ outTimeNumber-- this.setData({ codeBtnText: "重新获取" + outTimeNumber + 's' }) }else{ this.setData({ codeBtnStat: false, codeBtnText: "获取验证码" }) clearInterval(outTime) } },1000) // 提示信息 my.showToast({ content: res.data }) my.hideLoading(); }).catch(err=>{ my.showToast({ content: "短信发送失败,请稍候重试" }) my.hideLoading(); }) }else{ my.showToast({ content: "手机号码不能为空" }); } }, 100) }, // 找回密码 findForm(e){ my.showLoading() // api api.request({ url : "findpass", method : "POST", data : { mobile : e.detail.value.tel, code : e.detail.value.code, channel : "DEFAULT", password : e.detail.value.paw, password_confirmation : e.detail.value.confirmPaw } }).then(res=>{ my.hideLoading() my.alert({ content : res.data, buttonText: '去登录', success: () => { my.navigateBack(); } }); }).catch(err=>{ my.showToast({ type : 'none', content: err.data.message }) my.hideLoading() }) } });