diff --git a/src/store/modules/wxAccount.js b/src/store/modules/wxAccount.js new file mode 100644 index 00000000..19d1c8b5 --- /dev/null +++ b/src/store/modules/wxAccount.js @@ -0,0 +1,32 @@ +import Vue from 'vue' +export default { + namespaced: true, + state: { + ACCOUNT_TYPES:{ + 1:'订阅号', + 2:'服务号' + }, + accountList:[], + selectedAppid:'' + }, + mutations: { + updateAccountList (state, list) { + state.accountList = list + if(!list.length)return + if(!state.selectedAppid){ + let appidCookie = Vue.cookie.get('appid') + let selectedAppid = appidCookie?appidCookie:list[0].appid + this.commit('wxAccount/selectAccount',selectedAppid) + } + }, + selectAccount (state, appid) { + Vue.cookie.set('appid',appid) + let oldAppid = state.selectedAppid + state.selectedAppid = appid + if(oldAppid){//切换账号时刷新网页 + location.reload(); + } + }, + } + } + \ No newline at end of file