真食物配套的电商小程序.
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.

132 lines
2.9 KiB

import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
const debug = process.env.NODE_ENV !== "production";
import cookie from "@/utils/store/cookie";
5 years ago
import {
getUserInfo
} from "@/api/user";
import dialog from "@/utils/dialog";
const LOGIN_KEY = "login_status";
const vuexStore = new Vuex.Store({
5 years ago
state: {
// 是否已经在授权页面
isAuthorizationPage: false,
// 是否授权
isAuthorization: false,
// 不建议从这里取 token,但是删除掉会影响其他的页面
token: cookie.get(LOGIN_KEY) || null,
userInfo: cookie.get('userInfo'),
5 years ago
$deviceType: null,
},
mutations: {
SHOW_FOOTER(state) {
state.footer = true;
},
HIDE_FOOTER(state) {
state.footer = false;
},
SHOW_HOME(state) {
state.home = true;
},
HIDE_HOME(state) {
state.home = false;
},
OPEN_HOME(state) {
state.homeActive = true;
},
CLOSE_HOME(state) {
state.homeActive = false;
},
CHANGE_TABTAR(state, index) {
state.tabtarIndex = index;
},
LOGIN(state, token, expires_time) {
state.token = token;
cookie.set(LOGIN_KEY, token, expires_time);
5 years ago
},
LOGOUT(state) {
state.token = null;
state.userInfo = null
cookie.clearAll()
5 years ago
},
BACKGROUND_COLOR(state, color) {
state.color = color;
// document.body.style.backgroundColor = color;
},
- (2020/04/12) [+] 小程序首页 热门榜单 首发新品 标题有遮挡 - (2020/04/12) [+] 首页榜单进去提示登陆,页面空白:,还有这种总数操作也会就跳转到授权页面,应该是又问题的这快 - (2020/04/12) [+] 全部商品,右边有错误截图如下 - (2020/04/12) [+] 秒杀列表数据不显示;公众号15点的就有数据,但是小程序没有 - (2020/04/12) [+] 7、砍价可以改下,看下最新H5代码,首次进来不自动砍价,自己点击才砍价一次,而且里面详情是乱的 - (2020/04/12) [+] 为啥我也没退出,就取截个图,再进来,点击商品详情,又让登陆,登陆失效怎么这么快,mpvue小程序就没这个问题,这个问题非常严重,一会让让跳转到授权页面登陆!! - (2020/04/12) [+] 1、商品购买选择规格,这个开始进去点可以,点到后面花色的规格点不动了 - (2020/04/12) [+] 2、拼团客服隐藏掉,下面按钮太那个了,把商品详情那个收藏功能放进来,他们收藏功能都是一样的 - (2020/04/12) [+] 商品详情海报一直海报生成中 - (2020/04/12) [+] 砍价弹窗修改 - (2020/04/11) [+] 1、购买选择规格属性点不了 - (2020/04/11) [+] 12、拼团详情客服功能隐藏去掉,其他地方有客服功能的都去掉 - (2020/04/11) [+] 11、分类点击 会分类Tab页分类一级比一级低 - (2020/04/11) [+] 10、我的推广,里面样式有问题,点击海报里面空白 - (2020/04/11) [+] 9、小程序订单核销没上 你那边先根据路径判断隐藏下 - (2020/04/11) [+] 8、订单点击评价没反应 - (2020/04/11) [+] 6、个人中心我的余额点进去点击账单记录一直正在加载中,点击下全部就出来了,应该你没带默认参数 - (2020/04/11) [+] 5、添加地址选择地区无效 - (2020/04/11) [+] 4、待收货 列表查看物流点击没反应,详情查看物流可以点 - (2020/04/11) [+] 3、下单点击积分抵扣没反应 - (2020/04/11) [+] 2、购物车列表点击管理 点击收藏功能去掉
5 years ago
UPDATE_USERINFO(state, userInfo) {
5 years ago
state.userInfo = userInfo;
},
UPDATE_AUTHORIZATIONPAGE(state, isAuthorizationPage) {
state.isAuthorizationPage = isAuthorizationPage;
},
UPDATE_AUTHORIZATION(state, isAuthorization) {
state.isAuthorization = isAuthorization;
},
UPDATE_DEVICETYPE(state, $deviceType) {
state.$deviceType = $deviceType;
},
},
actions: {
USERINFO({
state,
commit
}, force) {
if (state.userInfo !== null && !force)
return Promise.resolve(state.userInfo);
else
return new Promise(reslove => {
getUserInfo().then(res => {
commit("UPDATE_USERINFO", res.data);
reslove(res.data);
});
}).catch(() => {
dialog.error("获取信息失败!");
});
},
changeLogin({
state,
commit
}, data, date) {
commit("LOGIN", data, date);
},
setUserInfo({
state,
commit
}, user) {
commit("UPDATE_USERINFO", user);
if (user) {
cookie.set('userInfo', user)
5 years ago
} else {
cookie.set('userInfo', null)
5 years ago
}
},
changeAuthorizationPage({
state,
commit
}, index) {
commit("UPDATE_AUTHORIZATIONPAGE", index);
},
changeAuthorization({
state,
commit
}, index) {
commit("UPDATE_AUTHORIZATION", index);
},
},
getters: {
isAuthorizationPage: state => state.isAuthorizationPage,
isAuthorization: state => state.isAuthorization,
token: state => state.token,
isLogin: state => !!state.token,
userInfo: state => state.userInfo || {},
},
strict: debug
});
export default vuexStore