import { setStorage } from "@/utils/storage";
/**
 * storeInfoStore 模块的 mutations
 */
import { StoreInfoStoreType } from './index'
export default {
    /**
     * 门店详细信息（allStoreInfo）
     * @param {object} allStoreInfo 本地门店详情
     * @param {object} payload 远端门店详情
     */
    setAllStoreInfo(store: StoreInfoStoreType, payload: AnyObject) {
        store.allStoreInfo = payload
        setStorage("storeName", payload.name)
        setStorage("lat", payload.lat)
        setStorage("lng", payload.lng)
    },


    /*************************************************
     * 保存美团门店的IM单聊状态
     */
    setImOnlineStatus(state: StoreInfoStoreType, payload: Array<AnyObject>) {
        state.imOnlineStatus = payload
    },


    /*************************************************
     * 保存三方门店ID(美团/饿了么)
     * @param {boolean} isConnectPrinter 是否连接成功
     * @param {boolean} payload 是否从公众号来 false 没有连接
    */
    setVendorStoreIDS(state: StoreInfoStoreType, payload: AnyObject) {
        state.vendorStoreIDS = payload
    },


    /**
     * 保存三方门店的所有信息
     */
    setPlatformInfo(state:StoreInfoStoreType,payload: AnyObject){
        state.platformInfo = payload
    },
    


    /**
     * 保存门店创建时间 (createStoreTimer)
     * @param {string} createStoreTimer 本地默认门店创建时间
     * @param {object} payload 远端门店创建时间
     */
    setCreateStoreTimer(state: StoreInfoStoreType, payload: string) {
        state.createStoreTimer = payload
    },


    /**
     * 保存门店营业状态 (storeStatus)
     * @param {number} storeStatus 门店营业状态
     * @param {number} payload 门店营业状态
     */
    setStoreStatus(state: StoreInfoStoreType, payload: number) {
        state.storeStatus = payload
    },


    /**
     * 更新加载图层 (jxLoading)
     * @param {boolean} jxLoading 是否显示加载图
     * @param {boolean} payload 是否显示加载图 
     */
    jxLoadingFn(state: StoreInfoStoreType, payload: boolean) {
        state.jxLoading = payload
    },


    /*************************************************
     * 判断是否从公众号来从公众号来先跳转去登录一下
     * @param {boolean} isSkiplogin 是否从公众号来
     * @param {boolean} payload 是否从公众号来 false 不是
    */
    setSkipLost(state: StoreInfoStoreType, payload: boolean) {
        state.isSkiplogin = payload
    },


    /*************************************************
     * 判断打印机是否连接成功
     * @param {boolean} isConnectPrinter 是否连接成功
     * @param {boolean} payload 是否从公众号来 false 没有连接
    */
    setIsConnectPrinter(state: StoreInfoStoreType, payload: boolean) {
        state.isConnectPrinter = payload
    },


    /*************************************************
     * 判断打印机是否有新信息
     * @param {boolean} isNewMessage 是否连接成功
     * @param {boolean} payload 是否有信息
    */
    setIsNewMessage(state: StoreInfoStoreType, payload: boolean) {
        state.isNewMessage = payload
    },


    /*************************************************
     * 拿到新用户信息
     * @param {boolean} imMessage 用户信息
     * @param {boolean} payload 需要吗存的用户信息
    */
    setImMessage(state: StoreInfoStoreType, payload: string) {
        state.imMessage = payload
    }
}
