From 0d1323fb39db5e8d3b124e61303bde1b1352b887 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期四, 29 二月 2024 21:48:02 +0800
Subject: [PATCH] feat(daima代码合并): 和宁

---
 pages/testLogin/index.js |  132 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 132 insertions(+), 0 deletions(-)

diff --git a/pages/testLogin/index.js b/pages/testLogin/index.js
new file mode 100644
index 0000000..d516931
--- /dev/null
+++ b/pages/testLogin/index.js
@@ -0,0 +1,132 @@
+// pages/testLogin/index.js
+const app = getApp();
+
+Page({
+
+  /**
+   * 椤甸潰鐨勫垵濮嬫暟鎹�
+   */
+  data: {
+    textName: "18892081234",
+    textPassword: "xA123456",
+    loading: false,
+    userInfo: {
+      name: "",
+      icon: ""
+    }
+  },
+
+  // 鐧诲綍
+  onLogin() {
+    this.setData({
+      loading: true
+    })
+    const data = {
+      loginName: this.data.textName,
+      password: this.data.textPassword,
+      appRefCode: app.config.appRefCode,
+      platform: "Mobile",
+    };
+    app.MG.identity.loginByPassword(data).then(res => {
+      if (res && res.status == "Ok") {
+        this.setData({
+          loginInfo: JSON.stringify(res)
+        })
+        wx.setStorageSync(app.config.tokenKey, res.token);
+        this.getUserInfo()
+      } else {
+        wx.showToast({
+          title: res.message || "鎵嬫満鍙锋垨瀵嗙爜閿欒",
+          icon: "error",
+          duration: 2000
+        })
+      }
+    });
+  },
+
+  // 鑾峰彇鐢ㄦ埛淇℃伅
+  // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤
+  getUserInfo() {
+    app.MG.identity.getCurrentAppUser().then(res => {
+      // 鐢ㄦ埛淇℃伅浼樺厛绾э細鏁欏笀璁よ瘉 > 寰俊 > 瀛︾敓锛堟敞鍐屾椂榛樿锛�
+      if (res) {
+        console.log(res, "user");
+        let defaultUser = {};
+        let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword')
+        let WeChatInfo = res.infoList.find((item) => item.type === "WeChat");
+        if (WeChatInfo) {
+          defaultUser = {
+            nickName: WeChatInfo.name,
+            avatarUrl: WeChatInfo.icon,
+            userId: res.userId
+          }
+        }
+        if (secretData) {
+          defaultUser = {
+            nickName: secretData.credential,
+            avatarUrl: "../../static/images/index/tab.png",
+            userId: res.userId
+          }
+        }
+
+        this.setData({
+          userInfo: defaultUser,
+          loading: false
+        })
+        wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo));
+      }
+      wx.switchTab({
+        url: '/pages/home/home'
+      })
+    });
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
+   */
+  onLoad(options) {
+    console.log(options);
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
+   */
+  onReachBottom() {
+
+  }
+})
\ No newline at end of file

--
Gitblit v1.9.1