2020-07-15 09:38:41 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
Vue.use(Vuex)
|
|
|
|
|
|
|
|
const store = new Vuex.Store({
|
|
|
|
state: {
|
2020-07-16 09:39:06 +00:00
|
|
|
cartInfo: {}, // 购物车数据
|
|
|
|
orderAddress: {}, // 下单时选择的地址
|
2020-07-20 09:17:41 +00:00
|
|
|
goodsDetails: {}, // 商品详情 1普通 2拼团 3秒杀 4优惠券
|
2020-07-15 08:21:43 +00:00
|
|
|
},
|
|
|
|
getters: {
|
2020-07-16 09:39:06 +00:00
|
|
|
getOrderAddress(state) {
|
|
|
|
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-16 09:39:06 +00:00
|
|
|
updateCart(state, cart) {
|
|
|
|
state.cartInfo = cart;
|
|
|
|
},
|
|
|
|
updateAddress(state, address) {
|
|
|
|
state.orderAddress = address;
|
2020-07-20 09:17:41 +00:00
|
|
|
},
|
|
|
|
setGoodsDetails(state, goods) {
|
|
|
|
state.goodsDetails = goods;
|
|
|
|
},
|
2020-07-15 08:21:43 +00:00
|
|
|
}
|
2020-07-15 09:38:41 +00:00
|
|
|
})
|
|
|
|
export default store;
|