Browse Source

开发者功能添加快捷登录

xiaohaizhao 2 months ago
parent
commit
44d074d0e3

+ 36 - 0
pages/login/developerTools.js

@@ -12,6 +12,9 @@ Page({
         } else {
             this.init();
         }
+        this.setData({
+            logins: wx.getStorageSync('logins') || []
+        })
     },
     init() {
         this.setData({
@@ -58,5 +61,38 @@ Page({
                 }
             }
         })
+    },
+    quickLogin(e) {
+        let {
+            item
+        } = e.currentTarget.dataset, page = getCurrentPages()[0].selectComponent("#login"), that = this;
+        if (item.baseUrl != _Http.baseUrl) {
+            wx.showModal({
+                title: '提示',
+                content: `是否确定将服务地址修改为“${item.baseUrl}”?`,
+                cancelText: "取消",
+                confirmText: "确定登录",
+                complete: (res) => {
+                    if (res.confirm) {
+                        that.setData({
+                            baseUrl: item.baseUrl
+                        })
+                        _Http.baseUrl = item.baseUrl;
+                        page.setData({
+                            ...item
+                        })
+                        page.allowOrNot();
+                        page.handleLogin();
+                    }
+                }
+            })
+
+        } else {
+            page.setData({
+                ...item
+            })
+            page.allowOrNot();
+            page.handleLogin();
+        }
     }
 })

+ 11 - 0
pages/login/developerTools.scss

@@ -14,4 +14,15 @@
 .radio {
     font-size: 14px;
     margin-top: 12rpx;
+}
+
+.accountno-box {
+    padding: 20rpx;
+    display: flex;
+    flex-wrap: wrap;
+
+    .accountno {
+        margin-right: 10rpx;
+        margin-bottom: 10rpx;
+    }
 }

+ 5 - 1
pages/login/developerTools.wxml

@@ -21,4 +21,8 @@
             <van-radio custom-class='radio' wx:for="{{urls}}" wx:key="name" name="{{item.url}}">{{item.name}}:{{item.url}}</van-radio>
         </van-radio-group>
     </view>
-</block>
+</block>
+
+<view class="accountno-box">
+    <van-button type="info" wx:for="{{logins}}" custom-class='accountno' wx:key="accountno" data-item="{{item}}" bind:tap="quickLogin">{{item.baseUrl == 'https://oms.idcgroup.com.cn:8079'? '正':'测'}}-{{item.accountno}}</van-button>
+</view>

+ 13 - 2
pages/login/modules/account.js

@@ -67,10 +67,21 @@ Component({
                     title: res.msg,
                     icon: "none"
                 })
-                wx.setStorageSync('loginMsg', {
+                let loginMsg = {
                     accountno: this.data.accountno,
+                    baseUrl: getApp().globalData.http.baseUrl,
                     password: (this.data.memory) ? this.data.password : ''
-                })
+                }
+                let list = wx.getStorageSync('logins') || [],
+                    index = list.findIndex(v => v.accountno == loginMsg.accountno && v.baseUrl == loginMsg.baseUrl);
+
+                if (index != -1) {
+                    list[index] = loginMsg
+                } else {
+                    list.push(loginMsg)
+                }
+                wx.setStorageSync('logins', list)
+                wx.setStorageSync('loginMsg', loginMsg)
                 require("./login").loginMsg(res);
                 getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
             })

+ 3 - 1
pages/tabbar/mine/index.js

@@ -75,10 +75,12 @@ Page({
 					title: getApp().globalData.Language.getMapText('退出成功')
 				});
 				let loginMsg = wx.getStorageSync("loginMsg"),
-					languagecode = wx.getStorageSync("languagecode");
+					languagecode = wx.getStorageSync("languagecode"),
+					logins = wx.getStorageSync("logins");
 
 				wx.clearStorageSync();
 				wx.setStorageSync('loginMsg', loginMsg)
+				wx.setStorageSync('logins', logins)
 				wx.setStorageSync('isAgree', true)
 				wx.removeStorageSync('languagecode');
 				wx.setStorageSync('languagecode', languagecode)