You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
60 lines
1.8 KiB
import { useRouter } from 'vue-router'
|
|
import { useStore } from '@/store/root'
|
|
import { uniqBy } from '@/utils/utils'
|
|
|
|
export const useInitMap = function () {
|
|
const store = useStore()
|
|
|
|
//初始化地图
|
|
// onReady(store.currentFloor, () => {
|
|
// const facilityList = window.Map_QM.getAllIcon().flat(Infinity)
|
|
//
|
|
// const list = facilityList.map(item => {
|
|
// item.imgUrl.replace('./', '/')
|
|
// return item
|
|
// })
|
|
//
|
|
// window.Map_QM.addEventListener('shop', onClickShop, false)
|
|
//
|
|
// store.SET_FACILITY_LIST(uniqBy(list, 'type'))
|
|
//
|
|
// window.Map_QM.renderer.domElement.addEventListener('webglcontextlost', onContextLost)
|
|
// })
|
|
}
|
|
|
|
//点击地图店铺box
|
|
function onClickShop(event) {
|
|
const store = useStore()
|
|
store.shop.houseNum && store.shop.formatColor && window.Map_QM.changeMapIPState(store.shop.houseNum, store.shop.formatColor)
|
|
|
|
if (event.data) {
|
|
showMapDialog()
|
|
window.Map_QM.addElementLabel(document.getElementById('shopInfo'), event.data.xaxis, event.data.yaxis)
|
|
store.SET_SHOP(event.data.shopData)
|
|
window.Map_QM.changeMapIPState(event.data.shopNum, '#AD8164')
|
|
} else {
|
|
hideMapDialog()
|
|
}
|
|
}
|
|
|
|
//地图弹框消失
|
|
export function hideMapDialog() {
|
|
document.getElementById('shopInfo').style.visibility = 'hidden'
|
|
}
|
|
|
|
//显示地图弹框
|
|
function showMapDialog() {
|
|
document.getElementById('shopInfo').style.visibility = 'visible'
|
|
}
|
|
|
|
//地图初始化
|
|
function onReady({ floorOrder, location, angle }, callback) {
|
|
window.Config.getInstance(callback, 0, floorOrder, location, angle) //设备楼栋, 设备楼层, 点位(机器点位直连主干道而不在主干道上), 方向 84 85
|
|
}
|
|
|
|
//监听地图上下文丢失 刷新页面
|
|
function onContextLost() {
|
|
const router = useRouter()
|
|
router.push('/')
|
|
location.reload()
|
|
}
|
|
|