zhaoxiaohai 3 лет назад
Родитель
Сommit
d66c2d8d62
3 измененных файлов с 103 добавлено и 7 удалено
  1. 99 4
      pages/teamManagement/change.js
  2. 3 3
      pages/teamManagement/change.wxml
  3. 1 0
      pages/teamManagement/change.wxss

+ 99 - 4
pages/teamManagement/change.js

@@ -6,6 +6,8 @@ import {
     TestVerify
 } from "../../utils/verify"
 const _Verify = new TestVerify();
+const utilMd5 = require('../../utils/md5')
+let countDown = null;
 Page({
     /**
      * 页面的初始数据
@@ -21,12 +23,16 @@ Page({
         throttle: false, //节流阀
         makeOver: false,
         showModel: false,
+        codeChange: "", //验证码
+        codeCount: 60,
+        verificationCode: "",
         /* 必填项 */
         errTips: {
             fname: false,
             frole: false,
             fphonenumber: false
-        }
+        },
+        tispText: "", //验证码提示文本
     },
     /* input事件剔除特殊字符 */
     eliminate(value) {
@@ -59,14 +65,101 @@ Page({
             })
         }
     },
+    /* 获取验证码 */
+    getAuthCode() {
+        if (this.data.codeCount != 60) return wx.showToast({
+            title: '已发送验证码,请勿重复获取',
+            icon: "none"
+        })
+        _Http.basic({
+            "accesstoken": wx.getStorageSync('userData').token,
+            "classname": "customer.usercenter.teammsg.teammsg",
+            "method": "getPassword",
+            "content": {
+                "tenterprise_userid": this.data.tenterprise_userid
+            }
+        }).then(res => {
+            console.log("转让主账号", res)
+            if (res.data != '成功') return;
+            const that = this;
+            wx.showToast({
+                title: '已将验证码发送到受让方',
+                icon: "none",
+                duration: 3000
+            })
+            this.setData({
+                tispText: "已发送到对方手机号"
+            })
+            that.setData({
+                codeCount: this.data.codeCount - 1
+            });
+            countDown = setInterval(() => {
+                if (this.data.codeCount == 0) {
+                    that.setData({
+                        codeCount: 60
+                    });
+                    clearInterval(countDown)
+                    return
+                }
+                that.setData({
+                    codeCount: this.data.codeCount - 1
+                });
+            }, 1000)
+        })
+    },
+    /* 回调 */
+    callBack({
+        detail
+    }) {
+        clearInterval(countDown)
+        this.setData({
+            codeCount: 60,
+            tispText: ''
+        });
+        if (detail == 'true') {
+            if (this.data.verificationCode == '') return wx.showToast({
+                title: '验证码不能为空',
+                icon: "none"
+            })
+            _Http.basic({
+                "accesstoken": wx.getStorageSync('userData').token,
+                "classname": "customer.usercenter.teammsg.teammsg",
+                "method": "changeAdministrator",
+                "content": {
+                    "tenterprise_userid": this.data.tenterprise_userid,
+                    "fpassword": utilMd5.hexMD5(this.data.verificationCode)
+                }
+            }).then(res => {
+                console.log(res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.msg,
+                    icon: "none"
+                })
+                wx.showToast({
+                    title: '转让成功!请您重新登录',
+                    icon: "none",
+                });
+                setTimeout(() => {
+                    wx.reLaunch({
+                        url: '/pages/login/index',
+                    })
+                }, 1000)
+            })
+        } else {
+
+        }
+    },
     /* 转让主账号 */
     makeOverChange() {
         this.setData({
             showModel: true
         })
     },
-    codeChange(e){
-        console.log(e)
+    /* 验证码输入 */
+    codeChange(e) {
+        this.setData({
+            verificationCode: e.detail.value
+        })
     },
     /* 提交 */
     submit() {
@@ -219,7 +312,9 @@ Page({
     /**
      * 生命周期函数--监听页面卸载
      */
-    onUnload: function () {},
+    onUnload: function () {
+        clearInterval(countDown);
+    },
 
     /**
      * 页面相关事件处理函数--监听用户下拉动作

+ 3 - 3
pages/teamManagement/change.wxml

@@ -28,11 +28,11 @@
     <van-button bindtap="submit" custom-class="custom-class" round color="linear-gradient(180deg, #82E0E9 0%, #4BBECF 100%);">保存</van-button>
 </view>
 
-<My_showModel isShow='{{showModel}}' transition=" " content="已将验证码发送到对方手机号">
+<My_showModel isShow='{{showModel}}' transition=" " content="{{tispText}}" bindcallBack='callBack'>
     <view class="showModelCon" style="margin-top: 5rpx;">
         <view class="input-box">
-            <input type="text" placeholder-class="index" placeholder="请输入验证码" bindinput="codeChange" />
+            <input type="number" placeholder-class="index" placeholder="请输入验证码" bindinput="codeChange" />
         </view>
-        <view class="gain">获取验证码</view>
+        <view class="gain" catchtap="getAuthCode">{{codeCount==60?'获取验证码':codeCount+'s'}}</view>
     </view>
 </My_showModel>

+ 1 - 0
pages/teamManagement/change.wxss

@@ -5,6 +5,7 @@
     justify-content: space-between;
     align-items: center;
     height: 80rpx;
+    margin-bottom: 10rpx;
 }
 
 .input-box {