Browse Source

feat: 🚀 添加分页hooks以及分页逻辑放在worker线程处理

pull/1/head
jiangx 3 years ago
parent
commit
d275da4dd1
  1. 82
      public/static/worker/page.worker.js
  2. 3
      src/assets/images/nav/2D.svg
  3. 3
      src/assets/images/nav/3D.svg
  4. 5
      src/assets/images/nav/big_down.svg
  5. 5
      src/assets/images/nav/big_left.svg
  6. 5
      src/assets/images/nav/big_right.svg
  7. 5
      src/assets/images/nav/big_up.svg
  8. 3
      src/assets/images/nav/down_thumb.svg
  9. 3
      src/assets/images/nav/ft.svg
  10. 3
      src/assets/images/nav/left_thumb.svg
  11. 3
      src/assets/images/nav/path.svg
  12. 3
      src/assets/images/nav/right_thumb.svg
  13. 3
      src/assets/images/nav/up_thumb.svg
  14. 3
      src/assets/images/nav/zt.svg
  15. 17
      src/base/ScrollView/ScrollView.vue
  16. 4
      src/composables/useActivityNav.ts
  17. 8
      src/composables/useChangeNavMethod.ts
  18. 11
      src/composables/useFacilityNav.ts
  19. 46
      src/composables/usePage.ts
  20. 4
      src/composables/useSearchShop.ts
  21. 2
      src/composables/useStatistics.ts
  22. 2
      src/http/api/statistics/types.ts
  23. 6
      src/types/map.d.ts
  24. 40
      src/types/shop.d.ts
  25. 6
      src/utils/Class/Brand.ts
  26. 10
      src/views/Guide/Guide.vue
  27. 28
      src/views/Nav/Nav.vue

82
public/static/worker/page.worker.js

@ -0,0 +1,82 @@
const MAX_LENGTH = 20
let pageIndex = 1 //数组中需要分页(即下标为pageIdx的数据)的当前页 大数组中的二维
const pageSize = 20 //一页显示的条数
let pageList = [] //用于UI渲染的列表
let showMore = false
let pageIdx = 0 //当前是数组中的哪一项需要分页 大数组中的一维
let allList = []
let loaded = false
function loadMore(_pageIndex) {
if (!Array.isArray(allList)) {
return
}
//如果数组中的大分页项大于等于大数组的长度则全部分页完成
if (pageIdx >= allList.length) {
loaded = true
return
}
pageIndex = _pageIndex
const size = allList[pageIdx].shopList.slice(0, pageIndex * pageSize)
//数组中需要分页的列表项是否存在于渲染列表中 如果有则直接把分页的数据赋值 没有则新开一个放到渲染列表中
if (pageList[pageIdx]?.name) {
pageList[pageIdx].shopList = size
} else {
pageList.push({
name: allList[pageIdx].name,
shopList: size
})
}
showMore = false
}
function scrollEnd() {
if (pageIdx >= allList.length || pageIdx < 0) {
loaded = true
return
}
if (pageList[pageIdx].shopList.length >= allList[pageIdx].shopList.length) {
pageIdx++
pageIndex = 1
loadMore(pageIndex)
return
}
if (!showMore) {
showMore = true
loadMore(pageIndex + 1)
}
}
self.onmessage = e => {
if (Array.isArray(e.data)) {
allList = e.data
}
if (e.data === 'scrollEnd') {
scrollEnd(allList)
self.postMessage({ pageList, loaded, refresh: false })
return
}
//数据变化时重置分页数据 一般是点击了业态或楼层筛选
loaded = false
pageIndex = 1
pageList = []
//找出数据中店铺列表长度大于分页点的索引 从索引处开始分页
pageIdx = allList.findIndex(item => item.shopList.length > MAX_LENGTH)
//pageIdx小于0的话 说明没有店铺列表长度大于分页点的 无需分页直接返回数据
if (pageIdx < 0) {
pageList = e.data
loaded = true
self.postMessage({ pageList, loaded, refresh: true })
return
}
if (pageIdx !== 0) {
for (let i = 0; i < pageIdx; i++) {
pageList.push(allList[i])
}
}
loadMore(pageIndex, allList)
self.postMessage({ pageList, loaded, refresh: true })
}

