Browse Source

feat: 支持指路机

ShangHai_LongXiang
jiannibang 2 years ago
parent
commit
c9e0e1b355
  1. 1
      package.json
  2. 2149
      public/static/offline/JSON/getDevCoordinateByIP.json
  3. 2
      src/composables/useFacilityNav.js
  4. 4
      src/composables/useInitMap.js
  5. 147
      src/composables/useShockman.js
  6. 3
      src/store/root/getters.js
  7. 27
      src/views/Brand/Brand.vue
  8. 19
      src/views/Guide/Guide.vue

1
package.json

@ -17,6 +17,7 @@
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"axios": "^0.26.0", "axios": "^0.26.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"crypto-js": "^4.2.0",
"lottie-web": "^5.9.6", "lottie-web": "^5.9.6",
"pinia": "^2.0.11", "pinia": "^2.0.11",
"qrcode": "^1.5.1", "qrcode": "^1.5.1",

2149
public/static/offline/JSON/getDevCoordinateByIP.json

File diff suppressed because it is too large

2
src/composables/useFacilityNav.js

@ -9,7 +9,7 @@ export const useFacilityNav = () => {
store.showSearch && store.SET_SHOW_SEARCH(false) store.showSearch && store.SET_SHOW_SEARCH(false)
store.showDetail && store.SET_SHOW_DETAIL(false) store.showDetail && store.SET_SHOW_DETAIL(false)
store.shop && store.SET_SHOP(null) store.shop && store.SET_SHOP(null)
store.SET_FACILITY(window.Map_QM.pathIcon({ type: item.type }))
store.SET_FACILITY({ ...item, ...window.Map_QM.pathIcon({ type: item.type }) })
router.push('/guide') router.push('/guide')
} }

4
src/composables/useInitMap.js

