|
|
@ -1,6 +1,6 @@ |
|
|
|
import { defineStore } from 'pinia'; |
|
|
|
import { defineStore } from 'pinia'; |
|
|
|
import { login, logout, getInfo } from '@/jtools/api/login'; |
|
|
|
import { login, logout, getInfo } from '@/jtools/api/login'; |
|
|
|
import { queryVip,getVipList } from '@/jtools/api/vip' |
|
|
|
import { queryVip, getVipList } from '@/jtools/api/vip'; |
|
|
|
import constants from '@/jtools/constants'; |
|
|
|
import constants from '@/jtools/constants'; |
|
|
|
import storage from '@/jtools/storage'; |
|
|
|
import storage from '@/jtools/storage'; |
|
|
|
|
|
|
|
|
|
|
@ -23,10 +23,11 @@ const useUserStore = defineStore({ |
|
|
|
// 保存登录信息,用于重新登录
|
|
|
|
// 保存登录信息,用于重新登录
|
|
|
|
this.isLogin = true; |
|
|
|
this.isLogin = true; |
|
|
|
this.token = resp.data.token; |
|
|
|
this.token = resp.data.token; |
|
|
|
this.userInfo = resp.data |
|
|
|
this.userInfo = resp.data; |
|
|
|
storage.set('isLogin', true) |
|
|
|
storage.set('isLogin', true); |
|
|
|
storage.set('token', resp.data.token) |
|
|
|
storage.set('token', resp.data.token); |
|
|
|
storage.set('userInfo', resp.data) |
|
|
|
storage.set('userInfo', resp.data); |
|
|
|
|
|
|
|
storage.remove('companyId'); |
|
|
|
resolve(resp.data); |
|
|
|
resolve(resp.data); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
reject(); |
|
|
|
reject(); |
|
|
@ -39,53 +40,53 @@ const useUserStore = defineStore({ |
|
|
|
this.resetUserData(); |
|
|
|
this.resetUserData(); |
|
|
|
uni.redirectTo({ |
|
|
|
uni.redirectTo({ |
|
|
|
url: '/pages/login/login' |
|
|
|
url: '/pages/login/login' |
|
|
|
}) |
|
|
|
}); |
|
|
|
resolve(); |
|
|
|
resolve(); |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
//过期登出
|
|
|
|
//过期登出
|
|
|
|
logoutWithoutToken(force = false) { |
|
|
|
logoutWithoutToken(force = false) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
this.resetUserData(); |
|
|
|
this.resetUserData(); |
|
|
|
resolve(); |
|
|
|
resolve(); |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 获取用户信息
|
|
|
|
// 获取用户信息
|
|
|
|
getUserInfo() { |
|
|
|
getUserInfo() { |
|
|
|
getInfo().then(resp => { |
|
|
|
getInfo().then(resp => { |
|
|
|
if (resp.code == '0000') { |
|
|
|
if (resp.code == '0000') { |
|
|
|
this.userInfo = resp.data |
|
|
|
this.userInfo = resp.data; |
|
|
|
storage.set('userInfo', resp.data) |
|
|
|
storage.set('userInfo', resp.data); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
resetUserData() { |
|
|
|
resetUserData() { |
|
|
|
this.isLogin = false; |
|
|
|
this.isLogin = false; |
|
|
|
this.token = ''; |
|
|
|
this.token = ''; |
|
|
|
this.userInfo = {} |
|
|
|
this.userInfo = {}; |
|
|
|
this.vipOnList = [] |
|
|
|
this.vipOnList = []; |
|
|
|
storage.remove('isLogin') |
|
|
|
storage.remove('isLogin'); |
|
|
|
storage.remove('token') |
|
|
|
storage.remove('token'); |
|
|
|
storage.remove('userInfo') |
|
|
|
storage.remove('userInfo'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 查询当前用户的vip开通情况
|
|
|
|
// 查询当前用户的vip开通情况
|
|
|
|
async searchUserVip() { |
|
|
|
async searchUserVip() { |
|
|
|
this.currentCartype=storage.get('carType') || '1001' |
|
|
|
this.currentCartype = storage.get('carType') || '1001'; |
|
|
|
const resp=await queryVip({ carTypeId: this.currentCartype,memberId: null, subject:'' }) |
|
|
|
const resp = await queryVip({ carTypeId: this.currentCartype, memberId: null, subject: '' }); |
|
|
|
if (resp.code == '0000') { |
|
|
|
if (resp.code == '0000') { |
|
|
|
this.vipOnList = resp.data |
|
|
|
this.vipOnList = resp.data; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 查询所有的vip
|
|
|
|
// 查询所有的vip
|
|
|
|
queryVipList() { |
|
|
|
queryVipList() { |
|
|
|
this.currentCartype= storage.get('carType') || '1001' |
|
|
|
this.currentCartype = storage.get('carType') || '1001'; |
|
|
|
getVipList({ carTypeId: this.currentCartype, memberId: null, subject: '' }).then(resp => { |
|
|
|
getVipList({ carTypeId: this.currentCartype, memberId: null, subject: '' }).then(resp => { |
|
|
|
if (resp.code == '0000') { |
|
|
|
if (resp.code == '0000') { |
|
|
|
this.vipAllList = resp.data |
|
|
|
this.vipAllList = resp.data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export default useUserStore; |
|
|
|
export default useUserStore; |
|
|
|