import { store as allStore } from "@/store";
export default {
    /**
     * 是否需要重新加载
     */
    indexNeedReload: (state, boo) => {
        state.indexNeedReload = boo
    },

    /**
     * 重定位信息
     */
    saveReLocation: (state, json) => {
        state.reLocation = json
    },

    /**
     * 定位信息
     */
    setMylocation: (state, json) => {
        state.myLocation = json
    },

    /**
     * 当前的附近位置
     */
    setPois: (state, arr) => {
        state.pois = arr
    },

    /**
     * 改变当前城市
     */
    changeCity: (state, str) => {
        state.cityChange = str
    },

    /**
     * 附近门店的数据信息
     */
    saveStoreMap: (state, json) => {
        state.storeMap = json
    },

    /**
     * 改变当前门店
     */
    changeStoreID: (state, storeID) => {
        // 设置重新加载标识
        if(storeID[0] !== state.storeID[0]){
            // allStore.commit('indexPage/indexNeedReload', true)   // 首页
            allStore.commit('goodPage/changeIsNeedReload', true) // 分类
            allStore.commit('cartPage/cartNeedReload', true)    // 购物车
            state.storeID = storeID
        }else{
            allStore.commit('goodPage/changeIsNeedReload', false) // 分类
            allStore.commit('cartPage/cartNeedReload', false)    // 购物车
        }
    },

    /**
     * 保存门店信息
     */
    saveStoreInfo: (state, json) => {
        state.storeInfo = json
    },

    /**
     * 保存门店的减运信息
     */
    saveWaybillSLG: (state, json) => {
        state.waybillSLG = json
    },

    /**
     * 保存轮播图信息
     */
    saveBannerList: (state, arr) => {
        state.bannerList = arr
    },

    /**
     * 保存物料购买信息
     */
    saveMaterialInfo: (state, json) => {
        uni.setStorageSync('materialInfo', json)
        uni.removeStorageSync('queryStoreID')
        uni.removeStorageSync('storeType')
        uni.removeStorageSync('brandID')
        state.queryStoreID = null
        state.isGy = false
        state.brandID = -1
        state.materialInfo = json
    },

    /**
     * 保存品牌brandID
     */
    saveBrandID: (state, json) => {
        uni.setStorageSync('brandID', json)
        // uni.removeStorageSync('materialInfo')
        // uni.removeStorageSync('queryStoreID')
        // state.queryStoreID = null
        // state.materialInfo = null
        state.brandID = json
    },

    /**
     * 推广码
     */
    savePromote: (state, json) => {
        state.promote = json
    },

    /**
     * 扫码进入
     */
    saveQueryStoreID: (state, storeID) => {
        uni.setStorageSync('queryStoreID', storeID)
        uni.removeStorageSync('materialInfo')
        uni.removeStorageSync('brandID')
        state.materialInfo = null
        state.brandID = -1
        state.queryStoreID = storeID
    },

    /**
     * 京西支付信息 自定义金额 以及app跳转支付
     */
    saveJXPayInfo: (state, json) => {
        state.jxPayInfo = json
    },

    /**
     * 保存热销商品
     */
    saveTopGoods: (state, arr) => {
        state.topGoods = arr
    },

    /**
     * 保存当前物料袋的可售数量
     */
    savePreSaleCount: (state, count) => {
        state.preSaleCount = count
    },

    /**
     * 当前物料袋是否可以购买
     */
    changeCanBuy: (state, boo) => {
        state.canBuy = boo
    },

    /**
     * 是否为果园
     */
    changeStoreType:(state,boo) => {
        uni.setStorageSync('storeType', boo?'gy':'c4')
        state.dns = boo ?'wxGy':'wxC4'  // 切换域名
        state.isGy = boo
    },

    /**
     * 保存附近的门店列表
     */
    saveStoreList:(state,arr) => {
        state.storeList = arr
    },

    /**
     * 切换域名
     */
    changeDNS:(state,str) => {
        state.dns = str
    }
}