@ -3,6 +3,7 @@ import { useStore } from '@/store/root'
import { uniqBy } from '@/utils/utils' import { uniqBy } from '@/utils/utils'
import { getMap, getFacilityList } from '@/http/api' import { getMap, getFacilityList } from '@/http/api'
import Message from '@/base/Message/Message' import Message from '@/base/Message/Message'
import { isZhiluji, useShockman } from './useShockman'
export const useInitMap = function () { export const useInitMap = function () {
const store = useStore() const store = useStore()
@ -24,6 +25,9 @@ export const useInitMap = function () {
window.Map_QM.addEventListener('shop', onClickShop, false) window.Map_QM.addEventListener('shop', onClickShop, false)
store.SET_FACILITY_LIST(uniqBy(list, 'type')) store.SET_FACILITY_LIST(uniqBy(list, 'type'))
window.Map_QM.renderer.domElement.addEventListener('webglcontextlost', onContextLost) window.Map_QM.renderer.domElement.addEventListener('webglcontextlost', onContextLost)
if (isZhiluji()) {
useShockman()
}
}) })
}) })
.catch(() => { .catch(() => {

147
src/composables/useShockman.js

@ -0,0 +1,147 @@
import { defineStore, storeToRefs } from 'pinia'
import { useStore } from '@/store/root'
import MD5 from 'crypto-js/md5'
const useShockmanStore = defineStore('shockman', {
state: () => ({
list: [],
intervalTimer: 0,
playTimer: 0,
index: 0
}),
actions: {
SET_LIST(list) {
this.list = list
},
SET_INTERVAL_TIMER(intervalTimer) {
this.intervalTimer = intervalTimer
},
SET_PLAY_TIMER(playTimer) {
this.playTimer = playTimer
},
APPEND_INDEX() {
this.index++
}
}
})
export const isZhiluji = () => {
const store = useStore()
const { device } = storeToRefs(store)
return device.value.machineTypeName === '指路机' && device.value.targetInfoList && device.value.controlInfo
}
const sendMsg2Shockman = async ({ progMode, progText1, progText2, progDist, progAngel }) => {
try {
const deviceKey = 'shockman!_$2023'
const body = new FormData()
body.append('deviceKey', deviceKey)
body.append('progMode', progMode)
body.append('progText1', progText1)
body.append('progTextColor', '6')
body.append('progText2', progText2)
body.append('progText2Color', '6')
body.append('progDist', progDist)
body.append('progDistColor', '6')
body.append('progAngel', progAngel)
body.append('progArmNo', '1')
body.append('progRota', '1')
body.append('progTrans', '1')
body.append('progDuration', '7200000')
body.append('progMd5', MD5(`${progMode}${progText1}6${progText2}6${progDist}6${progAngel}1117200000${deviceKey}`).toString().toUpperCase())
body.append('progStat', '1')
const res = await fetch('http://192.168.2.124:8100/program/play', { method: 'POST', body })
const json = await res.json()
if (json.rtnCode === '0') {
console.log(progText1, progText2, progDist, progAngel, '指路机执行成功')
} else {
console.log(progText1, progText2, progDist, progAngel, '指路机执行失败', json.rtnMsg)
}
} catch (error) {
console.log(progText1, progText2, progDist, progAngel, '指路机执行失败', error)
}
}
const sendMsgByInfo = info => {
const progMode = String(info.playWay)
const progText1 = info.oneText
const progText2 = info.playWay === 1 || info.playWay === 4 ? info.twoText : ' '
const progDist = info.playWay === 3 || info.playWay === 4 ? ' ' : info.cost + '米'
const progAngel = String(info.angle)
sendMsg2Shockman({ progMode, progText1, progText2, progDist, progAngel })
}
const getIntervalTimer = () => {
const store = useStore()
const shockmanStore = useShockmanStore()
const { device } = storeToRefs(store)
const { list, index, playTimer } = storeToRefs(shockmanStore)
return setInterval(() => {
if (playTimer.value) {
clearTimeout(playTimer.value)
shockmanStore.SET_PLAY_TIMER(0)
}
shockmanStore.APPEND_INDEX()
const current = list.value[index.value % list.value.length]
if (current) sendMsgByInfo(current)
}, (device.value.controlInfo?.rotationTime || Infinity) * 1000)
}
export const useShockman = () => {
const store = useStore()
const { device } = storeToRefs(store)
if (!(device.value.machineTypeName === '指路机' && device.value.targetInfoList && device.value.controlInfo)) {
return
}
const shockmanStore = useShockmanStore()
const { list, index } = storeToRefs(shockmanStore)
window.Map_QM.getObjectAngle &&
shockmanStore.SET_LIST(window.Map_QM.getObjectAngle(device.value.targetInfoList.filter(({ status }) => status === 1)).filter(({ cost }) => cost))
shockmanStore.SET_INTERVAL_TIMER(getIntervalTimer())
if (list.value.length) {
sendMsgByInfo(list.value[index.value])
}
}
export const playShockmanByNav = ({ progText1, progDist, progAngel }) => {
try {
const store = useStore()
const { device } = storeToRefs(store)
if (!(device.value.machineTypeName === '指路机' && device.value.targetInfoList && device.value.controlInfo)) {
return
}
const shockmanStore = useShockmanStore()
const { intervalTimer, playTimer } = storeToRefs(shockmanStore)
if (intervalTimer.value) {
clearInterval(intervalTimer.value)
shockmanStore.SET_INTERVAL_TIMER(0)
}
if (playTimer.value) {
clearTimeout(playTimer.value)
}
shockmanStore.SET_PLAY_TIMER(
setTimeout(() => {
shockmanStore.SET_INTERVAL_TIMER(getIntervalTimer())
}, 60000)
)
sendMsg2Shockman({ progMode: '1', progText1, progText2: '由此方向向前', progDist, progAngel })
} catch (error) {
console.log('指路机播放导航信息失败', error)
}
}
export const resetIntervalTimer = () => {
const store = useStore()
const { device } = storeToRefs(store)
if (!(device.value.machineTypeName === '指路机' && device.value.targetInfoList && device.value.controlInfo)) {
return
}
const shockmanStore = useShockmanStore()
const { intervalTimer } = storeToRefs(shockmanStore)
if (intervalTimer.value) {
clearInterval(intervalTimer.value)
}
shockmanStore.SET_INTERVAL_TIMER(getIntervalTimer())
}

3
src/store/root/getters.js

@ -50,3 +50,6 @@ export const currentFloorShopMap = ({ currentFloor: device, shopList, mapData })
return { ...acc, [shop.shopCode]: result } return { ...acc, [shop.shopCode]: result }
}, {}) }, {})
} }
export const device = ({ currentFloor }) => {
return currentFloor
}

27
src/views/Brand/Brand.vue

