34 lines
708 B
JavaScript
34 lines
708 B
JavaScript
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
Vue.use(Vuex)
|
|
|
|
const store = new Vuex.Store({
|
|
state: {
|
|
cartInfo: {}, // 购物车数据
|
|
orderAddress: {}, // 下单时选择的地址
|
|
goodsDetails: {}, // 商品详情 1普通 2拼团 3秒杀 4优惠券
|
|
},
|
|
getters: {
|
|
getOrderAddress(state) {
|
|
return state.orderAddress;
|
|
},
|
|
getGoodsType(state) {
|
|
return state.goodsDetails.type;
|
|
},
|
|
getGoodsInfo(state) {
|
|
return state.goodsDetails.goods;
|
|
}
|
|
},
|
|
mutations: {
|
|
updateCart(state, cart) {
|
|
state.cartInfo = cart;
|
|
},
|
|
updateAddress(state, address) {
|
|
state.orderAddress = address;
|
|
},
|
|
setGoodsDetails(state, goods) {
|
|
state.goodsDetails = goods;
|
|
},
|
|
}
|
|
})
|
|
export default store; |