12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import PersistedState from '../PersistedState'
- // initial state
- const state = {
- isOnline:PersistedState.getStorage('member','isOnline', false),
- token:PersistedState.getStorage('member','token'),
- info:PersistedState.getStorage('member','info'),
- point:PersistedState.getStorage('member','point', {}),
- inviterId:PersistedState.getStorage('member','inviterId', 0),
- isTokenInvalid:PersistedState.getStorage('member','isTokenInvalid', false),
- storeJoinin1:PersistedState.getStorage('member','storeJoinin1', {store_type:1}),
- storeJoinin0:PersistedState.getStorage('member','storeJoinin0', {store_type:0}),
- storeJoininType: PersistedState.getStorage('member','storeJoininType', 1)
- }
- // mutations
- const mutations = {
- sellerJoininSave (state, payload) {
- if(payload.storeJoinin.store_type==1){
- state.storeJoinin1 = Object.assign(
- state.storeJoinin1,
- payload.storeJoinin)
- }else{
- state.storeJoinin0 = Object.assign(
- state.storeJoinin0,
- payload.storeJoinin)
- }
- state.storeJoininType = payload.storeJoinin.store_type
- PersistedState.setStorage('member',state)
- },
- sellerJoininTypeSave (state, payload) {
- state.storeJoininType = payload.storeJoininType
- PersistedState.setStorage('member',state)
- },
- memberInviterId (state, payload) {
- state.inviterId = payload.inviterId
- PersistedState.setStorage('member',state)
- },
- memberPoint (state, payload) {
- state.point = Object.assign(
- state.point,
- payload.point)
- PersistedState.setStorage('member',state)
- },
- memberLogin (state, payload) {
- state.info = payload.info
- state.info.invalid_time = parseInt((new Date().getTime()) / 1000) + 3600// 一小时更新
- state.isOnline = true
- state.token = payload.token
- state.isTokenInvalid = false
- PersistedState.setStorage('member',state)
- },
- memberLogout (state) {
- state.info = null
- state.isOnline = false
- state.token = null
- PersistedState.setStorage('member',state)
- },
- memberUpdate (state, payload) {
- if (state.info) {
- state.info = payload.info
- state.info.invalid_time = parseInt((new Date().getTime()) / 1000) + 3600// 一小时更新
- PersistedState.setStorage('member',state)
- }
- },
- memberEdit (state, payload) {
- if (state.info) {
- let i
- for (i in payload) {
- state.info[i] = payload[i]
- }
- PersistedState.setStorage('member',state)
- }
- }
- }
- export default {
- state,
- mutations
- }
|