@ -34,6 +34,7 @@ import { hideMapDialog, setShopActive, setShopInactive } from '@/composables/use
import MapControl from '@/components/MapControl/MapControl.vue' import MapControl from '@/components/MapControl/MapControl.vue'
import { RESET, DIRECTION } from '@/components/MapControl/list' import { RESET, DIRECTION } from '@/components/MapControl/list'
import { useMediaQuery } from '@vueuse/core' import { useMediaQuery } from '@vueuse/core'
import { isZhiluji, playShockmanByNav } from '@/composables/useShockman'
const store = useStore() const store = useStore()
const storeRefs = storeToRefs(store) const storeRefs = storeToRefs(store)
@ -69,8 +70,18 @@ onBeforeUnmount(() => {
function handleShop(item) { function handleShop(item) {
if (shop.value?.shopCode === item.shopCode || shopPicsMap.value[item.shopCode]) { if (shop.value?.shopCode === item.shopCode || shopPicsMap.value[item.shopCode]) {
if (showMap.value) { if (showMap.value) {
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 })
if (shop.value)
window.Map_QM.pathNode({ floor: shop.value.floorOrder, node: shop.value.yaxis }, ({ angle, cost }) => {
if (isZhiluji()) {
playShockmanByNav({ progText1: shop.value.shopName, progAngel: String(angle), progDist: cost + '米' })
}
})
else
window.Map_QM.pathNode({ floor: item.floorOrder, node: item.yaxis }, ({ angle, cost }) => {
if (isZhiluji()) {
playShockmanByNav({ progText1: item.shopName, progAngel: String(angle), progDist: cost + '米' })
}
})
} else store.SET_SHOW_MAP(true) } else store.SET_SHOW_MAP(true)
} }
mapIdx.value = -1 mapIdx.value = -1
@ -113,7 +124,11 @@ watch(showMap, v => {
window?.Map_QM?.startRender() window?.Map_QM?.startRender()
if (shop.value) { if (shop.value) {
store.SET_SHOW_MAP(true) store.SET_SHOW_MAP(true)
window.Map_QM.pathNode({ floor: shop.value.floorOrder, node: shop.value.yaxis })
window.Map_QM.pathNode({ floor: shop.value.floorOrder, node: shop.value.yaxis }, ({ angle, cost }) => {
if (isZhiluji()) {
playShockmanByNav({ progText1: shop.value.shopName, progAngel: String(angle), progDist: cost + '米' })
}
})
} }
} else { } else {
window?.Map_QM?.cancelRender() window?.Map_QM?.cancelRender()
@ -125,7 +140,11 @@ watch(shop, nxt => {
setShopInactive() setShopInactive()
} else if (nxt && showMap.value) { } else if (nxt && showMap.value) {
setShopActive(nxt) setShopActive(nxt)
window.Map_QM.pathNode({ floor: nxt.floorOrder, node: nxt.yaxis })
window.Map_QM.pathNode({ floor: nxt.floorOrder, node: nxt.yaxis }, ({ angle, cost }) => {
if (isZhiluji()) {
playShockmanByNav({ progText1: nxt.shopName, progAngel: String(angle), progDist: cost + '米' })
}
})
} }
}) })
</script> </script>

19
src/views/Guide/Guide.vue

@ -95,6 +95,7 @@ import ScrollView from '@/base/ScrollView/ScrollView.vue'
import { useMediaQuery } from '@vueuse/core' import { useMediaQuery } from '@vueuse/core'
import MapControl from '@/components/MapControl/MapControl.vue' import MapControl from '@/components/MapControl/MapControl.vue'
import { RESET, DIRECTION } from '@/components/MapControl/list' import { RESET, DIRECTION } from '@/components/MapControl/list'
import { isZhiluji, playShockmanByNav } from '@/composables/useShockman'
const isH = useMediaQuery('(min-aspect-ratio: 1/1)') const isH = useMediaQuery('(min-aspect-ratio: 1/1)')
@ -174,7 +175,11 @@ watch(shop, nxt => {
if (floor.floorOrder !== nxt.floorOrder) { if (floor.floorOrder !== nxt.floorOrder) {
filterAboutCurrentInfo(false) filterAboutCurrentInfo(false)
} }
window.Map_QM.pathNode({ floor: nxt.floorOrder, node: nxt.yaxis })
window.Map_QM.pathNode({ floor: nxt.floorOrder, node: nxt.yaxis }, ({ angle, cost }) => {
if (isZhiluji()) {
playShockmanByNav({ progText1: nxt.shopName, progAngel: String(angle), progDist: cost + '米' })
}
})
} }
}) })
@ -227,7 +232,11 @@ function filterAboutCurrentInfo(needShowFloor = true) {
window.Map_QM.showFloor(floorOrder, () => { window.Map_QM.showFloor(floorOrder, () => {
if (shop.value) { if (shop.value) {
setShopActive(shop.value) setShopActive(shop.value)
window.Map_QM.pathNode({ floor: shop.value.floorOrder, node: shop.value.yaxis })
window.Map_QM.pathNode({ floor: shop.value.floorOrder, node: shop.value.yaxis }, ({ angle, cost }) => {
if (isZhiluji()) {
playShockmanByNav({ progText1: shop.value.shopName, progAngel: String(angle), progDist: cost + '米' })
}
})
} else if (facility.value) { } else if (facility.value) {
handleFacility(facility.value) handleFacility(facility.value)
} }
@ -264,7 +273,11 @@ watch(facility, fac => {
else hideMapDialog() else hideMapDialog()
}) })
const handleFacility = fac => { const handleFacility = fac => {
window.Map_QM.pathNode(fac)
window.Map_QM.pathNode(fac, ({ angle, cost }) => {
if (isZhiluji()) {
playShockmanByNav({ progText1: fac.title, progAngel: String(angle), progDist: cost + '米' })
}
})
} }
</script> </script>

Loading…
Cancel
Save