修正项目
This commit is contained in:
		
							
								
								
									
										19
									
								
								xlcs-user/store/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								xlcs-user/store/index.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
import Vuex from 'vuex'
 | 
			
		||||
import indexModule from './modules/index'
 | 
			
		||||
import pickUpLocationModule from './modules/pickUpLocation'
 | 
			
		||||
import categoriesModule from './modules/categories'
 | 
			
		||||
import cartModule from './modules/cart'
 | 
			
		||||
import orderModule from './modules/order'
 | 
			
		||||
 | 
			
		||||
Vue.use(Vuex)
 | 
			
		||||
 | 
			
		||||
export default new Vuex.Store({
 | 
			
		||||
    modules: {
 | 
			
		||||
        indexModule,
 | 
			
		||||
        pickUpLocationModule,
 | 
			
		||||
        categoriesModule,
 | 
			
		||||
        cartModule,
 | 
			
		||||
        orderModule
 | 
			
		||||
    },
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										246
									
								
								xlcs-user/store/modules/cart.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										246
									
								
								xlcs-user/store/modules/cart.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,246 @@
 | 
			
		||||
import Vue from "vue"
 | 
			
		||||
 | 
			
		||||
const state = {
 | 
			
		||||
    cartList: [],
 | 
			
		||||
    activityCartList: {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const getters = {
 | 
			
		||||
    // 检查商品是否存在于购物车中
 | 
			
		||||
    checkProductExists(state) {
 | 
			
		||||
        return function (skuId) {
 | 
			
		||||
            const pos = state.cartList.findIndex(item => item.skuId === skuId)
 | 
			
		||||
            return pos === -1 ? false : true;
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 获取单个商品的购买数量
 | 
			
		||||
    getProductSkuNum(state) {
 | 
			
		||||
        return function (skuId) {
 | 
			
		||||
            const index = state.cartList.findIndex(item => item.skuId === skuId);
 | 
			
		||||
            return index !== -1 ? state.cartList[index].skuNum : 0;
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 获取购物车商品信息列表
 | 
			
		||||
    getCartInfoList(state) {
 | 
			
		||||
        return state.activityCartList.carInfoVoList
 | 
			
		||||
    },
 | 
			
		||||
    // 是否显示包含多个商品的内容
 | 
			
		||||
    showMultiCheckbox(state) {
 | 
			
		||||
        return function (index) {
 | 
			
		||||
            return state.activityCartList.carInfoVoList[index].cartInfoList.length > 1
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 确认多个商品项是否为选中
 | 
			
		||||
    getMultiCheckCart(state) {
 | 
			
		||||
        return function (index) {
 | 
			
		||||
            return state.activityCartList.carInfoVoList[index].cartInfoList.every(item => item.isChecked === 1);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 获取多个商品项的ids
 | 
			
		||||
    getMultiCheckedIds(state) {
 | 
			
		||||
        return function (index) {
 | 
			
		||||
            let ids = []
 | 
			
		||||
            state.activityCartList.carInfoVoList[index].cartInfoList.forEach(item => ids.push(item.skuId));
 | 
			
		||||
            return ids.toString();
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 判断是否全选
 | 
			
		||||
    isAllSelected(state) {
 | 
			
		||||
        let isAllSelected = true;
 | 
			
		||||
        state.activityCartList.carInfoVoList && state.activityCartList.carInfoVoList
 | 
			
		||||
            .forEach(carInfoItem => {
 | 
			
		||||
                carInfoItem.cartInfoList.forEach(cartInfoItem => {
 | 
			
		||||
                    if (cartInfoItem.isChecked === 0) {
 | 
			
		||||
                        isAllSelected = false;
 | 
			
		||||
                        return false;
 | 
			
		||||
                    }
 | 
			
		||||
                })
 | 
			
		||||
            })
 | 
			
		||||
        return isAllSelected;
 | 
			
		||||
    },
 | 
			
		||||
    // 获取购物车价格信息
 | 
			
		||||
    getCartPriceInfo(state) {
 | 
			
		||||
        if (!state.activityCartList.totalAmount) {
 | 
			
		||||
            return {
 | 
			
		||||
                couponReduceAmount: 0,
 | 
			
		||||
                originalTotalAmount: 0,
 | 
			
		||||
                totalAmount: 0
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
            couponReduceAmount: state.activityCartList.couponReduceAmount,
 | 
			
		||||
            originalTotalAmount: state.activityCartList.originalTotalAmount,
 | 
			
		||||
            totalAmount: state.activityCartList.totalAmount
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 确认选中购物车的数量
 | 
			
		||||
    getSelectedCount(state) {
 | 
			
		||||
        let count = 0;
 | 
			
		||||
        state.activityCartList.carInfoVoList && state.activityCartList.carInfoVoList
 | 
			
		||||
            .forEach(carInfoItem => {
 | 
			
		||||
                carInfoItem.cartInfoList.forEach(cartInfoItem => {
 | 
			
		||||
                    if (cartInfoItem.isChecked === 1) {
 | 
			
		||||
                        count += cartInfoItem.skuNum;
 | 
			
		||||
                    }
 | 
			
		||||
                })
 | 
			
		||||
            })
 | 
			
		||||
        return count;
 | 
			
		||||
    },
 | 
			
		||||
    // 获取购物车优惠券信息列表
 | 
			
		||||
    getCartCouponInfoList(state) {
 | 
			
		||||
        return state.activityCartList.couponInfoList
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const mutations = {
 | 
			
		||||
    // 添加到购物车
 | 
			
		||||
    addShopMutation(state, payload) {
 | 
			
		||||
        state.cartList.push(payload);
 | 
			
		||||
    },
 | 
			
		||||
    // 获取不带活动的购物车列表
 | 
			
		||||
    getCartListMutation(state, payload) {
 | 
			
		||||
        state.cartList = payload;
 | 
			
		||||
    },
 | 
			
		||||
    // 修改购物车数量
 | 
			
		||||
    changeSkuNumMutation(state, payload) {
 | 
			
		||||
        // skuId为商品id
 | 
			
		||||
        // value为+1或者-1,操作的递增值
 | 
			
		||||
        // currentBuyNum为number-box组件当前商品购物车的操作值
 | 
			
		||||
        const {
 | 
			
		||||
            skuId,
 | 
			
		||||
            value,
 | 
			
		||||
            currentBuyNum
 | 
			
		||||
        } = payload
 | 
			
		||||
        const index = state.cartList.findIndex(item => item.skuId === skuId);
 | 
			
		||||
        // 如果当前购买数量小于1则删除该商品
 | 
			
		||||
        if (currentBuyNum < 1) {
 | 
			
		||||
            state.cartList.splice(index, 1)
 | 
			
		||||
        } else {
 | 
			
		||||
            state.cartList[index].skuNum += value
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 删除购物车
 | 
			
		||||
    deleteShopMutation(state, payload) {
 | 
			
		||||
        // 删除cartList中的数据
 | 
			
		||||
        const cartListIndex = state.cartList.findIndex(item => item.skuId === payload);
 | 
			
		||||
        state.cartList.splice(cartListIndex, 1)
 | 
			
		||||
    },
 | 
			
		||||
    // 获取带活动的购物车列表
 | 
			
		||||
    getActivityCartListMutation(state, payload) {
 | 
			
		||||
        state.activityCartList = payload
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
const actions = {
 | 
			
		||||
    // 添加到购物车
 | 
			
		||||
    async addShopAction({
 | 
			
		||||
                            commit,
 | 
			
		||||
                            state
 | 
			
		||||
                        }, payload) {
 | 
			
		||||
        // 给对象添加响应式数据属性
 | 
			
		||||
        Vue.set(payload, 'skuNum', 1)
 | 
			
		||||
        Vue.set(payload, 'skuId', payload.id)
 | 
			
		||||
        Vue.set(payload, 'isChecked', 1)
 | 
			
		||||
        await this._vm.$u.api.getAddToCart({
 | 
			
		||||
            skuId: payload.id,
 | 
			
		||||
            skuNum: payload.skuNum,
 | 
			
		||||
        })
 | 
			
		||||
        commit('addShopMutation', payload)
 | 
			
		||||
    },
 | 
			
		||||
    // 获取不带活动的购物车列表
 | 
			
		||||
    async getCartListAction({
 | 
			
		||||
                                commit
 | 
			
		||||
                            }) {
 | 
			
		||||
        let result = await this._vm.$u.api.getCartList()
 | 
			
		||||
        commit('getCartListMutation', result)
 | 
			
		||||
    },
 | 
			
		||||
    // 修改购物车数量
 | 
			
		||||
    async changeSkuNumAction({
 | 
			
		||||
                                 commit,
 | 
			
		||||
                                 dispatch
 | 
			
		||||
                             }, payload) {
 | 
			
		||||
        const {
 | 
			
		||||
            skuId,
 | 
			
		||||
            value,
 | 
			
		||||
            currentBuyNum,
 | 
			
		||||
            isCart
 | 
			
		||||
        } = payload;
 | 
			
		||||
        // 如果当前购买的数量小于1,则需要将该商品从购物车中删除,否则进行购物车数量的修改
 | 
			
		||||
        if (currentBuyNum < 1) {
 | 
			
		||||
            dispatch('deleteShopAction', payload)
 | 
			
		||||
        } else {
 | 
			
		||||
            await this._vm.$u.api.getAddToCart({
 | 
			
		||||
                skuId: skuId,
 | 
			
		||||
                skuNum: value,
 | 
			
		||||
            })
 | 
			
		||||
            commit('changeSkuNumMutation', payload)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 通过isCart判断是否是在购物车里进行购物车数量的改变,
 | 
			
		||||
        // 如果是在购物车里进行数量变化,则还需要获取带活动的购物车列表
 | 
			
		||||
        if (isCart) dispatch('getActivityCartListAction')
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    // 删除购物车
 | 
			
		||||
    async deleteShopAction({
 | 
			
		||||
                               commit,
 | 
			
		||||
                               dispatch
 | 
			
		||||
                           }, payload) {
 | 
			
		||||
        const {
 | 
			
		||||
            skuId,
 | 
			
		||||
            value,
 | 
			
		||||
            currentBuyNum,
 | 
			
		||||
            isCart
 | 
			
		||||
        } = payload;
 | 
			
		||||
        await this._vm.$u.api.deleteCart(skuId);
 | 
			
		||||
 | 
			
		||||
        // 删除时如果是在购物车列表操作,则需要重新获取数据
 | 
			
		||||
        if (isCart) await dispatch('getActivityCartListAction')
 | 
			
		||||
        await commit('deleteShopMutation', skuId)
 | 
			
		||||
    },
 | 
			
		||||
    // 获取带活动的购物车列表
 | 
			
		||||
    async getActivityCartListAction({
 | 
			
		||||
                                        commit
 | 
			
		||||
                                    }, payload) {
 | 
			
		||||
        let showLoading = false;
 | 
			
		||||
        if (payload) showLoading = true
 | 
			
		||||
 | 
			
		||||
        let result = await this._vm.$u.api.getActivityCartList({
 | 
			
		||||
            showLoading
 | 
			
		||||
        })
 | 
			
		||||
        commit('getActivityCartListMutation', result)
 | 
			
		||||
    },
 | 
			
		||||
    // 切换购物车商品的选中状态
 | 
			
		||||
    async changeCheckCartAction({
 | 
			
		||||
                                    commit,
 | 
			
		||||
                                    dispatch
 | 
			
		||||
                                }, payload) {
 | 
			
		||||
        let result = await this._vm.$u.api.getCheckCart(payload)
 | 
			
		||||
        dispatch('getActivityCartListAction')
 | 
			
		||||
    },
 | 
			
		||||
    // 对指定的多个商品进行选择/反选
 | 
			
		||||
    async changeMultiCheckedCartAction({
 | 
			
		||||
                                           commit,
 | 
			
		||||
                                           dispatch
 | 
			
		||||
                                       }, payload) {
 | 
			
		||||
        let result = await this._vm.$u.api.postBatchCheckCart(payload)
 | 
			
		||||
        dispatch('getActivityCartListAction')
 | 
			
		||||
    },
 | 
			
		||||
    // 对所有购物车商品进行全选/反选
 | 
			
		||||
    async changeAllCheckCartAction({
 | 
			
		||||
                                       commit,
 | 
			
		||||
                                       dispatch
 | 
			
		||||
                                   }, payload) {
 | 
			
		||||
        let result = await this._vm.$u.api.getCheckAllCart(payload)
 | 
			
		||||
        dispatch('getActivityCartListAction')
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    namespaced: true,
 | 
			
		||||
    state,
 | 
			
		||||
    mutations,
 | 
			
		||||
    actions,
 | 
			
		||||
    getters,
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										27
									
								
								xlcs-user/store/modules/categories.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								xlcs-user/store/modules/categories.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
const state = {
 | 
			
		||||
    categories: []
 | 
			
		||||
};
 | 
			
		||||
const getters = {};
 | 
			
		||||
const mutations = {
 | 
			
		||||
    updateCategoriesMutation(state, payload) {
 | 
			
		||||
        state.categories = payload;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
const actions = {
 | 
			
		||||
    async getCategoriesAction({
 | 
			
		||||
                                  commit
 | 
			
		||||
                              }) {
 | 
			
		||||
        return new Promise(async reslove => {
 | 
			
		||||
            let result = await this._vm.$u.api.getCategories()
 | 
			
		||||
            commit('updateCategoriesMutation', result)
 | 
			
		||||
            reslove();
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
export default {
 | 
			
		||||
    namespaced: true,
 | 
			
		||||
    state,
 | 
			
		||||
    mutations,
 | 
			
		||||
    actions,
 | 
			
		||||
    getters,
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										59
									
								
								xlcs-user/store/modules/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								xlcs-user/store/modules/index.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
const state = {
 | 
			
		||||
    home: {}
 | 
			
		||||
};
 | 
			
		||||
const getters = {
 | 
			
		||||
    // 商品分类
 | 
			
		||||
    categoryList(state) {
 | 
			
		||||
        return state.home.categoryList || [];
 | 
			
		||||
    },
 | 
			
		||||
    // 热销商品
 | 
			
		||||
    hotSkuList(state) {
 | 
			
		||||
        return state.home.hotSkuList || [];
 | 
			
		||||
    },
 | 
			
		||||
    // 新人专享
 | 
			
		||||
    newPersonSkuInfoList(state) {
 | 
			
		||||
        return state.home.newPersonSkuInfoList || [];
 | 
			
		||||
    },
 | 
			
		||||
    // 提货点信息
 | 
			
		||||
    leaderAddressVo(state) {
 | 
			
		||||
        return state.home.leaderAddressVo || {}
 | 
			
		||||
    },
 | 
			
		||||
    // 秒杀时间
 | 
			
		||||
    seckillTime(state) {
 | 
			
		||||
        return state.home.seckillTime || {}
 | 
			
		||||
    },
 | 
			
		||||
    // 秒杀商品
 | 
			
		||||
    seckillSkuVoList(state) {
 | 
			
		||||
        return state.home.seckillSkuVoList || []
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
const mutations = {
 | 
			
		||||
    // 获取首页数据
 | 
			
		||||
    getHomeIndexMutation(state, payload) {
 | 
			
		||||
        state.home = payload
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
const actions = {
 | 
			
		||||
    async getHomeIndexAction({
 | 
			
		||||
                                 commit,
 | 
			
		||||
                                 dispatch
 | 
			
		||||
                             }) {
 | 
			
		||||
        // 直接用this.$u.api在仓库中是无法调用到对应的接口的,因为this对象指向不同
 | 
			
		||||
        // 仓库中的this指向的是Store,所以需要通过this._vm来找到对应的Vue实例
 | 
			
		||||
        let result = await this._vm.$u.api.getHomeIndex()
 | 
			
		||||
        await commit('getHomeIndexMutation', result)
 | 
			
		||||
        // 利用root属性将派发pickUpLocation模块中的action动作
 | 
			
		||||
        dispatch('pickUpLocationModule/changeLeaderAddressVoAction', result.leaderAddressVo, {
 | 
			
		||||
            root: true
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        dispatch('cartModule/getCartListAction', {}, {root: true})
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
export default {
 | 
			
		||||
    namespaced: true,
 | 
			
		||||
    state,
 | 
			
		||||
    mutations,
 | 
			
		||||
    actions,
 | 
			
		||||
    getters,
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										90
									
								
								xlcs-user/store/modules/order.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								xlcs-user/store/modules/order.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,90 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
 | 
			
		||||
const state = {
 | 
			
		||||
    order: {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const getters = {
 | 
			
		||||
    // 获取订单商品信息列表
 | 
			
		||||
    getCartInfoList(state) {
 | 
			
		||||
        return state.order.carInfoVoList
 | 
			
		||||
    },
 | 
			
		||||
    // 获取提货点信息
 | 
			
		||||
    getLeaderAddressVo(state) {
 | 
			
		||||
        return state.order.leaderAddressVo
 | 
			
		||||
    },
 | 
			
		||||
    // 确认选中购物车的数量
 | 
			
		||||
    getSelectedCount(state) {
 | 
			
		||||
        let count = 0;
 | 
			
		||||
        state.order.carInfoVoList && state.order.carInfoVoList
 | 
			
		||||
            .forEach(carInfoItem => {
 | 
			
		||||
                carInfoItem.cartInfoList.forEach(cartInfoItem => {
 | 
			
		||||
                    if (cartInfoItem.isChecked === 1) {
 | 
			
		||||
                        count += cartInfoItem.skuNum;
 | 
			
		||||
                    }
 | 
			
		||||
                })
 | 
			
		||||
            })
 | 
			
		||||
        return count;
 | 
			
		||||
    },
 | 
			
		||||
    // 获取购物车价格信息
 | 
			
		||||
    getCartPriceInfo(state) {
 | 
			
		||||
        if (!state.order.totalAmount) {
 | 
			
		||||
            return {
 | 
			
		||||
                couponReduceAmount: 0,
 | 
			
		||||
                originalTotalAmount: 0,
 | 
			
		||||
                totalAmount: 0,
 | 
			
		||||
                activityReduceAmount: 0
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
            couponReduceAmount: state.order.couponReduceAmount,
 | 
			
		||||
            originalTotalAmount: state.order.originalTotalAmount,
 | 
			
		||||
            totalAmount: state.order.totalAmount,
 | 
			
		||||
            activityReduceAmount: state.order.activityReduceAmount
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 是否显示包含多个商品的内容
 | 
			
		||||
    showMultiCheckbox(state) {
 | 
			
		||||
        return function (index) {
 | 
			
		||||
            return state.order.carInfoVoList[index].cartInfoList.length > 1
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    // 获取订单优惠券信息列表
 | 
			
		||||
    getCartCouponInfoList(state) {
 | 
			
		||||
        const couponInfoList = state.order.couponInfoList || []
 | 
			
		||||
        if (couponInfoList) {
 | 
			
		||||
            couponInfoList.forEach((
 | 
			
		||||
                item) => {
 | 
			
		||||
                Vue.set(item, 'selected', item.isOptimal === 1 && item.isSelect === 1)
 | 
			
		||||
 | 
			
		||||
            })
 | 
			
		||||
        }
 | 
			
		||||
        return couponInfoList
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const mutations = {
 | 
			
		||||
    // 获取确认订单
 | 
			
		||||
    getConfirmOrderMutation(state, payload) {
 | 
			
		||||
        state.order = payload
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const actions = {
 | 
			
		||||
    // 获取确认订单
 | 
			
		||||
    async getConfirmOrderAction({
 | 
			
		||||
                                    commit
 | 
			
		||||
                                }) {
 | 
			
		||||
        let result = await this._vm.$u.api.getConfirmOrder()
 | 
			
		||||
        commit('getConfirmOrderMutation', result)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    namespaced: true,
 | 
			
		||||
    state,
 | 
			
		||||
    mutations,
 | 
			
		||||
    actions,
 | 
			
		||||
    getters,
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										63
									
								
								xlcs-user/store/modules/pickUpLocation.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								xlcs-user/store/modules/pickUpLocation.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
const state = {
 | 
			
		||||
    leaderAddressVo: {}, // 当前提货点
 | 
			
		||||
    currentPickUpArea: '', // 当前提货点区域
 | 
			
		||||
    findAllList: [], // 指定区域的提货点列表
 | 
			
		||||
};
 | 
			
		||||
const getters = {
 | 
			
		||||
    checkIsCurrent(state, payload) {
 | 
			
		||||
        return function (id) {
 | 
			
		||||
            if (state.leaderAddressVo) {
 | 
			
		||||
                return state.leaderAddressVo.leaderId === id;
 | 
			
		||||
            } else {
 | 
			
		||||
                return false
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
const mutations = {
 | 
			
		||||
    getSysRegionFindAllListMutation(state, payload) {
 | 
			
		||||
        state.findAllList = payload
 | 
			
		||||
    },
 | 
			
		||||
    setCurrentPickUpAreaMutation(state, payload) {
 | 
			
		||||
        state.currentPickUpArea = payload.regionName
 | 
			
		||||
    },
 | 
			
		||||
    changeCurrentPickUpAreaMutation(state, payload) {
 | 
			
		||||
        state.currentPickUpArea = payload[0].regionName
 | 
			
		||||
    },
 | 
			
		||||
    changeLeaderAddressVoMutation(state, payload) {
 | 
			
		||||
        state.leaderAddressVo = payload;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
const actions = {
 | 
			
		||||
    async getSysRegionFindAllListAction({
 | 
			
		||||
                                            commit
 | 
			
		||||
                                        }) {
 | 
			
		||||
        let result = await this._vm.$u.api.getSysRegionFindAllList();
 | 
			
		||||
        await commit('getSysRegionFindAllListMutation', result)
 | 
			
		||||
        await commit('changeCurrentPickUpAreaMutation', result)
 | 
			
		||||
    },
 | 
			
		||||
    changeLeaderAddressVoAction({
 | 
			
		||||
                                    commit,
 | 
			
		||||
                                    dispatch
 | 
			
		||||
                                }, payload) {
 | 
			
		||||
        commit('changeLeaderAddressVoMutation', payload)
 | 
			
		||||
    },
 | 
			
		||||
    async selectLeaderAddressVoAction({
 | 
			
		||||
                                          commit,
 | 
			
		||||
                                          dispatch
 | 
			
		||||
                                      }, payload) {
 | 
			
		||||
        let result = await this._vm.$u.api.getSelectLeader(payload);
 | 
			
		||||
        // 从首页设置当前提货点
 | 
			
		||||
        dispatch('indexModule/getHomeIndexAction', {}, {
 | 
			
		||||
            root: true
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    namespaced: true,
 | 
			
		||||
    state,
 | 
			
		||||
    mutations,
 | 
			
		||||
    actions,
 | 
			
		||||
    getters,
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user