// pages/setpwd/setpwd.js const config = require('../../config/config.js') const Common = require("../../common/common.js") const app = getApp() Page({ data: { phone: '', yzm: '' }, onLoad(e) { this.setData({ phone: e.phone, yzm: e.code }) }, setPwd(e) { let { newPwd, pwd } = e.detail.value var regx = /^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z\d]{8,16}$/; if (newPwd.match(regx) == null) { tt.showToast({ title: '密码为8-16位字母和数字的组合', icon: "none" // image: './../../static/images/fail.png', }) } else { console.log(newPwd) console.log(pwd) if (newPwd == pwd) { Common.updateUserPassword(this.data.phone, this.data.yzm, newPwd) .then(res => { if (res.code == 200) { tt.showToast({ title: "修改成功", icon: "none", duration:1200 }) setTimeout(function () { tt.reLaunch({ url: '/pages/main/main', }) }, 1200) } else { tt.showToast({ title: res.message, icon: "none" }) } }) } else { tt.showToast({ title: '密码不一致', icon: "none" // image: './../../static/images/fail.png', }) } } } })