diff --git a/src/base/ShopItem/ShopItem.vue b/src/base/ShopItem/ShopItem.vue index f0a26cb..7b00eaa 100644 --- a/src/base/ShopItem/ShopItem.vue +++ b/src/base/ShopItem/ShopItem.vue @@ -8,6 +8,7 @@ class="shop-logo" /> +

{{ switchLanguage(shop, 'shopName') }} {{ shop.distance ? shop.distance + '米' : '' }} @@ -33,7 +34,7 @@ -

+
+ + + +
+
+ +
{{ switchLanguage(shop, 'shopName') }}
+
{{ shop.floor }}
+ + +
扫码导航
+
+ + + +
+
@@ -60,9 +87,11 @@ import QRCodeFromText from '@/components/QRCodeFromText/QRCodeFromText.vue' import { storeToRefs } from 'pinia' import { useStore } from '@/store/root' import { computed } from 'vue' +import EffectFade from '@/components/EffectFade/EffectFade.vue' const store = useStore() -const { currentFloor, config, theme, showMap, path } = storeToRefs(store) +const { currentFloor, config, theme, showMap, path, shopPicsMap } = storeToRefs(store) const isBrandShowMap = computed(() => showMap.value && (path.value === '/brand' || path.value === '/foods')) +const pics = computed(() => shopPicsMap.value[props.shop.shopCode]) const props = defineProps({ shop: Object, @@ -82,11 +111,19 @@ const deactivate = () => store.SET_SHOP(null) diff --git a/src/base/ShopItem/arrow.png b/src/base/ShopItem/arrow.png new file mode 100644 index 0000000..b0ffc4e Binary files /dev/null and b/src/base/ShopItem/arrow.png differ diff --git a/src/base/ShopItem/close.png b/src/base/ShopItem/close.png new file mode 100644 index 0000000..0156f92 Binary files /dev/null and b/src/base/ShopItem/close.png differ diff --git a/src/base/ShopItem/loc.png b/src/base/ShopItem/loc.png new file mode 100644 index 0000000..ccdd7e3 Binary files /dev/null and b/src/base/ShopItem/loc.png differ diff --git a/src/base/ShopItem/pictag.png b/src/base/ShopItem/pictag.png new file mode 100644 index 0000000..d499d05 Binary files /dev/null and b/src/base/ShopItem/pictag.png differ diff --git a/src/composables/useInitConfigAndMallInfo.js b/src/composables/useInitConfigAndMallInfo.js index 484c094..4ef1a85 100644 --- a/src/composables/useInitConfigAndMallInfo.js +++ b/src/composables/useInitConfigAndMallInfo.js @@ -1,4 +1,4 @@ -import { getConfig, getCurrentFloor, getGuideList, getTheme, getQMGoShopData, getMenuList, getFoodIIndustryList, getWeather } from '@/http/api' +import { getConfig, getCurrentFloor, getGuideList, getTheme, getQMGoShopData, getMenuList, getFoodIIndustryList, getWeather, getPicsUrl, getPics } from '@/http/api' import { useStore } from '@/store/root' import VConsole from 'vconsole' const matchPXExp = /([0-9.]+px)/g @@ -67,6 +67,43 @@ export const useInitConfigAndMallInfo = async () => { data: { searchList, recommendList } } = await getQMGoShopData() const shopMap = shopList.reduce((acc, nxt) => ({ ...acc, [nxt.shopCode]: nxt }), {}) - + const hasPic = getPicsUrl() + if (hasPic) handlePics() store.SET_INDEX_LIST({ ...weather, recommendList, hotSearch: searchList.filter(({ shopName }) => shopName).map(item => ({ ...item, ...shopMap[item.shopCode] })) }) } + +const fetchPics = async () => { + const store = useStore() + try { + const { data } = await getPics() + if (Array.isArray(data)) { + store.SET_SHOP_PICS(data) + setPics() + } + } catch (error) { + console.log(error) + } +} +const setPics = () => { + const store = useStore() + const now = Date.now() + const shopPicsMap = store.shopPics.reduce((acc, { shopCode, fileUrl, startTime, endTime }) => { + const s = new Date(startTime).getTime() + const e = new Date(endTime).getTime() + if (s < now && e > now) { + acc[shopCode] = acc[shopCode] ? [...acc[shopCode], fileUrl] : [fileUrl] + } + return { ...acc } + }, {}) + store.SET_SHOP_PICS_MAP(shopPicsMap) +} +const handlePics = () => { + fetchPics() + setInterval(() => { + fetchPics() + }, 30 * 60 * 1000) + + setInterval(() => { + setPics() + }, 60 * 1000) +} diff --git a/src/http/api.js b/src/http/api.js index 48508f5..0e7e2e9 100644 --- a/src/http/api.js +++ b/src/http/api.js @@ -54,3 +54,7 @@ export const getMenuList = () => get(`./static/offline/JSON/menuList.json`) export const getFoodIIndustryList = () => get(`./static/offline/JSON/foodIIndustryList.json`) export const getFacilityList = () => get(`./static/offline/JSON/getFacilityList.json`) + +export const getPicsUrl = () => url().picsUrl + +export const getPics = () => post(url().picsUrl, {}) diff --git a/src/http/config.js b/src/http/config.js index 629cb14..56ed3eb 100644 --- a/src/http/config.js +++ b/src/http/config.js @@ -16,5 +16,6 @@ export function url() { const sourceUrl = './static/offline' const handWriteUrl = store.config.handWriteUrl const clickUploadUrl = store.config.clickUploadUrl - return { interfaceUrl, sourceUrl, handWriteUrl, clickUploadUrl } + const picsUrl = !interfaceUrl ? null : !interfaceUrl.startsWith('https') ? null : `${interfaceUrl}/data/v1/web/getShopPictureList` + return { interfaceUrl, sourceUrl, handWriteUrl, clickUploadUrl, picsUrl } } diff --git a/src/store/root/actions.js b/src/store/root/actions.js index dba7b69..6fa164a 100644 --- a/src/store/root/actions.js +++ b/src/store/root/actions.js @@ -1,6 +1,12 @@ import { i18n } from '@/i18n' import { useStatistics } from '@/composables/useStatistics' export const actions = { + SET_SHOP_PICS(list) { + this.shopPics = list + }, + SET_SHOP_PICS_MAP(map) { + this.shopPicsMap = map + }, SET_SHOP_LIST(list) { this.shopList = list }, diff --git a/src/store/root/getters.js b/src/store/root/getters.js index 381c693..01f9770 100644 --- a/src/store/root/getters.js +++ b/src/store/root/getters.js @@ -40,7 +40,6 @@ export const currentFloorShopMap = ({ currentFloor: device, shopList, mapData }) let angle = (Math.atan2(deviceY - xaxis[2], xaxis[0] - deviceX) / Math.PI) * 180 + device.angle if (angle < 0) angle += 360 if (angle > 360) angle -= 360 - console.log(angle) angle = (angle / 180) * Math.PI result.distance = Math.ceil(getDistance({ x: deviceX, y: deviceY }, { x: xaxis[0], y: xaxis[2] }) / building.scale) diff --git a/src/store/root/state.js b/src/store/root/state.js index b7058e4..b5c50de 100644 --- a/src/store/root/state.js +++ b/src/store/root/state.js @@ -1,4 +1,6 @@ export const state = () => ({ + shopPicsMap: {}, + shopPics: [], menuList: [], is4k: is4k(), shopList: [], //店铺列表 diff --git a/src/views/Brand/Brand.vue b/src/views/Brand/Brand.vue index cdb57ab..c00f49b 100644 --- a/src/views/Brand/Brand.vue +++ b/src/views/Brand/Brand.vue @@ -37,7 +37,7 @@ import { useMediaQuery } from '@vueuse/core' const store = useStore() const storeRefs = storeToRefs(store) -const { config, indexList, foodIndustryMap, shop, currentFloor, showMap, showSearch, path } = storeRefs +const { config, indexList, foodIndustryMap, shop, currentFloor, showMap, showSearch, path, shopPicsMap } = storeRefs const mapIdx = ref(-1) const mapTimer = ref(null) const mapIconTimer = ref(null) @@ -67,9 +67,10 @@ onBeforeUnmount(() => { if (!showSearch.value) store.SET_SHOP(null) }) function handleShop(item) { - if (shop.value?.shopCode === item.shopCode) { + if (shop.value?.shopCode === item.shopCode || shopPicsMap.value[item.shopCode]) { if (showMap.value) { - window.Map_QM.pathNode({ floor: shop.value.floorOrder, node: shop.value.yaxis }) + if (shop.value) window.Map_QM.pathNode({ floor: shop.value.floorOrder, node: shop.value.yaxis }) + else window.Map_QM.pathNode({ floor: item.floorOrder, node: item.yaxis }) } else store.SET_SHOW_MAP(true) } mapIdx.value = -1