getCode: function () {
if (this.data.isDisabled) {
return;
}
let self = this;
if (this.data.phone_num.trim() == '') {
wx.showToast({
title: '请输入手机号',
icon: 'none'
})
return;
}
if (!/^1[0-9]{10}$/.test(self.data.phone_num)) {
wx.showToast({
title: '手机号格式错误',
icon: 'none'
})
return;
}
wx.showLoading();
wx.request({
url: util.baseUrl + 'api/phoneGetCode',
method: 'POST',
data: {
tel: this.data.phone_num,
zone_id:app.globalData.zone_id,
s: '/api/phoneGetCode'
},
success: res => {
wx.hideLoading();
if(res.statusCode && res.statusCode !== 200) {
wx.showToast({
title: '服务器错误'+res.statusCode,
icon: 'none',
})
app.postErrorMsg('接口api/phoneGetCode:'+res.statusCode+JSON.stringify({res}))
return
}
if (res.data.err_code == 200) {
wx.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 3000
})
// 每60s 发送一次验证码
let num = 60;
wx.setStorageSync('send_sms_timeStamp', Date.parse(new Date())/1000)
let intervalId = setInterval(function () {
if (num >= 0) {
self.setData({
code_text: num + 's',
isDisabled: true
})
num -= 1;
} else {
self.setData({
code_text: '获取验证码',
isDisabled: false
})
clearInterval(intervalId);
}
}, 1000);
} else if (res.data.err_code == 100) {
wx.showModal({
title: '查询不到该账号',
content: '请检查您输入的号码是否有误。如输入正确但无法登陆,请联系咨询助理,我们将及时帮您解决。',
showCancel: false
})
} else {
wx.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 3000
})
}
},
fail(err) {
wx.hideLoading();
wx.showToast({
title: '发送请求失败',
icon: 'none'
});
app.postErrorMsg('接口api/phoneGetCode:'+JSON.stringify({err}))
}
})
},
小程序点击发起请求,请求接口成功后调用wx.hideLoading(),偶尔 出现无法关闭loading的情况,并且调用了后面的wx.showToast也没有toast弹窗,感觉频率挺高的,很容易就复现一次,手机和工具都有出现过
另外工具的版本:1.06.2503281 基础库:3.8.3
