全新UI视觉体验,移动端API优化降低重复调用,提高并发6倍,修复N多Bug

This commit is contained in:
stivepeim
2021-06-11 17:41:16 +08:00
parent 0b9f28fa52
commit b76840e10f
582 changed files with 35633 additions and 28276 deletions

View File

@@ -3,7 +3,8 @@ import {
} from "../../api/user.js";
import {
LOGIN_STATUS,
UID
UID,
PLATFORM
} from '../../config/cache';
import Cache from '../../utils/cache';
import {
@@ -11,21 +12,22 @@ import {
} from '../../config/cache';
const state = {
token: Cache.get(LOGIN_STATUS) || null,
token: Cache.get(LOGIN_STATUS) || '',
backgroundColor: "#fff",
userInfo: Cache.get(USER_INFO)?JSON.parse(Cache.get(USER_INFO)):null,
uid: Cache.get(UID) || null,
homeActive: false,
chatUrl: Cache.get('chatUrl') || '',
authorizeType: ''
systemPlatform: Cache.get(PLATFORM)?Cache.get(PLATFORM):'',
productType: Cache.get('productType') || ''
};
const mutations = {
LOGIN(state, opt) {
state.token = opt.token;
Cache.set(LOGIN_STATUS, opt.token, opt.time);
Cache.set(LOGIN_STATUS, opt.token);
},
SETUID(state,val){
SETUID(state,val){
state.uid = val;
Cache.set(UID, val);
},
@@ -37,6 +39,7 @@ const mutations = {
state.uid = undefined
Cache.clear(LOGIN_STATUS);
Cache.clear(UID);
Cache.clear(USER_INFO);
},
BACKGROUND_COLOR(state, color) {
state.color = color;
@@ -55,8 +58,22 @@ const mutations = {
SET_CHATURL(state, chatUrl){
state.chatUrl = chatUrl;
},
AuthorizeType(state, authorizeType){
state.authorizeType = authorizeType;
// AuthorizeType(state, authorizeType){
// state.authorizeType = authorizeType;
// },
SYSTEM_PLATFORM(state, systemPlatform){
state.systemPlatform = systemPlatform;
Cache.set(PLATFORM, systemPlatform);
},
//更新useInfo数据
changInfo(state, payload) {
state.userInfo[payload.amount1] = payload.amount2;
Cache.set(USER_INFO, state.userInfo);
},
//商品类型,用于区分视频号商品与一般商品
PRODUCT_TYPE(state, productType) {
state.productType = productType;
Cache.set('productType', productType);
}
};
@@ -65,18 +82,26 @@ const actions = {
state,
commit
}, force) {
if (state.userInfo !== null && !force)
return Promise.resolve(state.userInfo);
else
return new Promise(reslove => {
getUserInfo().then(res => {
commit("UPDATE_USERINFO", res.data);
Cache.set(USER_INFO, res.data);
reslove(res.data);
});
}).catch(() => {
return new Promise(reslove => {
getUserInfo().then(res => {
commit("UPDATE_USERINFO", res.data);
reslove(res.data);
});
}).catch(() => {
});
// debugger
// if (state.userInfo !== null && !force)
// return Promise.resolve(state.userInfo);
// else
// return new Promise(reslove => {
// getUserInfo().then(res => {
// commit("UPDATE_USERINFO", res.data);
// reslove(res.data);
// });
// }).catch(() => {
// });
}
};