From 1a6905045d38bb50b0c6554c3440bdfd339c8d23 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 30 七月 2024 19:13:46 +0800
Subject: [PATCH] ‘’
---
wechat_jiaxuan/app.js | 55 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/wechat_jiaxuan/app.js b/wechat_jiaxuan/app.js
index 2920c51..1aa5ea5 100644
--- a/wechat_jiaxuan/app.js
+++ b/wechat_jiaxuan/app.js
@@ -1,13 +1,16 @@
import {
wxLoginCustomer
} from './api/index'
+import CustomHook from 'spa-custom-hooks';
+let globalData = {
+ token: '',
+ primary: '#B08771',
+ bottomLift: ''
+}
App({
- globalData: {
- primary: '#B08771',
- bottomLift: ''
- },
+ globalData,
onLaunch: function (op) {
- console.log('options', op.query.scene);
+ console.log('options', op.query)
let pathMap = [
'/pages/detailDis/product',
'/pages/detailDis/case',
@@ -18,29 +21,37 @@
//鑾峰彇褰撳墠璁惧淇℃伅
const WindowInfo = wx.getWindowInfo()
if (WindowInfo.safeArea.top > 20) {
- this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom;
+ this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom
}
// 鎺堟潈鐧诲綍
wx.login({
timeout: 5000,
- success(res) {
+ success: (res) => {
+ var userId = null
+ if (op.query.scene) {
+ let temp = op.query.scene.split('_')
+ userId = temp[2]
+ }
if (res.code) {
//鍙戣捣缃戠粶璇锋眰
wxLoginCustomer({
- code: res.code
+ code: res.code,
+ userId
+
}).then(res => {
- console.log(res)
+ wx.setStorageSync('token', res.data.token)
+ this.globalData.token = res.data.token
+ if (op.query.scene) {
+ let temp = op.query.scene.split('_')
+ wx.navigateTo({
+ url: `${pathMap[temp[1]]}?id=${temp[0]}&userId=${temp[2]}`,
+ })
+ }
+ console.log('鎷垮埌token浜�', res.data.token);
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)
- if(op.query.scene){
- let temp = op.query.scene.split('&')
- wx.navigateTo({
- url: `${pathMap[temp[1]]}?id=${temp[0]}`,
- })
- }
} else {
console.log('鐧诲綍澶辫触锛�')
}
@@ -57,4 +68,14 @@
}
-})
\ No newline at end of file
+})
+CustomHook.install({
+ 'Login':{
+ name:'Login',
+ watchKey: 'token',
+ onUpdate(val){
+ //鏈塼oken鍒欒Е鍙戞閽╁瓙
+ return !!val;
+ }
+ }
+ }, globalData || 'globalData')
\ No newline at end of file
--
Gitblit v1.9.3