迭代功能需求

1.修改用户信息存储位置
2.修复订单显示的问题
3.修改优惠卷显示文字显示和选择提示
4.修复地址列表排版错位的问题
5.添加搜索链接跳转查询
This commit is contained in:
lin
2022-03-23 18:04:14 +08:00
parent 6f8a8c628d
commit 9f955a34eb
29 changed files with 5615 additions and 5612 deletions

View File

@@ -1,17 +1,57 @@
// import { getCookie } from "../../plugins/until/until.js";
export default {
state : {
des : '这个存储用户登录逻辑操作',
loginState : false, //登录状态
state: {
des: '这个存储用户登录逻辑操作',
loginState: false, //登录状态
},
/* 存储修改状态的静态方法 */
mutations : {
mutations: {
/* 设置登录状态 */
SET_LOGIN_STATE(state){
console.log(state);
}
SET_LOGIN_STATE(state, value) {
state.loginState = value
},
},
/* 存储修改数据的动态方法 */
actions : {
actions: {
/**
* 判断是否登录
* context
* app vue 实例
*/
checkLoginState(context, app) {
let key = context.rootState.userKey;
let mobile = app.$cookies.get(key);
let isHasToken = false;
if (mobile == undefined || !mobile || mobile == 'mobile') {
isHasToken = false;
} else {
isHasToken = true;
/* 更新用户数据 */
if (!context.rootState.user.userInfo) {
context.dispatch('getUserInfo', app, {
root: true
});
}
}
context.commit('SET_LOGIN_STATE', isHasToken);
},
/**
* 退出登录
* @param {Object} context 上下文
* @param {Object} app vue 实例
*/
logout(context, app){
let userKey = context.rootState.userKey;
let tokenKey = context.rootState.tokenKey;
app.$cookies.remove(userKey);
app.$cookies.remove(tokenKey);
context.commit('SET_USER_INFO', null, {
root: true
});
context.commit('SET_INDEX_USER_INFO', null, {
root: true
});
localStorage.removeItem(tokenKey)
}
}
}
}

View File

@@ -1,18 +1,61 @@
import Vue from "vue";
import { userregOrLogin } from '../../ajax/getData.js';
export default {
state : {
des : '这个存储用户数据的模块列表',
userInfo : {}, //用户信息
loginState : false, //登录状态
state: {
des: '这个存储用户数据的模块列表',
userInfo: null, //用户信息
loginState: false, //登录状态
},
/* 存储修改状态的静态方法 */
mutations : {
mutations: {
/* 设置用户信息 */
SET_USER_INFO(state){
console.log(state);
SET_USER_INFO(state, userInfo) {
state.userInfo = userInfo;
}
},
/* 存储修改数据的动态方法 */
actions : {
actions: {
/**
* 设置会员信息
* @param {Object} context 上下文
* @param {Object} {
data : 后台返回的用户数据
app : vue实例this
}
*/
setUserInfo(context, {
data,
app
}) {
const userKey = context.rootState.userKey;
const tokenKey = context.rootState.tokenKey;
const userInfo = data.data;
const {
mobile
} = userInfo;
/* 存储数据 变更登录状态 */
app.$cookies.set(userKey, mobile);
app.$cookies.set(tokenKey, data.xaccessToken);
localStorage.setItem(tokenKey,data.xaccessToken);
context.commit('SET_USER_INFO', userInfo);
context.commit('SET_LOGIN_STATE', true, {
root: true
});
context.commit('SET_INDEX_USER_INFO', data, {
root: true
});
},
/* 获取用户数据 */
async getUserInfo(context,app){
let key = context.rootState.userKey;
let mobile = app.$cookies.get(key);
const data = await userregOrLogin(app.$cookies.get(key));
context.dispatch('setUserInfo',{
data,
app,
})
}
}
}
}