增加公共状态管理
This commit is contained in:
61
store/common.js
Normal file
61
store/common.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import {
|
||||
defineStore
|
||||
} from "pinia";
|
||||
import {getCommonConfig} from '@/api/init.js'
|
||||
const $map = {
|
||||
882: 'isWxIosPay',
|
||||
833: 'checkIosLogin',
|
||||
834: 'checkIosPay',
|
||||
835: 'checkWxLogin',
|
||||
836: 'checkPhoneLogin',
|
||||
108: 'isOpenWxWebAutoLogin',
|
||||
817: 'zhengbu',
|
||||
818: 'danbu',
|
||||
252: 'adUnitId',
|
||||
821: 'playType',
|
||||
251: 'isGuanggao',
|
||||
254: 'isGuanggaody',
|
||||
202: 'kefu',
|
||||
206: 'kefuPhone',
|
||||
204: 'kefuUrl',
|
||||
203: 'kefuAppId',
|
||||
248: 'isVips',
|
||||
249: 'moreSearch',
|
||||
49: 'AppUrl',
|
||||
823: 'OfferID',
|
||||
824: 'payEnv',
|
||||
825: 'moneyTips',
|
||||
855: 'kmPaySel',
|
||||
849: 'homeTypeSel',
|
||||
856: 'syPaySel',
|
||||
857: 'imId',
|
||||
858: 'isAccountPay',
|
||||
860: 'dyadUnitId',
|
||||
881: '',
|
||||
109: '',
|
||||
922: 'withdrawNum',
|
||||
500:'payTips'
|
||||
}
|
||||
|
||||
export const useCommonStore = defineStore("common", {
|
||||
state() {
|
||||
return {
|
||||
payTips:'付款完成后不要忘记抽红包哦'
|
||||
};
|
||||
},
|
||||
actions:{
|
||||
async init(){
|
||||
const res=await getCommonConfig()
|
||||
if(res){
|
||||
for (let i in $map) {
|
||||
const key = $map[i]
|
||||
if (key) {
|
||||
this[key]=res[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(res);
|
||||
}
|
||||
},
|
||||
unistorage: true, // 开启后对 state 的数据读写都将持久化
|
||||
});
|
||||
Reference in New Issue
Block a user