// 公共
const module = {
    // 开启命名空间
    namespaced: true,

    // 仓库
    state: {
        iphoneX: false,
        activeShop: null,   // 当前店铺
        activeUpShop: null,   // 当前店铺
        storeConfig: {},  // 店铺设置
        theme: 2,
        tabList: [{
            id: 1,
            name: "首页",
            imgOff: "../../static/tabBar/icon_green_1.png",
            imgOn: "../../static/tabBar/icon_green_1_select.png",
            "url": "/pages/index/index",
            hide:false,
        },
        {
            id: 2,
            name: "店铺",
            imgOff: "../../static/tabBar/icon_green_2.png",
            imgOn: "../../static/tabBar/icon_green_2_select.png",
            "url": "/pages/goods/index",
            hide:false,
        },
        // {
        //     id: 3,
        //     name: "优选",
        //     imgOff: "../../static/tabBar/icon_green_5.png",
        //     imgOn: "../../static/tabBar/icon_green_5_select.png",
        //     "url": "/pages/recommend/index",
        //     hide:true,
        // },
        {
            id: 4,
            name: "购物车",
            imgOff: "../../static/tabBar/icon_green_3.png",
            imgOn: "../../static/tabBar/icon_green_3_select.png",
            "url": "/pages/cart/index",
            hide:false,
        },
        {
            id: 5,
            name: "我的",
            imgOff: "../../static/tabBar/icon_green_4.png",
            imgOn: "../../static/tabBar/icon_green_4_select.png",
            "url": "/pages/user/index",
            hide:false,
        },
        ]
    },

    // 同步方法
    mutations: {
        // 更新数据
        update(state, data) {
            for (let key in data) {
                if (data.hasOwnProperty(key)) {
                    state[key] = data[key]
                }
            }
        },

        // 移除数据
        remove(state, name) {
            if (typeof name === 'string') {
                delete state[name]
            } else {
                for (let key in name) {
                    if (name.hasOwnProperty(key)) {
                        delete state[name[key]]
                    }
                }
            }
        },

        // 移除所有数据
        removeAll(state) {
            for (let key in state) {
                if (state.hasOwnProperty(key)) {
                    delete state[key]
                }
            }
        },
    },

    // 异步方法
    actions: {},
}

export default module
