From a75b18a4157ab486e0b51c438ac165ab3a08e3e0 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 18:10:00 +0800
Subject: [PATCH] 代码提交

---
 wechat_staff/app.js |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/wechat_staff/app.js b/wechat_staff/app.js
index 3dc96bb..d83da7c 100644
--- a/wechat_staff/app.js
+++ b/wechat_staff/app.js
@@ -1,4 +1,6 @@
-// app.js
+import {
+  wxLoginCustomer
+} from './api/index'
 App({
   globalData: {
     primary: '#B08771',
@@ -10,7 +12,35 @@
     if (WindowInfo.safeArea.top > 20) {
       this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom;
     }
-    // 
-    // let menuButtonInfo = wx.getMenuButtonBoundingClientRect();
+    wx.login({
+      timeout: 5000,
+      success(res) {
+        if (res.code) {
+          //鍙戣捣缃戠粶璇锋眰
+          wxLoginCustomer({
+            code: res.code
+          }).then(res => {
+            if (res && res.data) {
+              wx.setStorageSync('member', res.data.users || '')
+              wx.setStorageSync('sessionKey', res.data.sessionKey)
+              wx.setStorageSync('token', res.data.token || '')
+            } else {
+              wx.navigateTo({
+                url: '/pages/login/index',
+              })
+              console.log('鐧诲綍澶辫触锛�')
+            }
+          })
+        } else {
+          wx.navigateTo({
+            url: '/pages/login/index',
+          })
+          console.log('鐧诲綍澶辫触锛�' + res)
+        }
+      },
+      fail(err) {
+        console.log(err)
+      }
+    })
   }
-})
+})
\ No newline at end of file

--
Gitblit v1.9.3