租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
825 B

import { getInfo } from "@/common/api.js"
export default {
state: {
token:"",
userInfo : {}, //用户信息
},
mutations: {
onAuth(state){
},
setUserInfo(state,obj){
state.userInfo = obj.userInfo
state.token = obj.token
},
getUserInfo(state){
if(!uni.getStorageSync('token')){
return
}
getInfo({}).then(result=>{
if(result.result.nickName){
state.userInfo = result.result
}else{
uni.navigateTo({
url:"/pages/login/index"
})
}
})
},
logout(state){
uni.showModal({
title: '确认退出登录吗',
success(r) {
if(r.confirm){
state.userInfo = {}
state.token = ""
uni.removeStorageSync('token')
uni.redirectTo({
url: '/pages/index/index'
})
}
}
})
},
},
actions: {}
}