diff --git a/src/pageB/comm_rec/index.vue b/src/pageB/comm_rec/index.vue index e51e8d1..6b5f3d8 100644 --- a/src/pageB/comm_rec/index.vue +++ b/src/pageB/comm_rec/index.vue @@ -1,17 +1,19 @@ diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 787dcfe..46d959b 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -10,11 +10,12 @@ const ALLACCOUNTS = "app_accounts" const getDefaultState = () => { return { token: uni.getStorageSync(TOKEN), - user: null,//用户信息 - news_num: 0,//消息数 - order_count: null,//订单数量 - history: uni.getStorageSync(HISTORY) || [],//历史搜索 - allaccounts: uni.getStorageSync(ALLACCOUNTS) || [],//所有账号 + // token: '1104|nAMfPQH3HTnb4Y6p06mgIbPjPNC9Hqb24sbglwfQ', + user: null, //用户信息 + news_num: 0, //消息数 + order_count: null, //订单数量 + history: uni.getStorageSync(HISTORY) || [], //历史搜索 + allaccounts: uni.getStorageSync(ALLACCOUNTS) || [], //所有账号 } } @@ -26,16 +27,16 @@ const mutations = { Object.assign(state, getDefaultState()) }, async LOGIN(state, value) { - await this.commit('user/SET_TOKEN',value) - await this.dispatch('user/getUserInfo',false) - }, - LOGOUT(){ + await this.commit('user/SET_TOKEN', value) + await this.dispatch('user/getUserInfo', false) + }, + LOGOUT() { return this.dispatch('user/resetToken') }, // 登录 async SET_TOKEN(state, value) { state.token = value - await uni.setStorageSync(TOKEN, value); + await uni.setStorageSync(TOKEN, value); }, //获取用户信息 SET_USERINFO(state, value) { @@ -52,7 +53,9 @@ const mutations = { if (state.history.length == 0) { state.history.unshift(value) } else { - let Index = state.history.findIndex(item => { return item == value }) + let Index = state.history.findIndex(item => { + return item == value + }) if (Index == -1) { state.history.unshift(value) } @@ -71,7 +74,9 @@ const mutations = { }, //修改资料后改变用户信息 SET_REFRESH(state, value) { - let Index = state.allaccounts.findIndex(item => { return item.phone == value.phone }) + let Index = state.allaccounts.findIndex(item => { + return item.phone == value.phone + }) if (Index != -1) { state.allaccounts[Index].phone = value.phone state.allaccounts[Index].avatar = value.avatar @@ -97,7 +102,10 @@ const actions = { commit, state, dispatch - }, { form, switchAllaccounts }) { + }, { + form, + switchAllaccounts + }) { return new Promise((resolve, reject) => { http.post('/v1/login', form, { @@ -107,12 +115,15 @@ const actions = { }).then(({ token }) => { - if(switchAllaccounts && state.allaccounts.length==0){ + if (switchAllaccounts && state.allaccounts.length == 0) { const tempUserInfo = { - ...Object.assign({},state.user), - token:state.token, + ...Object.assign({}, state.user), + token: state.token, } - dispatch('getAccounts', { info:tempUserInfo, switchAllaccounts }) + dispatch('getAccounts', { + info: tempUserInfo, + switchAllaccounts + }) } resolve(token) commit('SET_TOKEN', token) @@ -150,7 +161,11 @@ const actions = { }, //获取用户信息 - getUserInfo({ commit, state, dispatch }, switchAllaccounts) { + getUserInfo({ + commit, + state, + dispatch + }, switchAllaccounts) { return new Promise((resolve, reject) => { if (!state.token) return @@ -158,16 +173,29 @@ const actions = { custom: { silence: true } - }).then(({ phone, user_info, is_vip, wallet, balance,vip_expired }) => { + }).then(({ + phone, + user_info, + is_vip, + wallet, + balance, + vip_expired + }) => { let user = user_info user.phone = phone user.is_vip = is_vip user.wallet = wallet user.balance = balance - user.vip_expired=vip_expired + user.vip_expired = vip_expired commit('SET_USERINFO', user) dispatch('bindCid') - dispatch('getAccounts', { info: { ...user, token: state.token }, switchAllaccounts }) + dispatch('getAccounts', { + info: { + ...user, + token: state.token + }, + switchAllaccounts + }) resolve(user) }).catch(err => { reject(err) @@ -175,7 +203,13 @@ const actions = { }) }, - getAccounts({ commit, state }, { info, switchAllaccounts = false }) { + getAccounts({ + commit, + state + }, { + info, + switchAllaccounts = false + }) { const obj = { avatar: info.avatar, @@ -194,7 +228,9 @@ const actions = { } commit('SET_ACCOUNTS', all) }, - resetToken({ commit }) { + resetToken({ + commit + }) { return new Promise(resolve => { uni.removeStorageSync(TOKEN); commit('RESET_STATE') @@ -204,19 +240,30 @@ const actions = { bindCid() { // #ifdef APP-PLUS const cid = plus.push.getClientInfo()?.clientid - http.post('/v1/push-bind-uni', { cid }, { custom: { toast: false } }) + http.post('/v1/push-bind-uni', { + cid + }, { + custom: { + toast: false + } + }) // #endif }, //异步获取消息未读数 - getNewsNum({ commit, state }) { + getNewsNum({ + commit, + state + }) { return new Promise((resolve, reject) => { if (!state.token) return http.get('/v1/messages/wait-read-num', {}, { custom: { silence: true } - }).then(({ num }) => { + }).then(({ + num + }) => { commit('SET_NEWS', num) resolve(num) }).catch(err => { @@ -225,7 +272,10 @@ const actions = { }) }, //获取订单数量 - getOrderNum({ commit, state }) { + getOrderNum({ + commit, + state + }) { return new Promise((resolve, reject) => { if (!state.token) return http.get('/v1/order/statistics').then(res => {