2025-10-29 15:50:14 +08:00

88 lines
2.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* WanlShop状态管理器 - 用户管理
*
* @ author 深圳前海万联科技有限公司 <wanlshop@i36k.com>
* < 程序仅用作FastAdmin付费插件API测试使用非FastAdmin购买授权未经版权所有权人书面许可不能用于商业用途>
* @ link http://www.wanlshop.com
* @ 2020年9月29日19:00:46
* @ version 1.0.0
**/
export default {
namespaced: true,
state: {
id: 0, //用户ID
isLogin: false, // 登录状态
username: '', // 用户名
nickname: '', // 昵称
mobile: '', // 手机号
avatar: '', // 默认头像
level: 0, // 等级
gender: 0, // 性别
birthday: '', // 生日
bio: '', // 签名
money: '0.00', // 余额
score: 0, // 积分
successions: '', // 连续登录天数
maxsuccessions: '', // 最大连续登录天数
prevtime: '', // 上次登录时间
logintime: '', // 登录时间
loginip: '', // 加入IP
jointime: '', // 加入时间
token: '', // 令牌
pushs: true, // 推送
shock: true, // 震动
voice: true, // 提示音
redpocket:0,//红包
vip: 0,
vipout_time: 0,
},
mutations: {
setUserInfo(state, payload) {
for (let i in payload) {
for (let j in state) {
if (i === j) {
state[j] = payload[i];
}
}
}
uni.setStorageSync("wanlshop:user", state);
}
},
actions: {
async login({state, commit, dispatch, rootState}, data) {
commit('setUserInfo', data.userinfo);
state.isLogin = true; // 登录状态强制 开启
// 根据notice.vue 而知fastadmin没有此三项默认字段手动添加想同步修改该这两处即可
state.pushs = true; // 推送
state.voice = true; // 提示音
state.shock = true; // 震动
uni.setStorageSync("wanlshop:user", state);
if(uni.getStorageSync('shareId')){
// 调用绑定人接口
uni.request({
url: '/user/bindSquireid',
method: 'POST',
data:{
squire_id:uni.getStorageSync('shareId')
},
success: res => {}
});
}else{
uni.setStorageSync('shareId',data.userinfo.id)
}
// 统计信息
dispatch('statistics', data.statistics)
},
async statistics({state, dispatch, rootState}, payload){
let states = rootState.statistics;
for (let i in payload) {
for (let j in states) {
if (i === j) {
states[j] = payload[i];
}
}
}
uni.setStorageSync("wanlshop:statis", states);
}
}
};