// component/updatePassword/updatePassword.ts import { httpUtil } from "../../utils/restful"; Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { width: 671, height: 713, initScale: 0, showAccPwd: true, scaleAnim: 0, inputPhoneNum: '', inputVCode: '', inputPwd: '', hasGetVCode: false, getVCodeText: "获取验证码", getvcodeInter: -5 }, lifetimes: { attached: function () { // 在组件实例被从页面节点树添加时执行 //放大小动画() this.data.scaleAnim = setInterval(() => { if (this.data.initScale < 0.9) { this.setData({ initScale: this.data.initScale + 0.1 }) } else { clearInterval(this.data.scaleAnim) } }, 15); }, detached: function () { // 在组件实例被从页面节点树移除时执行 }, }, /** * 组件的方法列表 */ methods: { //账号密码登录——--------------------------- showAccountPwd: function (event: any) { if (this.data.showAccPwd) { this.setData({ showAccPwd: false }) } else { this.setData({ showAccPwd: true }) } }, hideSelf: function () { //调用父组件方法移除自身 this.triggerEvent('showUpdatePwdLayout'); }, bindPwdLoginPhoneInput: function (event: any) { this.setData({ inputPhoneNum: event.detail.value }) }, bindVCodeInput: function (event: any) { this.setData({ inputVCode: event.detail.value }) }, bindPassWordInput: function (event: any) { this.setData({ inputPwd: event.detail.value }) }, // 获取验证码 clickGetVCode: function (event: any) { if (this.data.hasGetVCode) { this.showToast("请勿频繁点击") return; } if (!this.data.inputPhoneNum) { this.showToast("请输入手机号") return; } let that = this; let time = 60; this.data.getvcodeInter = setInterval(function () { if (time <= 1) { clearInterval(that.data.getvcodeInter) that.setData({ hasGetVCode: false, getVCodeText: '获取验证码', getvcodeInter: -5 }) return; } time--; that.setData({ getVCodeText: time.toString(), hasGetVCode: true }) }, 1000) let params = { mobileNo: this.data.inputPhoneNum } httpUtil.wxGet(httpUtil.interfaces.getVerifyCode, params).then((res) => { console.log("获取验证码成功:", res) }).catch((res) => { console.log("获取验证码失败:", res) }) }, submitInfo: function () { if (!this.data.inputPhoneNum) { this.showToast("请输入手机号") return; } if (!this.data.inputVCode) { this.showToast("请输入验证码") return; } let params = { mobile: this.data.inputPhoneNum, password: this.data.inputPwd, verifyCode: this.data.inputVCode } let that = this; httpUtil.wxPost(httpUtil.interfaces.updatePassWord, params).then((res) => { console.log("修改密码成功:", res) that.hideSelf() }).catch((res) => { console.log("修改密码失败:", res) that.showToast(res.data.message) }) }, showToast: function (message: string) { wx.showToast({ title: message, icon: 'none' }) } } })