From 716ab46fb071ed48bc75d10fabed66bd8fcae6f1 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 22 七月 2024 15:45:11 +0800
Subject: [PATCH] 代码提交

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

diff --git a/wechat_jiaxuan/app.js b/wechat_jiaxuan/app.js
index 746a9f2..c9e2dcb 100644
--- a/wechat_jiaxuan/app.js
+++ b/wechat_jiaxuan/app.js
@@ -1,4 +1,6 @@
-// app.js
+import {
+  wxLoginCustomer
+} from './api/index'
 App({
   globalData: {
     primary: '#B08771',
@@ -7,10 +9,38 @@
   onLaunch: function () {
     //鑾峰彇褰撳墠璁惧淇℃伅
     const WindowInfo = wx.getWindowInfo()
-    console.log('WindowInfo', WindowInfo);
     if (WindowInfo.safeArea.top > 20) {
       this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom;
-      console.log(this.globalData.bottomLift);
     }
+    // 鎺堟潈鐧诲綍
+    const member = wx.getStorageSync('member')
+    wx.login({
+      timeout: 5000,
+      success(res) {
+        if (res.code) {
+          //鍙戣捣缃戠粶璇锋眰
+          wxLoginCustomer({
+            code: res.code
+          }).then(res => {
+            console.log(res)
+            if (res && res.data.member) {
+              wx.setStorageSync('member', res.data.member)
+              wx.setStorageSync('openid', res.data.member.openid)
+              wx.setStorageSync('sessionKey', res.data.sessionKey)
+              wx.setStorageSync('token', res.data.token)
+            } else {
+              console.log('鐧诲綍澶辫触锛�')
+            }
+          })
+        } else {
+          console.log('鐧诲綍澶辫触锛�' + res)
+        }
+      },
+      fail(err) {
+        console.log(err)
+      }
+    })
+
+
   }
-})
+})
\ No newline at end of file

--
Gitblit v1.9.3