3
src/assets/images/nav/2D.svg

@ -0,0 +1,3 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.6236 5.27583C15.6692 5.24844 15.8025 5.1998 16.0001 5.1998C16.1977 5.1998 16.3311 5.24844 16.3767 5.27583L27.5833 11.9998L16.3767 18.7238C16.3311 18.7512 16.1977 18.7998 16.0001 18.7998C15.8025 18.7998 15.6692 18.7512 15.6236 18.7238L4.41692 11.9998L15.6236 5.27583ZM17.6115 3.21784C17.1082 2.91586 16.522 2.7998 16.0001 2.7998C15.4782 2.7998 14.8921 2.91586 14.3888 3.21784L2.46112 10.3744C1.95858 10.676 1.4668 11.2272 1.4668 11.9998C1.4668 12.7724 1.95858 13.3237 2.46112 13.6252L14.3888 20.7818C14.8921 21.0838 15.4782 21.1998 16.0001 21.1998C16.522 21.1998 17.1082 21.0838 17.6115 20.7818L29.5391 13.6252C30.0417 13.3237 30.5335 12.7724 30.5335 11.9998C30.5335 11.2272 30.0417 10.676 29.5391 10.3744L17.6115 3.21784ZM2.46112 18.3747L4.30488 17.2685L6.60773 18.6856L4.41692 20.0001L15.6236 26.7241C15.6692 26.7515 15.8025 26.8001 16.0001 26.8001C16.1977 26.8001 16.3311 26.7515 16.3767 26.7241L27.5833 20.0001L25.3924 18.6855L27.6953 17.2684L29.5391 18.3747C30.0417 18.6763 30.5335 19.2275 30.5335 20.0001C30.5335 20.7727 30.0417 21.324 29.5391 21.6255L17.6115 28.7821C17.1082 29.084 16.522 29.2001 16.0001 29.2001C15.4782 29.2001 14.8921 29.084 14.3888 28.7821L2.46112 21.6255C1.95858 21.324 1.4668 20.7727 1.4668 20.0001C1.4668 19.2275 1.95858 18.6763 2.46112 18.3747Z" fill="#605E74"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

3
src/assets/images/nav/3D.svg

@ -0,0 +1,3 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.3004 1.28779C16.496 0.823342 15.5048 0.823342 14.7004 1.28779L3.90937 7.51799C3.10493 7.98243 2.60938 8.84076 2.60938 9.76965V22.2301C2.60938 23.1589 3.10493 24.0173 3.90938 24.4817L14.7004 30.7119C15.5048 31.1764 16.496 31.1764 17.3004 30.7119L28.0914 24.4817C28.8959 24.0173 29.3914 23.1589 29.3914 22.2301V9.76965C29.3914 8.84076 28.8959 7.98243 28.0914 7.51799L17.3004 1.28779ZM15.9671 3.48172C15.9877 3.46981 16.0131 3.46981 16.0337 3.48172L26.8248 9.71192C26.8454 9.72383 26.8581 9.74584 26.8581 9.76965V22.2301C26.8581 22.2539 26.8454 22.2759 26.8248 22.2878L16.0337 28.518C16.0131 28.5299 15.9877 28.5299 15.9671 28.518L5.17604 22.2878C5.15542 22.2759 5.14271 22.2539 5.14271 22.2301V9.76965C5.14271 9.74584 5.15542 9.72383 5.17604 9.71192L15.9671 3.48172ZM8.63818 10.2391C8.03392 9.88659 7.25831 10.0907 6.90583 10.695C6.55334 11.2992 6.75744 12.0748 7.36171 12.4273L14.7333 16.7274V25.3332C14.7333 26.0328 15.3004 26.5999 15.9999 26.5999C16.6995 26.5999 17.2666 26.0328 17.2666 25.3332V16.7274L24.6382 12.4273C25.2424 12.0748 25.4466 11.2992 25.0941 10.695C24.7416 10.0907 23.966 9.88659 23.3617 10.2391L15.9999 14.5334L8.63818 10.2391Z" fill="#535D75"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

