123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- // 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'
- })
- }
- }
- })
|