var api = require('../../utils/api.js') // pages/editPassword/editPassword.js Page({ /** * 页面的初始数据 */ data: { checkPassword:'', form:{ identityNo:'', mobile:'', newPassword:'' } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, bindIdentityNo(e){ this.setData({ 'form.identityNo':e.detail.value }) }, bindMobile(e){ this.setData({ 'form.mobile':e.detail.value }) }, bindNewPassword(e){ this.setData({ 'form.newPassword':e.detail.value }) }, bindCheckPassword(e){ this.setData({ 'checkPassword':e.detail.value }) }, submit(){ if(!this.data.form.identityNo){ wx.showToast({ title: '请输入身份证号码后6位', icon:'none' }) return false } if(this.data.form.identityNo.length !== 6){ wx.showToast({ title: '请确认身份证号码后6位', icon:'none' }) return false } if(!this.data.form.mobile){ wx.showToast({ title: '请输入手机号码', icon:'none' }) return false } if(this.data.form.mobile.length !== 11){ wx.showToast({ title: '手机号码错误,请确认手机号码', icon:'none' }) return false } if(!this.data.form.newPassword){ wx.showToast({ title: '请输入新密码', icon:'none' }) return false } if(this.data.checkPassword != this.data.form.newPassword){ wx.showToast({ title: '两次密码不一致', icon:'none' }) return false } if(this.data.form.newPassword.length < 6){ wx.showToast({ title: '新密码至少需要6位数字或字符', icon:'none' }) return false } delete this.data.checkPassword api.forgotPwd(this.data.form).then(res=>{ if(res.code === 0){ wx.reLaunch({ url: '/pages/login/login', }) }else { console.log(err); wx.reLaunch({ url: '/pages/formid/formid', }) } }).catch(err=>{ console.log(err); }) } })