5
src/assets/images/nav/big_down.svg

@ -0,0 +1,5 @@
<svg width="38" height="82" viewBox="0 0 38 82" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 50L-7.10483e-07 66.254L19 82L38 66.254L38 50L19 65.746L0 50Z" fill="#F6987F"/>
<path opacity="0.8" fill-rule="evenodd" clip-rule="evenodd" d="M0 25L-7.10483e-07 41.254L19 57L38 41.254L38 25L19 40.746L0 25Z" fill="#F6987F"/>
<path opacity="0.6" fill-rule="evenodd" clip-rule="evenodd" d="M0 0L-7.10483e-07 16.254L19 32L38 16.254L38 1.66103e-06L19 15.746L0 0Z" fill="#F6987F"/>
</svg>

After

Width:  |  Height:  |  Size: 531 B

5
src/assets/images/nav/big_left.svg

@ -0,0 +1,5 @@
<svg width="82" height="38" viewBox="0 0 82 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M32 0L15.746 -1.42097e-06L-1.66103e-06 19L15.746 38L32 38L16.254 19L32 0Z" fill="#F6987F"/>
<path opacity="0.8" fill-rule="evenodd" clip-rule="evenodd" d="M57 0L40.746 -1.42097e-06L25 19L40.746 38L57 38L41.254 19L57 0Z" fill="#F6987F"/>
<path opacity="0.6" fill-rule="evenodd" clip-rule="evenodd" d="M82 0L65.746 -1.42097e-06L50 19L65.746 38L82 38L66.254 19L82 0Z" fill="#F6987F"/>
</svg>

After

Width:  |  Height:  |  Size: 534 B

5
src/assets/images/nav/big_right.svg

@ -0,0 +1,5 @@
<svg width="82" height="38" viewBox="0 0 82 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M50 0L66.254 -1.42097e-06L82 19L66.254 38L50 38L65.746 19L50 0Z" fill="#F6987F"/>
<path opacity="0.8" fill-rule="evenodd" clip-rule="evenodd" d="M25 0L41.254 -1.42097e-06L57 19L41.254 38L25 38L40.746 19L25 0Z" fill="#F6987F"/>
<path opacity="0.6" fill-rule="evenodd" clip-rule="evenodd" d="M0 0L16.254 -1.42097e-06L32 19L16.254 38L3.32207e-06 38L15.746 19L0 0Z" fill="#F6987F"/>
</svg>

After

Width:  |  Height:  |  Size: 531 B

5
src/assets/images/nav/big_up.svg

@ -0,0 +1,5 @@
<svg width="38" height="82" viewBox="0 0 38 82" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 32L-2.13145e-06 15.746L19 -2.49155e-06L38 15.746L38 32L19 16.254L0 32Z" fill="#F6987F"/>
<path opacity="0.8" fill-rule="evenodd" clip-rule="evenodd" d="M0 57L-2.13145e-06 40.746L19 25L38 40.746L38 57L19 41.254L0 57Z" fill="#F6987F"/>
<path opacity="0.6" fill-rule="evenodd" clip-rule="evenodd" d="M0 82L-2.13145e-06 65.746L19 50L38 65.746L38 82L19 66.254L0 82Z" fill="#F6987F"/>
</svg>

After

Width:  |  Height:  |  Size: 534 B

3
src/assets/images/nav/down_thumb.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.00017 12.172L1.63617 6.808L0.222168 8.222L8.00017 16L15.7782 8.222L14.3642 6.808L9.00017 12.172L9.00017 3.83699e-07L7.00017 2.96276e-07L7.00017 12.172Z" fill="#6879B0"/>
</svg>

After

Width:  |  Height:  |  Size: 285 B

3
src/assets/images/nav/ft.svg

