From a223d5e29e9384f720ae98c44cbe10f8fa4f73e7 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 21 八月 2025 13:42:16 +0800
Subject: [PATCH] 优化
---
small-program/store/index.js | 39 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 38 insertions(+), 1 deletions(-)
diff --git a/small-program/store/index.js b/small-program/store/index.js
index 66686fa..e783ab2 100644
--- a/small-program/store/index.js
+++ b/small-program/store/index.js
@@ -5,12 +5,21 @@
const navHeight = uni.getStorageSync('navHeight');
const statusbarHeight = uni.getStorageSync('statusbarHeight');
+const userInfo = uni.getStorageSync('userInfo');
+const token = uni.getStorageSync('token');
+const openid = uni.getStorageSync('openid');
const store = new Vuex.Store({
state: {
navHeight: navHeight || '',
- statusbarHeight: statusbarHeight || ''
+ statusbarHeight: statusbarHeight || '',
+ userInfo: userInfo || {},
+ token: token || '',
+ openid: token || '',
+
+ latitude: '',
+ longitude: ''
},
mutations: {
// 璁剧疆瀵艰埅鏍忛珮搴�
@@ -19,6 +28,34 @@
state.statusbarHeight = val.statusbarHeight
uni.setStorageSync('navHeight', val.navHeight);
uni.setStorageSync('statusbarHeight', val.statusbarHeight);
+ },
+ // 璁剧疆token
+ setToken(state, val) {
+ state.token = val
+ uni.setStorageSync('token', val);
+ },
+ // 璁剧疆token
+ setOpenid(state, val) {
+ state.openid = val
+ uni.setStorageSync('openid', val);
+ },
+ // 璁剧疆鐢ㄦ埛淇℃伅
+ setUserInfo(state, val) {
+ state.userInfo = val
+ uni.setStorageSync('userInfo', val);
+ },
+ // 璁剧疆缁忕含搴�
+ setPosition(state, obj) {
+ console.log(obj)
+ state.latitude = obj.latitude
+ state.longitude = obj.longitude
+ },
+ // 娓呴櫎缂撳瓨鏁版嵁
+ empty(state) {
+ state.userInfo = ''
+ state.token = ''
+ uni.removeStorageSync('token');
+ uni.removeStorageSync('userInfo');
}
},
--
Gitblit v1.9.3