2020-07-15 09:38:41 +00:00
|
|
|
|
import Vue from 'vue'
|
|
|
|
|
import Vuex from 'vuex'
|
2020-07-29 07:04:57 +00:00
|
|
|
|
import {
|
|
|
|
|
mapMutations
|
|
|
|
|
} from 'vuex';
|
|
|
|
|
|
2020-07-15 09:38:41 +00:00
|
|
|
|
Vue.use(Vuex)
|
|
|
|
|
|
|
|
|
|
const store = new Vuex.Store({
|
|
|
|
|
state: {
|
2020-07-22 10:51:48 +00:00
|
|
|
|
orderType: '', // 订单类型 1 普通订单 2 拼团订单 3 秒杀订单 4 优惠券 5 购物车订单 和 goodsDetails 的 type 相同
|
2020-07-21 13:02:28 +00:00
|
|
|
|
orderInfo: {}, // 订单数据 订单步骤1:展示结算数据
|
2020-07-16 09:39:06 +00:00
|
|
|
|
orderAddress: {}, // 下单时选择的地址
|
2020-07-20 09:17:41 +00:00
|
|
|
|
goodsDetails: {}, // 商品详情 1普通 2拼团 3秒杀 4优惠券
|
2020-07-21 13:02:28 +00:00
|
|
|
|
goods_id: '', // 拼团商品 id
|
2020-07-22 10:51:48 +00:00
|
|
|
|
pintuangroup_headid: '', // 拼团团长id 有为开团 无为参团
|
2020-07-21 13:02:28 +00:00
|
|
|
|
groupbuyInfo: {}, // 秒杀详情
|
2020-07-23 12:58:56 +00:00
|
|
|
|
loadmore: {}, // 下拉加载返回的数据
|
2020-07-29 07:04:57 +00:00
|
|
|
|
hasLogin: false, // 登录状态
|
2020-08-06 12:42:03 +00:00
|
|
|
|
token: "", // 储存token
|
|
|
|
|
showLoginModel: false, // 登录框
|
2020-07-15 08:21:43 +00:00
|
|
|
|
},
|
|
|
|
|
getters: {
|
2020-07-16 09:39:06 +00:00
|
|
|
|
getOrderAddress(state) {
|
2020-07-30 12:33:16 +00:00
|
|
|
|
return state.orderAddress || {};
|
2020-07-20 09:17:41 +00:00
|
|
|
|
},
|
|
|
|
|
getGoodsType(state) {
|
|
|
|
|
return state.goodsDetails.type;
|
|
|
|
|
},
|
|
|
|
|
getGoodsInfo(state) {
|
|
|
|
|
return state.goodsDetails.goods;
|
2020-07-15 08:21:43 +00:00
|
|
|
|
}
|
2020-07-15 09:38:41 +00:00
|
|
|
|
},
|
2020-07-15 08:21:43 +00:00
|
|
|
|
mutations: {
|
2020-07-29 07:04:57 +00:00
|
|
|
|
// 登录
|
|
|
|
|
loginIn(state, token) {
|
|
|
|
|
state.hasLogin = true;
|
|
|
|
|
state.token = token;
|
|
|
|
|
uni.setStorage({
|
|
|
|
|
key: "token",
|
|
|
|
|
data: token
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 退出登录
|
|
|
|
|
logout(state) {
|
|
|
|
|
state.hasLogin = false;
|
|
|
|
|
state.token = "";
|
|
|
|
|
uni.removeStorage({
|
|
|
|
|
key: "token"
|
|
|
|
|
})
|
2020-08-03 06:26:52 +00:00
|
|
|
|
uni.removeStorage({
|
|
|
|
|
key: "user_info"
|
|
|
|
|
})
|
2020-07-29 07:04:57 +00:00
|
|
|
|
},
|
2020-07-21 13:02:28 +00:00
|
|
|
|
setOrderType(state, type) {
|
|
|
|
|
state.orderType = type;
|
|
|
|
|
},
|
|
|
|
|
updateOrderInfo(state, info) {
|
|
|
|
|
state.orderInfo = info;
|
2020-07-16 09:39:06 +00:00
|
|
|
|
},
|
|
|
|
|
updateAddress(state, address) {
|
|
|
|
|
state.orderAddress = address;
|
2020-07-20 09:17:41 +00:00
|
|
|
|
},
|
|
|
|
|
setGoodsDetails(state, goods) {
|
|
|
|
|
state.goodsDetails = goods;
|
|
|
|
|
},
|
2020-07-21 13:02:28 +00:00
|
|
|
|
setGoodsId(state, id) {
|
|
|
|
|
state.goods_id = id;
|
|
|
|
|
},
|
|
|
|
|
setGroupbuyInfo(state, info) {
|
|
|
|
|
state.groupbuyInfo = info;
|
|
|
|
|
},
|
2020-07-22 10:51:48 +00:00
|
|
|
|
setGroupHeadId(state, id) {
|
|
|
|
|
state.pintuangroup_headid = id;
|
|
|
|
|
},
|
2020-07-23 12:58:56 +00:00
|
|
|
|
setLoadMore(state, info) {
|
|
|
|
|
state.loadmore = info;
|
2020-07-29 07:04:57 +00:00
|
|
|
|
}
|
2020-07-15 08:21:43 +00:00
|
|
|
|
}
|
2020-07-15 09:38:41 +00:00
|
|
|
|
})
|
2020-07-29 07:04:57 +00:00
|
|
|
|
export default store;
|