@ -0,0 +1,3 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.3045 6.71338C13.3045 7.84358 12.3878 8.76025 11.2602 8.76025C10.1326 8.76025 9.21594 7.84358 9.21333 6.7134C9.21333 5.58317 10.1274 4.6665 11.2602 4.6665C12.3878 4.6665 13.3045 5.58578 13.3045 6.71338ZM11.229 9.23686C10.1977 9.26029 9.18473 9.58061 9.18473 10.9634V17.4478L13.3722 13.6353V10.9634C13.3722 9.52591 12.2915 9.21082 11.229 9.23686ZM20.3904 8.39036C20.6404 8.14031 20.9795 7.99984 21.3332 7.99984H28.3332C28.8855 7.99984 29.3332 8.44755 29.3332 8.99984V9.6665C29.3332 10.2188 28.8855 10.6665 28.3332 10.6665H22.2997C22.0345 10.6665 21.7801 10.7719 21.5926 10.9594L8.94265 23.6093C8.6926 23.8594 8.35346 23.9998 7.99984 23.9998H3.6665C3.11422 23.9998 2.6665 23.5521 2.6665 22.9998V22.3332C2.6665 21.7809 3.11422 21.3332 3.6665 21.3332H7.03334C7.29856 21.3332 7.55291 21.2278 7.74045 21.0403L20.3904 8.39036ZM23.3332 11.9998C22.8027 11.9998 22.294 12.2106 21.919 12.5856L9.4643 25.0403C9.27677 25.2278 9.02241 25.3332 8.7572 25.3332H3.6665C3.11422 25.3332 2.6665 25.7809 2.6665 26.3332V28.3332C2.6665 28.8855 3.11422 29.3332 3.6665 29.3332H9.99984C10.5303 29.3332 11.039 29.1225 11.4141 28.7474L23.8687 16.2927C24.0562 16.1052 24.3106 15.9998 24.5758 15.9998H28.3332C28.8855 15.9998 29.3332 15.5521 29.3332 14.9998V12.9998C29.3332 12.4476 28.8855 11.9998 28.3332 11.9998H23.3332Z" fill="#535D75"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

3
src/assets/images/nav/left_thumb.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.828 6.99998L9.192 1.63598L7.778 0.221985L0 7.99998L7.778 15.778L9.192 14.364L3.828 8.99998H16V6.99998H3.828Z" fill="#6879B0"/>
</svg>

After

Width:  |  Height:  |  Size: 242 B

3
src/assets/images/nav/path.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.1 KiB

3
src/assets/images/nav/right_thumb.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.172 6.99998L6.808 1.63598L8.222 0.221985L16 7.99998L8.222 15.778L6.808 14.364L12.172 8.99998H0V6.99998H12.172Z" fill="#6879B0"/>
</svg>

After

Width:  |  Height:  |  Size: 245 B

3
src/assets/images/nav/up_thumb.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.00017 3.828L1.63617 9.192L0.222168 7.778L8.00017 -3.39987e-07L15.7782 7.778L14.3642 9.192L9.00017 3.828L9.00017 16L7.00017 16L7.00017 3.828Z" fill="#6879B0"/>
</svg>

After

Width:  |  Height:  |  Size: 274 B

3
src/assets/images/nav/zt.svg

@ -0,0 +1,3 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.33317 25.3333V6.66667H14.6665V25.3333H5.33317ZM17.3332 28H14.6665H3.99984C3.64622 28 3.30708 27.8595 3.05703 27.6095C2.80698 27.3594 2.6665 27.0203 2.6665 26.6667V5.33333C2.6665 4.97971 2.80698 4.64057 3.05703 4.39052C3.30708 4.14048 3.64622 4 3.99984 4H14.6665H17.3332H27.9998C28.3535 4 28.6926 4.14048 28.9426 4.39052C29.1927 4.64057 29.3332 4.97971 29.3332 5.33333V26.6667C29.3332 27.0203 29.1927 27.3594 28.9426 27.6095C28.6926 27.8595 28.3535 28 27.9998 28H17.3332ZM17.3332 6.66667H26.6665V25.3333H17.3332V6.66667ZM9.99984 9.6156L10.5253 10.1315L13.8586 13.4042L12.8077 14.4746L10.7498 12.4541V22.6667H9.24984V12.4541L7.19195 14.4746L6.14106 13.4042L9.47439 10.1315L9.99984 9.6156ZM22.5253 21.8685L21.9998 22.3844L21.4744 21.8685L18.1411 18.5958L19.1919 17.5254L21.2498 19.5459V9.33333H22.7498V19.5459L24.8077 17.5254L25.8586 18.5958L22.5253 21.8685Z" fill="#605E74"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

