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_staff/app.js | 43 ++++++++++++++++++++++++++++++++++++++++---
1 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/wechat_staff/app.js b/wechat_staff/app.js
index 3dc96bb..ca43848 100644
--- a/wechat_staff/app.js
+++ b/wechat_staff/app.js
@@ -1,4 +1,4 @@
-// app.js
+import { wxLoginCustomer } from './api/index'
App({
globalData: {
primary: '#B08771',
@@ -9,8 +9,45 @@
const WindowInfo = wx.getWindowInfo()
if (WindowInfo.safeArea.top > 20) {
this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom;
+ }
+ const res = wx.getStorageSync('member')
+ if (res) {
+ this.globalData.userInfo = res
+ console.error("res",res)
+ } else {
+ // 鐧诲綍
+ wx.login({
+ timeout: 5000,
+ success(res) {
+ if (res.code) {
+ //鍙戣捣缃戠粶璇锋眰
+ wxLoginCustomer({
+ code: res.code
+ }).then(res => {
+ console.log(res)
+ if (res && res.data.users) {
+ wx.setStorageSync('member', res.data.users)
+ wx.setStorageSync('openid', res.data.users.openid)
+ 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)
+ }
+ })
}
- //
- // let menuButtonInfo = wx.getMenuButtonBoundingClientRect();
}
})
--
Gitblit v1.9.3