export default { onLoad() { }, onShow() { // 刷新多语言 this.$langConfig.refresh(); }, computed: { // 是否是英文环境 isEnEnv() { return uni.getStorageSync('lang') === 'en-us'; }, themeStyle() { return this.$store.state.themeStyle; }, themeColor() { return this.$store.state.themeColor; }, // 插件是否存在 addonIsExist() { return this.$store.state.addonIsExist; }, tabBarList() { return this.$store.state.tabBarList; }, siteInfo() { return this.$store.state.siteInfo; }, memberInfo() { return this.$store.state.memberInfo; }, storeToken() { return this.$store.state.token; }, bottomNavHidden() { return this.$store.state.bottomNavHidden; }, globalStoreConfig() { return this.$store.state.globalStoreConfig; }, globalStoreInfo() { return this.$store.state.globalStoreInfo; }, // 定位信息 location() { return this.$store.state.location; }, // 定位信息(缓存) locationStorage() { let data = uni.getStorageSync('location'); if (data) { var date = new Date(); if (this.mapConfig.wap_valid_time > 0) { data.is_expired = (date.getTime() / 1000) > data.valid_time; // 是否过期 } else { data.is_expired = false; } } return data; }, // 默认总店(定位失败后使用) defaultStoreInfo() { return this.$store.state.defaultStoreInfo; }, // 组件刷新计数 componentRefresh() { return this.$store.state.componentRefresh; }, // AI客服配置 globalAIKefuConfig() { return this.$store.state.globalAIKefuConfig; }, // 客服配置 servicerConfig() { return this.$store.state.servicerConfig; }, // 企业微信配置 wxworkConfig() { return this.$store.state.wxworkConfig; }, diySeckillInterval() { return this.$store.state.diySeckillInterval; }, tabBarHeight() { return this.$store.state.tabBarHeight; }, mapConfig() { return this.$store.state.mapConfig; }, copyright() { let copyright = this.$store.state.copyright; // 判断是否授权 if (copyright && !copyright.auth) { copyright.logo = ''; copyright.copyright_link = ''; } return copyright; }, cartList() { return this.$store.state.cartList; }, cartIds() { return this.$store.state.cartIds; }, cartNumber() { return this.$store.state.cartNumber; }, cartMoney() { return this.$store.state.cartMoney; } }, methods: { // 颜色变浅(>0)、变深函数(<0) lightenDarkenColor(color, amount) { var usePound = false; if (color[0] == "#") { color = color.slice(1); usePound = true; } var num = parseInt(color, 16); var r = (num >> 16) + amount; if (r > 255) r = 255; else if (r < 0) r = 0; var b = ((num >> 8) & 0x00FF) + amount; if (b > 255) b = 255; else if (b < 0) b = 0; var g = (num & 0x0000FF) + amount; if (g > 255) g = 255; else if (g < 0) g = 0; return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16); }, /** * 切换门店 * @param {Object} info 门店信息 * @param {Object} isJump 是否跳转到首页 */ changeStore(info, isJump) { if (info) { this.$store.commit('setGlobalStoreInfo', info); } let route = this.$util.getCurrRoute(); if (isJump && route != 'pages/index/index') { uni.setStorageSync('manual_change_store', true); // 手动切换门店 this.$store.dispatch('getCartNumber'); //重新获取购物车数据 this.$util.redirectTo(this.$util.INDEX_PAGE_URL); } } }, filters: { /** * 金额格式化输出 * @param {Object} money */ moneyFormat(money) { if (isNaN(parseFloat(money))) return money; return parseFloat(money).toFixed(2); } } }