17
src/base/ScrollView/ScrollView.vue

@ -26,6 +26,7 @@ type Props = {
refreshDelay?: number refreshDelay?: number
scrollTop?: boolean scrollTop?: boolean
stopPropagation?: boolean stopPropagation?: boolean
pullUp: boolean
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
@ -37,7 +38,8 @@ const props = withDefaults(defineProps<Props>(), {
deceleration: 0.02, deceleration: 0.02,
refreshDelay: 20, refreshDelay: 20,
scrollTop: true, scrollTop: true,
stopPropagation: false
stopPropagation: false,
pullUp: false
}) })
const _BScrollRef = shallowRef<BScrollInstance | null>(null) const _BScrollRef = shallowRef<BScrollInstance | null>(null)
@ -46,6 +48,8 @@ const timer = ref<any>()
const store = useStore() const store = useStore()
const { language } = toRefs(store) const { language } = toRefs(store)
const emits = defineEmits(['scroll-end'])
function _initScroll() { function _initScroll() {
if (!scrollDOMRef.value) { if (!scrollDOMRef.value) {
return return
@ -61,6 +65,17 @@ function _initScroll() {
observeImage: props.observeImage, observeImage: props.observeImage,
stopPropagation: props.stopPropagation stopPropagation: props.stopPropagation
}) })
if (props.pullUp) {
_BScrollRef.value.on('scrollEnd', () => {
if (!_BScrollRef.value) {
return
}
if (_BScrollRef.value?.y <= _BScrollRef.value?.maxScrollY + 50) {
emits('scroll-end')
}
})
}
} }
function refresh() { function refresh() {

4
src/composables/useActivityNav.ts

@ -13,8 +13,8 @@ export const useActivityNav = () => {
if (activity?.shopCode?.length) { if (activity?.shopCode?.length) {
shop = shopList.value.find(item => item.shopCode === activity?.shopCode) shop = shopList.value.find(item => item.shopCode === activity?.shopCode)
} else if (typeof activity.point === 'number') { } else if (typeof activity.point === 'number') {
const { activityName, floorOrder, floor, point, fileUrl } = activity
shop = new Brand({ shopName: activityName, floorOrder, floor, logoUrl: fileUrl, yaxis: point })
const { activityName, floorOrder, floor, point, fileUrl, activityId } = activity
shop = new Brand({ shopName: activityName, floorOrder, floor, logoUrl: fileUrl, yaxis: point, shopCode: activityId })
} }
if (!shop) { if (!shop) {
return return

8
src/composables/useChangeNavMethod.ts

@ -5,14 +5,8 @@ import { NavMethods, methodsList } from '@/views/Nav/methodsList'
* *
* *
* @param {Function} callback * @param {Function} callback
* @return {
* methodsList: 导航路线 ;
* methodIdx: 当前路线选中的索引;
* handleControl: 切换路线 ;
* selectedWayMethods: 选中哪条路线;
* }
*/ */
export const useChangeNavMethod = (callback: () => void) => {
export const useChangeNavMethod = (callback: ({ direction, wayList }: { direction: Direction; wayList: Shop[] }) => void) => {
const methodIdx = ref(0) const methodIdx = ref(0)
//切换导航路线 //切换导航路线
function handleControl(method: NavMethods, index: number) { function handleControl(method: NavMethods, index: number) {

11
src/composables/useFacilityNav.ts

@ -6,15 +6,16 @@ export const useFacilityNav = () => {
const store = useStore() const store = useStore()
const router = useRouter() const router = useRouter()
function handleFacility(item: Facility) {
const facility = window.Map_QM.pathIcon({ type: item.abbreviation })
function handleFacility({ abbreviation, customFacilityName, filePath, code }: Facility) {
const facility = window.Map_QM.pathIcon({ type: abbreviation })
const floorName = store.currentBuildingFloorsList.find(floor => floor.floorOrder === facility.floor)?.floor const floorName = store.currentBuildingFloorsList.find(floor => floor.floorOrder === facility.floor)?.floor
const shop = new Brand({ const shop = new Brand({
shopName: item.customFacilityName,
shopName: customFacilityName,
floorOrder: facility.floor, floorOrder: facility.floor,
floor: floorName as string, floor: floorName as string,
logoUrl: item.filePath,
yaxis: facility.node
logoUrl: filePath,
yaxis: facility.node,
shopCode: code
}) })
store.SET_SHOP(shop) store.SET_SHOP(shop)
router.push('/nav') router.push('/nav')

46
src/composables/usePage.ts

@ -0,0 +1,46 @@
import { ref, shallowRef, watch, toRaw, nextTick, onBeforeUnmount, type ShallowRef } from 'vue'
/**
* @param {array} totalList
* @param {*} scroll
* @return {*} { scrollEnd, pageList, loaded }
*/
type PageList = { name: string; shopList: Shop[] }
export const usePage = (totalList: PageList[], scroll: ShallowRef<any>) => {
if (typeof Worker === 'undefined') {
alert('抱歉,当前运行环境不支持Web Worker API, 请升级浏览器版本')
}
const pageList = shallowRef<PageList[]>([]) //用于UI渲染的列表
const loaded = ref(false)
const worker = ref<Worker>()
worker.value = new Worker('./static/worker/page.worker.js')
worker.value.onmessage = e => {
pageList.value = e.data.pageList
loaded.value = e.data.loaded
if (e.data.refresh) {
nextTick(() => {
scroll.value?.scrollTo?.(0, 0, 100)
})
}
}
function scrollEnd() {
worker.value?.postMessage('scrollEnd')
}
watch(
totalList,
newVal => {
const rawList = newVal.map(item => toRaw(item))
worker.value?.postMessage(rawList)
},
{
immediate: true
}
)
onBeforeUnmount(() => {
worker.value?.terminate()
})
return { scrollEnd, pageList, loaded }
}

4
src/composables/useSearchShop.ts

@ -1,6 +1,6 @@
import { computed, shallowRef, watch } from 'vue' import { computed, shallowRef, watch } from 'vue'
import { useStore } from '@/store/root' import { useStore } from '@/store/root'
import type { Ref } from 'vue'
import type { Ref, ShallowRef } from 'vue'
/** /**
*` *`
* *
@ -8,7 +8,7 @@ import type { Ref } from 'vue'
* @param {Ref<UnwrapRef<number>>} [searchType=0] 0:键盘搜索 1:手写搜索 * @param {Ref<UnwrapRef<number>>} [searchType=0] 0:键盘搜索 1:手写搜索
* @return {*} [searchShopListRef] * @return {*} [searchShopListRef]
*/ */
export const useSearchShop = (watchName: Ref<string>, searchType: Ref<0 | 1>): { searchShopListRef: Ref<Shop[]> } => {
export const useSearchShop = (watchName: Ref<string>, searchType: Ref<0 | 1>): { searchShopListRef: ShallowRef<Shop[]> } => {
const store = useStore() const store = useStore()
const searchShopListRef = shallowRef<Shop[]>([]) const searchShopListRef = shallowRef<Shop[]>([])
const cacheFirstSearchListRef = shallowRef<Shop[]>([]) //缓存第一次检索首字母后的列表结果 const cacheFirstSearchListRef = shallowRef<Shop[]>([]) //缓存第一次检索首字母后的列表结果

2
src/composables/useStatistics.ts

@ -5,7 +5,7 @@ import type { Query, TagType } from '@/http/api/statistics/types'
//店铺编码: tag=navigation或shop或brandSearch或时必传 //店铺编码: tag=navigation或shop或brandSearch或时必传
//industryCode : tag=industry时必传 //industryCode : tag=industry时必传
export const useStatistics = ({ tag, shopCode, industryCode }: { tag: TagType; shopCode: string; industryCode: string }) => {
export const useStatistics = ({ tag, shopCode, industryCode = '' }: { tag: TagType; shopCode: string | number; industryCode?: string }) => {
const store = useStore() const store = useStore()
const { currentFloor } = storeToRefs(store) const { currentFloor } = storeToRefs(store)

2
src/http/api/statistics/types.ts

@ -5,6 +5,6 @@ export type Query = {
deviceCode: string //设备编码 deviceCode: string //设备编码
projectCode: string //项目编码 projectCode: string //项目编码
tag: TagType tag: TagType
shopCode?: string
shopCode?: string | number
industryCode?: string //tag=industry时必传 industryCode?: string //tag=industry时必传
} }

6
src/types/map.d.ts

@ -169,19 +169,19 @@ export declare global {
* *
* @param callBack * @param callBack
*/ */
ChangePathByFt(callBack?: () => void): void
ChangePathByFt(callBack?: ({ direction, wayList }: { direction: Direction; wayList: Shop[] }) => void): void
/** /**
* *
* @param callBack * @param callBack
*/ */
ChangePathByGood(callBack?: () => void): void
ChangePathByGood(callBack?: ({ direction, wayList }: { direction: Direction; wayList: Shop[] }) => void): void
/** /**
* *
* @param callBack * @param callBack
*/ */
ChangePathByDt(callBack?: () => void): void
ChangePathByDt(callBack?: ({ direction, wayList }: { direction: Direction; wayList: Shop[] }) => void): void
/** /**
* *

40
src/types/shop.d.ts

@ -1,25 +1,25 @@
declare interface Shop { declare interface Shop {
shopName: string
floor: string
floorOrder: number
logoUrl: string
yaxis: number | string
shopCode?: string
shopNameEn?: string
initials?: string
spelling?: string
shopName: string //店铺名
floor: string //所属楼层名称 从 0 开始递增
floorOrder: number //楼层编号
logoUrl: string //logo图片
yaxis: number | string //店铺导航点
shopCode: string | number //店铺code
shopNameEn?: string //店铺英文名
initials?: string //店铺名首字母
spelling?: string //店铺名称中文全拼
alias?: string //店铺别名 alias?: string //店铺别名
borderColor?: string
formatColor?: string
buildingCode?: number
building?: string
buildingOrder?: number
borderColor?: string //地图内该店铺的box边框颜色
formatColor?: string //地图内该店铺的box颜色
buildingCode?: number //所属楼栋code
building?: string //所属楼栋名称
buildingOrder?: number //所属楼栋编号
floorCode?: number floorCode?: number
houseNumber?: string
houseNumber?: string //门牌号
contact?: string //联系方式 contact?: string //联系方式
businessHours?: string //营业时间 businessHours?: string //营业时间
intro?: string
introEn?: string
intro?: string //店铺简介
introEn?: string //简介英文
industryFatherCode?: string //父业态code industryFatherCode?: string //父业态code
industryFatherName?: string //父业态 industryFatherName?: string //父业态
industryUrl?: string //父业态icon industryUrl?: string //父业态icon
@ -37,7 +37,7 @@ declare interface Shop {
thirdKouCode?: number //口碑ID thirdKouCode?: number //口碑ID
thirdMeiCode?: number //美味不用等ID thirdMeiCode?: number //美味不用等ID
thirdZhiCode?: number //智石ID thirdZhiCode?: number //智石ID
doorMaterialList?: string[]
foodMaterialList?: string[]
activityList?: Activity[]
doorMaterialList?: string[] //店铺简介图
foodMaterialList?: string[] //美食素材图
activityList?: Activity[] //店铺活动图
} }

6
src/utils/Class/Brand.ts

@ -1,4 +1,4 @@
type PickShop = Pick<Shop, 'shopName' | 'floorOrder' | 'floor' | 'logoUrl' | 'yaxis'>
type PickShop = Pick<Shop, 'shopName' | 'floorOrder' | 'floor' | 'logoUrl' | 'yaxis' | 'shopCode'>
/** /**
* Creates an instance of Shop. * Creates an instance of Shop.
* @param {*} { shopName, floorOrder, floor, logoUrl, yaxis } * @param {*} { shopName, floorOrder, floor, logoUrl, yaxis }
@ -10,11 +10,13 @@ export default class Brand {
floor: string floor: string
logoUrl: string logoUrl: string
yaxis: number | string yaxis: number | string
constructor({ shopName, floorOrder, floor, logoUrl, yaxis }: PickShop) {
shopCode: string | number
constructor({ shopName, floorOrder, floor, logoUrl, yaxis, shopCode }: PickShop) {
this.shopName = shopName this.shopName = shopName
this.floorOrder = floorOrder this.floorOrder = floorOrder
this.floor = floor this.floor = floor
this.logoUrl = logoUrl this.logoUrl = logoUrl
this.yaxis = yaxis this.yaxis = yaxis
this.shopCode = shopCode
} }
} }

10
src/views/Guide/Guide.vue

@ -3,15 +3,11 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useStore } from '@/store/root'
import { useGuideMapOperation } from '@/composables/useGuideMapOperation' import { useGuideMapOperation } from '@/composables/useGuideMapOperation'
import { useFacilityNav } from '@/composables/useFacilityNav' import { useFacilityNav } from '@/composables/useFacilityNav'
import { useGuideFilterShop } from '@/composables/useGuideFilterShop' import { useGuideFilterShop } from '@/composables/useGuideFilterShop'
import ScrollView from '@/base/ScrollView/ScrollView.vue'
const store = useStore()
// const { floorIdx, selectedShopList, filterShopByFloorName, filterAboutCurrentInfo } = useGuideFilterShop() //
// const { switchFloor, handleMapIcon, list, mapIdx } = useGuideMapOperation() //
// const { handleFacility } = useFacilityNav() //
const { floorIdx, selectedShopList, filterShopByFloorName, filterAboutCurrentInfo } = useGuideFilterShop() //
const { switchFloor, handleMapIcon, list, mapIdx } = useGuideMapOperation() //
const { handleFacility } = useFacilityNav() //
</script> </script>

28
src/views/Nav/Nav.vue

@ -3,21 +3,21 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// import { storeToRefs } from 'pinia'
// import { useStore } from '@/store/root'
// import { useMapNavControl } from '@/composables/useMapNavControl'
// import { useChangeNavMethod } from '@/composables/useChangeNavMethod'
// import { useStartNavi } from '@/composables/useStartNavi'
// import { useSetCameraViews } from '@/composables/useSetCameraViews'
// import { useBrandStatistics } from '@/composables/useStatistics'
import { storeToRefs } from 'pinia'
import { useStore } from '@/store/root'
import { useMapNavControl } from '@/composables/useMapNavControl'
import { useChangeNavMethod } from '@/composables/useChangeNavMethod'
import { useStartNavi } from '@/composables/useStartNavi'
import { useSetCameraViews } from '@/composables/useSetCameraViews'
import { useStatistics } from '@/composables/useStatistics'
// const store = useStore()
// const { shop, currentFloor } = storeToRefs(store)
const store = useStore()
const { shop, currentFloor } = storeToRefs(store)
// useBrandStatistics('')
useStatistics({ tag: 'navigation', shopCode: shop.value.shopCode })
// const { replay, pause, speedUp, handleReplay, togglePause, handleSpeedUp, resetPause } = useMapNavControl()
// const { directionInfo, pathShopList, backPathArray } = useStartNavi(shop, currentFloor, resetPause)
// const { methodIdx, handleControl } = useChangeNavMethod(backPathArray)
// const { cameraViews, setCameraViews } = useSetCameraViews(resetPause)
const { replay, pause, speedUp, handleReplay, togglePause, handleSpeedUp, resetPause } = useMapNavControl()
const { directionInfo, pathShopList, backPathArray } = useStartNavi(shop, currentFloor, resetPause)
const { methodIdx, handleControl } = useChangeNavMethod(backPathArray)
const { cameraViews, setCameraViews } = useSetCameraViews(resetPause)
</script> </script>

Loading…
Cancel
Save