diff --git a/src/composables/useShockman.js b/src/composables/useShockman.js index 4644be7..685ccfc 100644 --- a/src/composables/useShockman.js +++ b/src/composables/useShockman.js @@ -7,6 +7,7 @@ import MD5 from 'crypto-js/md5' const useShockmanStore = defineStore('shockman', { state: () => ({ list: [], + endMap: {}, intervalTimer: 0, playTimer: 0, index: 0 @@ -15,6 +16,9 @@ const useShockmanStore = defineStore('shockman', { SET_LIST(list) { this.list = list }, + SET_END_MAP(endMap) { + this.endMap = endMap + }, SET_INTERVAL_TIMER(intervalTimer) { this.intervalTimer = intervalTimer }, @@ -96,8 +100,9 @@ export const useShockman = () => { } 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)) + const { targetInfoList } = device.value + shockmanStore.SET_END_MAP(targetInfoList.reduce((acc, nxt) => ({ ...acc, [nxt.name]: nxt }), {})) + window.Map_QM.getObjectAngle && shockmanStore.SET_LIST(window.Map_QM.getObjectAngle(targetInfoList.filter(({ status }) => status === 1)).filter(({ cost }) => cost)) shockmanStore.SET_INTERVAL_TIMER(getIntervalTimer()) if (list.value.length) { @@ -113,7 +118,7 @@ export const playShockmanByNav = ({ progText1, progDist, progAngel }) => { return } const shockmanStore = useShockmanStore() - const { intervalTimer, playTimer } = storeToRefs(shockmanStore) + const { intervalTimer, playTimer, endMap } = storeToRefs(shockmanStore) if (intervalTimer.value) { clearInterval(intervalTimer.value) shockmanStore.SET_INTERVAL_TIMER(0) @@ -126,7 +131,12 @@ export const playShockmanByNav = ({ progText1, progDist, progAngel }) => { shockmanStore.SET_INTERVAL_TIMER(getIntervalTimer()) }, 60000) ) - sendMsg2Shockman({ progMode: '1', progText1, progText2: '由此方向向前', progDist, progAngel }) + + const info = endMap.value[progText1] + if (info) console.log('匹配到指路机目标', info) + const progMode = info ? String(info.playWay) : '1' + const progText2 = info ? (info.playWay === 1 || info.playWay === 4 ? info.twoText : ' ') : '由此方向向前' + sendMsg2Shockman({ progMode, progText1, progText2, progDist, progAngel }) } catch (error) { console.log('指路机播放导航信息失败', error) }