|
@@ -57,7 +57,7 @@ |
|
@@ -57,7 +57,7 @@ |
57
|
</div>
|
57
|
</div>
|
58
|
<div v-if="deviceDetail?.deviceInfo?.address" class="mt-4">
|
58
|
<div v-if="deviceDetail?.deviceInfo?.address" class="mt-4">
|
59
|
<p>设备位置</p>
|
59
|
<p>设备位置</p>
|
60
|
- <div ref="wrapRef" style="height: 550px; width: 100%"></div>
|
60
|
+ <div ref="mapWrapRef" style="height: 550px; width: 100%"></div>
|
61
|
</div>
|
61
|
</div>
|
62
|
</div>
|
62
|
</div>
|
63
|
</template>
|
63
|
</template>
|
|
@@ -65,7 +65,7 @@ |
|
@@ -65,7 +65,7 @@ |
65
|
import { defineComponent, ref, unref, nextTick } from 'vue';
|
65
|
import { defineComponent, ref, unref, nextTick } from 'vue';
|
66
|
import { Image, Tooltip } from 'ant-design-vue';
|
66
|
import { Image, Tooltip } from 'ant-design-vue';
|
67
|
import { descSchema } from '../../config/detail.config';
|
67
|
import { descSchema } from '../../config/detail.config';
|
68
|
- import { useScript } from '/@/hooks/web/useScript';
|
68
|
+ import { useAsyncScript } from '/@/hooks/web/useAsyncScript';
|
69
|
import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
|
69
|
import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
|
70
|
import { useMessage } from '/@/hooks/web/useMessage';
|
70
|
import { useMessage } from '/@/hooks/web/useMessage';
|
71
|
import { BAI_DU_MAP_URL } from '/@/utils/fnUtils';
|
71
|
import { BAI_DU_MAP_URL } from '/@/utils/fnUtils';
|
|
@@ -77,6 +77,7 @@ |
|
@@ -77,6 +77,7 @@ |
77
|
import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
|
77
|
import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
|
78
|
|
78
|
|
79
|
import wz from '/@/assets/images/wz.png';
|
79
|
import wz from '/@/assets/images/wz.png';
|
|
|
80
|
+ import { useAsyncQueue } from '../../../localtion/useAsyncQueue';
|
80
|
export default defineComponent({
|
81
|
export default defineComponent({
|
81
|
components: {
|
82
|
components: {
|
82
|
Image,
|
83
|
Image,
|
|
@@ -101,13 +102,30 @@ |
|
@@ -101,13 +102,30 @@ |
101
|
});
|
102
|
});
|
102
|
|
103
|
|
103
|
// 地图
|
104
|
// 地图
|
104
|
- const wrapRef = ref<HTMLDivElement | null>(null);
|
|
|
105
|
- const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
|
105
|
+ const mapWrapRef = ref<HTMLDivElement>();
|
106
|
|
106
|
|
107
|
- async function initMap(longitude, latitude, address) {
|
|
|
108
|
- await toPromise();
|
107
|
+ const { executeFlag, setTask } = useAsyncQueue();
|
|
|
108
|
+ const { toPromise } = useAsyncScript({ src: BAI_DU_MAP_URL });
|
|
|
109
|
+
|
|
|
110
|
+ async function initMap(longitude: number, latitude: number, address: string) {
|
|
|
111
|
+ if (!(window as any).BMap) {
|
|
|
112
|
+ setTask(() => markerMap(longitude, latitude, address));
|
|
|
113
|
+ let interval: Nullable<NodeJS.Timer> = setInterval(() => {
|
|
|
114
|
+ if ((window as any).BMap) {
|
|
|
115
|
+ executeFlag.value = true;
|
|
|
116
|
+ clearInterval(interval!);
|
|
|
117
|
+ interval = null;
|
|
|
118
|
+ }
|
|
|
119
|
+ }, 300);
|
|
|
120
|
+ await toPromise();
|
|
|
121
|
+ return;
|
|
|
122
|
+ }
|
|
|
123
|
+ markerMap(longitude, latitude, address);
|
|
|
124
|
+ }
|
|
|
125
|
+
|
|
|
126
|
+ async function markerMap(longitude: number, latitude: number, address: string) {
|
109
|
await nextTick();
|
127
|
await nextTick();
|
110
|
- const wrapEl = unref(wrapRef);
|
128
|
+ const wrapEl = unref(mapWrapRef);
|
111
|
const BMap = (window as any).BMap;
|
129
|
const BMap = (window as any).BMap;
|
112
|
if (!wrapEl) return;
|
130
|
if (!wrapEl) return;
|
113
|
const map = new BMap.Map(wrapEl);
|
131
|
const map = new BMap.Map(wrapEl);
|
|
@@ -132,6 +150,7 @@ |
|
@@ -132,6 +150,7 @@ |
132
|
map.enableScrollWheelZoom(true);
|
150
|
map.enableScrollWheelZoom(true);
|
133
|
map.addOverlay(marker);
|
151
|
map.addOverlay(marker);
|
134
|
}
|
152
|
}
|
|
|
153
|
+
|
135
|
const { createMessage } = useMessage();
|
154
|
const { createMessage } = useMessage();
|
136
|
const { clipboardRef } = useCopyToClipboard();
|
155
|
const { clipboardRef } = useCopyToClipboard();
|
137
|
const copyTbDeviceId = () => {
|
156
|
const copyTbDeviceId = () => {
|
|
@@ -166,7 +185,7 @@ |
|
@@ -166,7 +185,7 @@ |
166
|
const remoteConnectiondGateway = () => {};
|
185
|
const remoteConnectiondGateway = () => {};
|
167
|
|
186
|
|
168
|
return {
|
187
|
return {
|
169
|
- wrapRef,
|
188
|
+ mapWrapRef,
|
170
|
copyTbDeviceId,
|
189
|
copyTbDeviceId,
|
171
|
copyDeviceToken,
|
190
|
copyDeviceToken,
|
172
|
initMap,
|
191
|
initMap,
|