12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- export default{
- //开启命名空间
- namespaced:true,
- //数据
- state:()=>({
- userName:"ST [渔夺]",
- avatarUrl:"../../static/avator/1.jpg",
- address:JSON.parse(uni.getStorageSync('address')||'{}'),
- token:uni.getStorageSync('token')||'',
- //用户的信息对象
- userinfo:JSON.parse(uni.getStorageSync('userinfo')||'{}'),
- //重定向Object对象
- redirectInfo:null,
- level:"Lv1 青铜",
- levelRate:0
- }),
- //方法
- mutations:{
- //更新收货地址
- updateAddress(state,address){
- state.address=address
- this.commit('m_user/saveAddressToStorage')
- },
- updateAvatarUrl(state,avatarUrl){
- state.avatarUrl=avatarUrl
- },
- updateUserName(state,userName){
- state.userName=userName
- },
- //持久化储存address
- saveAddressToStorage(state){
- uni.setStorageSync('address',JSON.stringify(state.address))
- },
- updateUserInfo(state,userinfo){
- state.userinfo=userinfo
- console.log('更新User数据');
- this.commit('m_user/saveUserInfoToStorage')
- },
- saveUserInfoToStorage(state){
- uni.setStorageSync('userinfo',JSON.stringify(state.userinfo))
- console.log('还没错哦');
- },
- updateToken(state,token){
- state.token=token
- this.commit('m_user/saveTokenToStorage')
- },
- saveTokenToStorage(state){
- uni.setStorageSync('token',state.token)
- },
- updateRedirectInfo(state,info){
- state.redirectInfo=info
- console.log(state.redirectInfo);
- },
- addLevelRate(state,num){//待完成
- if(判断升段)//
- {
- commit('m_user/addLevel')
- }
- },
- addLevel(state){//待完成
- }
- },
- getters:{
- //收货地址
- getUserName(state){
- return state.userName
- },
- addstr(state){
- if(!state.address.provinceName) return ''
- return state.address.provinceName+state.address.cityName+state.address.countyName+state.address.detailInfo
- },
- getAvatarUrl(state){
- return state.avatarUrl
- }
- }
- }
|