|
@@ -2,68 +2,68 @@ import { defineStore } from 'pinia'
|
|
|
import { userProfile } from '@/api/index'
|
|
import { userProfile } from '@/api/index'
|
|
|
|
|
|
|
|
const userInfo = defineStore({
|
|
const userInfo = defineStore({
|
|
|
- id: 'userInfo',
|
|
|
|
|
- state: () => ({
|
|
|
|
|
- UserInfo: {
|
|
|
|
|
- account: '',
|
|
|
|
|
- password: ''
|
|
|
|
|
- },
|
|
|
|
|
- profile:{} as any,
|
|
|
|
|
- routes:[
|
|
|
|
|
- { id: 0, path: '/p_index', title: '首页' },
|
|
|
|
|
- // { id: 1, path: '/p_rank', title: '排行' },
|
|
|
|
|
- { id: 2, path: '/p_categroy', title: '分类' },
|
|
|
|
|
- { id: 4, path: '/p_order', title: '订单' },
|
|
|
|
|
- { id: 3, path: '/p_mine', title: '我的' }
|
|
|
|
|
- ] as {id:number,path:string,title:string}[],
|
|
|
|
|
- menuPath:[
|
|
|
|
|
- { text: '首页', value: 1, url: 'm_index' },
|
|
|
|
|
- // { text: '排行', value: 2, url: 'm_rank' },
|
|
|
|
|
- { text: '分类', value: 3, url: 'm_categroy' },
|
|
|
|
|
- { text: '我的游戏', value: 4, url: 'm_mine' },
|
|
|
|
|
- ]
|
|
|
|
|
- }),
|
|
|
|
|
- actions: {
|
|
|
|
|
- setUerInfo(data: any) {
|
|
|
|
|
- this.UserInfo = data
|
|
|
|
|
- console.log('UserInfo', this.UserInfo);
|
|
|
|
|
- },
|
|
|
|
|
- setProfile(info:any){
|
|
|
|
|
- this.profile = info
|
|
|
|
|
- },
|
|
|
|
|
- async getUserProfile(){
|
|
|
|
|
- // from 2 手机登录 1密码登录
|
|
|
|
|
- await userProfile({from: parseInt(localStorage.getItem('from') as string)}).then((res) => {
|
|
|
|
|
- console.log(res)
|
|
|
|
|
- this.setProfile(res.data.data)
|
|
|
|
|
- this.routes = [
|
|
|
|
|
- { id: 0, path: '/p_index', title: '首页' },
|
|
|
|
|
- // { id: 1, path: '/p_rank', title: '排行' },
|
|
|
|
|
- { id: 2, path: '/p_categroy', title: '分类' },
|
|
|
|
|
- { id: 4, path: '/p_order', title: '订单' },
|
|
|
|
|
- { id: 5, path: '/p_ecoin', title: this.profile.ecoinName },
|
|
|
|
|
- { id: 6, path: '/p_ncoin', title: this.profile.ncoinName },
|
|
|
|
|
- { id: 3, path: '/p_mine', title: '我的' }
|
|
|
|
|
- ]
|
|
|
|
|
- this.menuPath = [
|
|
|
|
|
- { text: '首页', value: 1, url: 'm_index' },
|
|
|
|
|
- // { text: '排行', value: 2, url: 'm_rank' },
|
|
|
|
|
- { text: '分类', value: 3, url: 'm_categroy' },
|
|
|
|
|
- { text: '订单', value: 5, url: 'm_order' },
|
|
|
|
|
- { text: this.profile.ecoinName, value: 6, url: 'm_ecoin' },
|
|
|
|
|
- { text: this.profile.ncoinName, value: 7, url: 'm_ncoin' },
|
|
|
|
|
- { text: '我的游戏', value: 4, url: 'm_mine' },
|
|
|
|
|
- ]
|
|
|
|
|
- }).catch((error) => {
|
|
|
|
|
- console.log(error)
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ id: 'userInfo',
|
|
|
|
|
+ state: () => ({
|
|
|
|
|
+ UserInfo: {
|
|
|
|
|
+ account: '',
|
|
|
|
|
+ password: ''
|
|
|
|
|
+ },
|
|
|
|
|
+ profile: {} as any,
|
|
|
|
|
+ routes: [
|
|
|
|
|
+ { id: 0, path: '/p_index', title: '首页' },
|
|
|
|
|
+ // { id: 1, path: '/p_rank', title: '排行' },
|
|
|
|
|
+ { id: 2, path: '/p_categroy', title: '分类' },
|
|
|
|
|
+ { id: 4, path: '/p_order', title: '订单' },
|
|
|
|
|
+ { id: 3, path: '/p_mine', title: '我的' }
|
|
|
|
|
+ ] as {id:number, path:string, title:string}[],
|
|
|
|
|
+ menuPath: [
|
|
|
|
|
+ { text: '首页', value: 1, url: 'm_index' },
|
|
|
|
|
+ // { text: '排行', value: 2, url: 'm_rank' },
|
|
|
|
|
+ { text: '分类', value: 3, url: 'm_categroy' },
|
|
|
|
|
+ { text: '我的游戏', value: 4, url: 'm_mine' }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }),
|
|
|
|
|
+ actions: {
|
|
|
|
|
+ setUerInfo(data: any) {
|
|
|
|
|
+ this.UserInfo = data
|
|
|
|
|
+ console.log('UserInfo', this.UserInfo)
|
|
|
|
|
+ },
|
|
|
|
|
+ setProfile(info:any) {
|
|
|
|
|
+ this.profile = info
|
|
|
},
|
|
},
|
|
|
- getters: {
|
|
|
|
|
- getAccount(state){
|
|
|
|
|
- return state.UserInfo.account
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ async getUserProfile() {
|
|
|
|
|
+ // from 2 手机登录 1密码登录
|
|
|
|
|
+ await userProfile({ from: parseInt(localStorage.getItem('from') as string) }).then((res) => {
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ this.setProfile(res.data.data)
|
|
|
|
|
+ this.routes = [
|
|
|
|
|
+ { id: 0, path: '/p_index', title: '首页' },
|
|
|
|
|
+ // { id: 1, path: '/p_rank', title: '排行' },
|
|
|
|
|
+ { id: 2, path: '/p_categroy', title: '分类' },
|
|
|
|
|
+ { id: 4, path: '/p_order', title: '订单' },
|
|
|
|
|
+ { id: 5, path: '/p_ecoin', title: this.profile.ecoinName + ':' + this.profile.ecoin },
|
|
|
|
|
+ { id: 6, path: '/p_ncoin', title: this.profile.ncoinName + ':' + this.profile.ncoin },
|
|
|
|
|
+ { id: 3, path: '/p_mine', title: '我的' }
|
|
|
|
|
+ ]
|
|
|
|
|
+ this.menuPath = [
|
|
|
|
|
+ { text: '首页', value: 1, url: 'm_index' },
|
|
|
|
|
+ // { text: '排行', value: 2, url: 'm_rank' },
|
|
|
|
|
+ { text: '分类', value: 3, url: 'm_categroy' },
|
|
|
|
|
+ { text: '订单', value: 5, url: 'm_order' },
|
|
|
|
|
+ { text: this.profile.ecoinName + ':' + this.profile.ecoin, value: 6, url: 'm_ecoin' },
|
|
|
|
|
+ { text: this.profile.ncoinName + ':' + this.profile.ncoin, value: 7, url: 'm_ncoin' },
|
|
|
|
|
+ { text: '我的游戏', value: 4, url: 'm_mine' }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }).catch((error) => {
|
|
|
|
|
+ console.log(error)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ getters: {
|
|
|
|
|
+ getAccount(state) {
|
|
|
|
|
+ return state.UserInfo.account
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-export { userInfo }
|
|
|
|
|
|
|
+export { userInfo }
|