import {getDataSet, getEventParam, isMobile, toast} from "../../utils/utils"; import Api from "../../model/api"; import User from "../../model/user"; Page({ data: { formData: { phone: '', checkNum: '', } }, onLoad: function (options) { }, onChange(e) { const field = getDataSet(e, "field"); this.setData({ [field]: getEventParam(e) }) }, async update(e) { if (!isMobile(this.data.formData.phone)) { toast('请输入正确的手机号') return; } if (!this.data.formData.checkNum.trim()) { toast('请输入验证码') return; } await Api.updatePhone(this.data.formData, true) let user = User.getUserInfoByLocal(); user.phone = this.data.formData.phone; await User.updateUserInfo(user) wx.navigateBack(); } })