Sfoglia il codice sorgente

Merge branch 'green'

NULL1222 4 giorni fa
parent
commit
72b8dcc2c8
2 ha cambiato i file con 49 aggiunte e 25 eliminazioni
  1. 48 24
      pages/login/retrievePassword.js
  2. 1 1
      pages/login/retrievePassword.wxml

+ 48 - 24
pages/login/retrievePassword.js

@@ -4,7 +4,8 @@ let passwordDowm = null;
 Page({
     data: {
         from: {
-            accountno: "", //账户名
+            accountno: "", //通过手机号查询到的账号
+            phonenumber: "", //手机号
             password: "", //验证码
             newPassword: "", //新密码
             verifyNewPassword: "", //确认密码
@@ -19,43 +20,66 @@ Page({
     },
     /* 获取验证码 */
     getPassword() {
-        let accountno = this.data.from.accountno;
-        if (!accountno) return Toast({
-            message: getApp().globalData.Language.getMapText('还未填写账号') || '您还未填写账户名称',
-            position: 'bottom'
-        });
-        if (this.data.countDown != '') return;
-        /*  Toast({
-            message: '您已发送验证码,请勿重复获取',
+      let phonenumber = this.data.from.phonenumber;
+      if (!phonenumber) return Toast({
+        message: getApp().globalData.Language.getMapText('还未填写手机号') || '您还未填写手机号码',
+        position: 'bottom'
+      });
+      if (this.data.countDown != '') return;
+      /* 第一步:通过手机号查询账号 */
+      getApp().globalData.http.base({
+        "id": 2026060914572402,
+        "content": {
+            phonenumber
+        }
+    }, false).then(res => {
+        if (res.code != 1) return Toast({
+            message: res.msg,
             position: 'bottom'
-        }); */
-        getApp().globalData.http.base({
+          });
+          let accountno = res.data.accountno;
+          if (!accountno) return Toast({
+              message: '未找到该手机号对应的账号',
+              position: 'bottom'
+          });
+          /* 第二步:通过账号获取验证码 */
+          getApp().globalData.http.base({
             "classname": "common.usercenter.usercenter",
             "method": "forgetPassword_getPassWord",
             "content": {
                 accountno
             }
-        }, false).then(res => {
-            if (res.code != 1) return Toast({
-                message: res.msg,
+        }, false).then(res2 => {
+            if (res2.code != 0) return Toast({
+                message: res2.msg,
                 position: 'bottom'
-            });
-            this.setData({
-                countDown: 30
-            })
-            passwordDowm = setInterval(() => {
+              });
+              this.setData({
+                countDown: 30,
+                ['from.accountno']: accountno
+              })
+              passwordDowm = setInterval(() => {
                 let countDown = (this.data.countDown == 0) ? '' : this.data.countDown - 1;
                 this.setData({
-                    countDown
+                  countDown
                 })
                 if (countDown == '') clearInterval(passwordDowm)
-            }, 1000);
-            Toast({
-                message: res.msg,
+              }, 1000);
+              Toast({
+                message: res2.msg,
                 position: 'bottom'
-            });
+              });
+            })
         })
     },
+    // 页面卸载清除定时器
+    onUnload() {
+      if (passwordDowm) {
+        clearInterval(passwordDowm);
+        passwordDowm = null;
+        console.log('【页面卸载】清除遗留定时器');
+      }
+    },
     /* 表单输入 */
     formInput(e) {
         let v = e.detail.value.trim(),

+ 1 - 1
pages/login/retrievePassword.wxml

@@ -2,7 +2,7 @@
     <view class="icon-box">
         <text class="iconfont icon-a-biaoqianlanwodexuanzhong" />
     </view>
-    <input class="input" type="text" bindinput="formInput" data-name="accountno" placeholder="{{language['手机号']||'请填写手机号'}}" />
+    <input class="input" type="text" bindinput="formInput" data-name="phonenumber" placeholder="{{language['手机号']||'请填写手机号'}}" />
 </view>
 <view class='input-field'>
     <view class="icon-box">