Showing
4 changed files
with
97 additions
and
17 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-07-27 11:04:04 | 2 | * @Date: 2023-07-27 11:04:04 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-08-02 07:17:28 | 4 | + * @LastEditTime: 2023-08-04 16:00:11 |
| 5 | * @FilePath: /map-demo/src/components/Floor/index.vue | 5 | * @FilePath: /map-demo/src/components/Floor/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -44,7 +44,7 @@ | ... | @@ -44,7 +44,7 @@ |
| 44 | :class="['level', 'level--' + (index + 1)]"> | 44 | :class="['level', 'level--' + (index + 1)]"> |
| 45 | <div v-html="level.svg"></div> | 45 | <div v-html="level.svg"></div> |
| 46 | <div class="level__pins"> | 46 | <div class="level__pins"> |
| 47 | - <a v-for="(item, index) in level.pin" :key="index" class="pin" :style="item.style" | 47 | + <a @click="clickPin(item, $event)" v-for="(item, index) in level.pin" :key="index" class="pin" :style="item.style" |
| 48 | :data-category="item.category" :data-space="item.space"> | 48 | :data-category="item.category" :data-space="item.space"> |
| 49 | <span class="pin__icon"> | 49 | <span class="pin__icon"> |
| 50 | <svg class="icon icon--pin"> | 50 | <svg class="icon icon--pin"> |
| ... | @@ -69,10 +69,8 @@ | ... | @@ -69,10 +69,8 @@ |
| 69 | <van-icon name="cross" size="1.5rem" /> | 69 | <van-icon name="cross" size="1.5rem" /> |
| 70 | </div> | 70 | </div> |
| 71 | <div style="margin: 0 1rem"> | 71 | <div style="margin: 0 1rem"> |
| 72 | - <div style="font-size: 1.25rem; margin-bottom: 1rem;">大雄宝殿</div> | 72 | + <div style="font-size: 1.25rem; margin-bottom: 1rem;">{{ popup_title }}</div> |
| 73 | - <div> | 73 | + <div> {{ popup_content }} </div> |
| 74 | - 大雄宝殿是寺院的中心建筑,兴建于清末民初时期。重檐歇山,面阔七楹,飞檐翘角,气势雄伟,风格挺秀。梁枋均施苏式彩绘,典雅富丽,绚丽夺目。 | ||
| 75 | - </div> | ||
| 76 | </div> | 74 | </div> |
| 77 | </van-popup> | 75 | </van-popup> |
| 78 | 76 | ||
| ... | @@ -109,6 +107,8 @@ export default { | ... | @@ -109,6 +107,8 @@ export default { |
| 109 | show_popup: false, | 107 | show_popup: false, |
| 110 | show_search_popup: false, | 108 | show_search_popup: false, |
| 111 | level_list: Data, | 109 | level_list: Data, |
| 110 | + popup_title: '', | ||
| 111 | + popup_content: '', | ||
| 112 | search_list: [ | 112 | search_list: [ |
| 113 | { | 113 | { |
| 114 | title: '1-客房', | 114 | title: '1-客房', |
| ... | @@ -144,12 +144,6 @@ export default { | ... | @@ -144,12 +144,6 @@ export default { |
| 144 | } | 144 | } |
| 145 | }, | 145 | }, |
| 146 | async mounted() { | 146 | async mounted() { |
| 147 | - // 绑定选择点后回调 | ||
| 148 | - $('.level__pins').children('.pin').on('click', (evt) => { | ||
| 149 | - this.clearPinShow(); | ||
| 150 | - $(evt.currentTarget).addClass('pin--active'); | ||
| 151 | - this.show_popup = true; | ||
| 152 | - }); | ||
| 153 | }, | 147 | }, |
| 154 | methods: { | 148 | methods: { |
| 155 | clearPinShow() { | 149 | clearPinShow() { |
| ... | @@ -224,7 +218,15 @@ export default { | ... | @@ -224,7 +218,15 @@ export default { |
| 224 | onClosePopup() { | 218 | onClosePopup() { |
| 225 | this.show_popup = false; | 219 | this.show_popup = false; |
| 226 | this.clearPinShow(); | 220 | this.clearPinShow(); |
| 227 | - } | 221 | + }, |
| 222 | + clickPin (item, evt) { // 点击pin操作 | ||
| 223 | + this.clearPinShow(); | ||
| 224 | + $(evt.target).parents('a.pin').addClass('pin--active'); | ||
| 225 | + this.show_popup = true; | ||
| 226 | + // 打开 pin 详情信息 | ||
| 227 | + this.popup_title = item?.affix?.title; | ||
| 228 | + this.popup_content = item?.affix?.content; | ||
| 229 | + }, | ||
| 228 | } | 230 | } |
| 229 | } | 231 | } |
| 230 | </script> | 232 | </script> | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2023-08-01 13:55:03 | 2 | * @Date: 2023-08-01 13:55:03 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-08-01 16:12:24 | 4 | + * @LastEditTime: 2023-08-04 16:06:07 |
| 5 | * @FilePath: /map-demo/src/components/Floor/pin.js | 5 | * @FilePath: /map-demo/src/components/Floor/pin.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -336,10 +336,14 @@ const testInfo = [ | ... | @@ -336,10 +336,14 @@ const testInfo = [ |
| 336 | pin: [ | 336 | pin: [ |
| 337 | { | 337 | { |
| 338 | id: 'pin--4-1', | 338 | id: 'pin--4-1', |
| 339 | - category: 1, | 339 | + category: 2, |
| 340 | space: 4.01, | 340 | space: 4.01, |
| 341 | icon: 'tomato', | 341 | icon: 'tomato', |
| 342 | style: { top: '55vmin', left: '21vmin' }, | 342 | style: { top: '55vmin', left: '21vmin' }, |
| 343 | + affix: { | ||
| 344 | + title: '宿舍401', | ||
| 345 | + content: '休息室', | ||
| 346 | + }, | ||
| 343 | }, | 347 | }, |
| 344 | { | 348 | { |
| 345 | id: 'pin--4-2', | 349 | id: 'pin--4-2', |
| ... | @@ -347,6 +351,10 @@ const testInfo = [ | ... | @@ -347,6 +351,10 @@ const testInfo = [ |
| 347 | space: 4.02, | 351 | space: 4.02, |
| 348 | icon: 'cinema', | 352 | icon: 'cinema', |
| 349 | style: { top: '18vmin', left: '20vmin' }, | 353 | style: { top: '18vmin', left: '20vmin' }, |
| 354 | + affix: { | ||
| 355 | + title: '宿舍402', | ||
| 356 | + content: '休息室', | ||
| 357 | + }, | ||
| 350 | }, | 358 | }, |
| 351 | { | 359 | { |
| 352 | id: 'pin--4-3', | 360 | id: 'pin--4-3', |
| ... | @@ -354,6 +362,10 @@ const testInfo = [ | ... | @@ -354,6 +362,10 @@ const testInfo = [ |
| 354 | space: 4.03, | 362 | space: 4.03, |
| 355 | icon: 'paint-brush', | 363 | icon: 'paint-brush', |
| 356 | style: { top: '21vmin', left: '88vmin' }, | 364 | style: { top: '21vmin', left: '88vmin' }, |
| 365 | + affix: { | ||
| 366 | + title: '宿舍403', | ||
| 367 | + content: '休息室', | ||
| 368 | + }, | ||
| 357 | }, | 369 | }, |
| 358 | { | 370 | { |
| 359 | id: 'pin--4-4', | 371 | id: 'pin--4-4', |
| ... | @@ -361,6 +373,10 @@ const testInfo = [ | ... | @@ -361,6 +373,10 @@ const testInfo = [ |
| 361 | space: 4.04, | 373 | space: 4.04, |
| 362 | icon: 'modx', | 374 | icon: 'modx', |
| 363 | style: { top: '52vmin', left: '74vmin' }, | 375 | style: { top: '52vmin', left: '74vmin' }, |
| 376 | + affix: { | ||
| 377 | + title: '宿舍404', | ||
| 378 | + content: '休息室', | ||
| 379 | + }, | ||
| 364 | }, | 380 | }, |
| 365 | { | 381 | { |
| 366 | id: 'pin--4-5', | 382 | id: 'pin--4-5', |
| ... | @@ -368,6 +384,10 @@ const testInfo = [ | ... | @@ -368,6 +384,10 @@ const testInfo = [ |
| 368 | space: 4.05, | 384 | space: 4.05, |
| 369 | icon: 'droplet', | 385 | icon: 'droplet', |
| 370 | style: { top: '33vmin', left: '38vmin' }, | 386 | style: { top: '33vmin', left: '38vmin' }, |
| 387 | + affix: { | ||
| 388 | + title: '宿舍405', | ||
| 389 | + content: '休息室', | ||
| 390 | + }, | ||
| 371 | }, | 391 | }, |
| 372 | { | 392 | { |
| 373 | id: 'pin--4-6', | 393 | id: 'pin--4-6', |
| ... | @@ -375,6 +395,10 @@ const testInfo = [ | ... | @@ -375,6 +395,10 @@ const testInfo = [ |
| 375 | space: 4.06, | 395 | space: 4.06, |
| 376 | icon: 'cupcake', | 396 | icon: 'cupcake', |
| 377 | style: { top: '39vmin', left: '56vmin' }, | 397 | style: { top: '39vmin', left: '56vmin' }, |
| 398 | + affix: { | ||
| 399 | + title: '宿舍406', | ||
| 400 | + content: '休息室', | ||
| 401 | + }, | ||
| 378 | }, | 402 | }, |
| 379 | { | 403 | { |
| 380 | id: 'pin--4-7', | 404 | id: 'pin--4-7', |
| ... | @@ -382,6 +406,10 @@ const testInfo = [ | ... | @@ -382,6 +406,10 @@ const testInfo = [ |
| 382 | space: 4.07, | 406 | space: 4.07, |
| 383 | icon: 'leafcircle', | 407 | icon: 'leafcircle', |
| 384 | style: { top: '58vmin', left: '10vmin' }, | 408 | style: { top: '58vmin', left: '10vmin' }, |
| 409 | + affix: { | ||
| 410 | + title: '宿舍407', | ||
| 411 | + content: '休息室', | ||
| 412 | + }, | ||
| 385 | }, | 413 | }, |
| 386 | ], | 414 | ], |
| 387 | }, | 415 | }, | ... | ... |
This diff could not be displayed because it is too large.
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-05-19 14:54:27 | 2 | * @Date: 2023-05-19 14:54:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-07-31 18:14:27 | 4 | + * @LastEditTime: 2023-08-04 15:34:12 |
| 5 | * @FilePath: /map-demo/src/views/inner.vue | 5 | * @FilePath: /map-demo/src/views/inner.vue |
| 6 | * @Description: 内部地图主体页面 | 6 | * @Description: 内部地图主体页面 |
| 7 | --> | 7 | --> |
| ... | @@ -277,7 +277,7 @@ export default { | ... | @@ -277,7 +277,7 @@ export default { |
| 277 | point_range: [ // 景区范围经纬度 | 277 | point_range: [ // 景区范围经纬度 |
| 278 | [120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005] | 278 | [120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005] |
| 279 | ], | 279 | ], |
| 280 | - show_floor_popup: false, | 280 | + show_floor_popup: true, |
| 281 | } | 281 | } |
| 282 | }, | 282 | }, |
| 283 | async mounted() { | 283 | async mounted() { |
| ... | @@ -392,6 +392,10 @@ export default { | ... | @@ -392,6 +392,10 @@ export default { |
| 392 | this.map.setZoomAndCenter(this.defaultZoom, this.defaultCenter); | 392 | this.map.setZoomAndCenter(this.defaultZoom, this.defaultCenter); |
| 393 | }, 100); | 393 | }, 100); |
| 394 | this.removeNavRoute(); | 394 | this.removeNavRoute(); |
| 395 | + // 测试选择人员后轮询 | ||
| 396 | + if (id === 'members') { | ||
| 397 | + this.testPolling() | ||
| 398 | + } | ||
| 395 | }, | 399 | }, |
| 396 | loadMaker (id) { | 400 | loadMaker (id) { |
| 397 | var zoomStyleMapping = { 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0, 20: 0 }; | 401 | var zoomStyleMapping = { 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0, 20: 0 }; |
| ... | @@ -1197,6 +1201,52 @@ export default { | ... | @@ -1197,6 +1201,52 @@ export default { |
| 1197 | }, | 1201 | }, |
| 1198 | onClose () { | 1202 | onClose () { |
| 1199 | this.show_floor_popup = false; | 1203 | this.show_floor_popup = false; |
| 1204 | + }, | ||
| 1205 | + testPolling () { // 测试轮询 | ||
| 1206 | + let index = 1; // 控制何时停止轮询 | ||
| 1207 | + let timer = 0; // 实现中断轮询 | ||
| 1208 | + | ||
| 1209 | + // syncPromise 模拟异步请求 | ||
| 1210 | + const syncPromise = () => { | ||
| 1211 | + return new Promise(resolve => { | ||
| 1212 | + setTimeout(() => { | ||
| 1213 | + console.log(`第 ${index} 次请求`); | ||
| 1214 | + resolve(index < 5 ? true : false); // 当进行 5 次异步请求后,会返回 false 表示拿到数据分析结果,停止数据查询轮询: | ||
| 1215 | + index++; | ||
| 1216 | + }, 50); | ||
| 1217 | + }); | ||
| 1218 | + } | ||
| 1219 | + | ||
| 1220 | + // pollingPromise 作为 sleep 睡眠函数使用,去控制轮询的间隔时间,并在指定时间执行异步请求 | ||
| 1221 | + const pollingPromise = () => { | ||
| 1222 | + return new Promise(resolve => { | ||
| 1223 | + timer = setTimeout(async () => { | ||
| 1224 | + const result = await syncPromise(); | ||
| 1225 | + resolve(result); | ||
| 1226 | + }, 1000); | ||
| 1227 | + }); | ||
| 1228 | + } | ||
| 1229 | + | ||
| 1230 | + // startPolling 作为开始轮询的入口 | ||
| 1231 | + const startPolling = async () => { | ||
| 1232 | + // 清除进行中的轮询,重新开启计时轮询 | ||
| 1233 | + clearTimeout(timer); // !!! 注意:清除计时器后,会导致整个 async/await 链路中断,若计时器的位置下方还存在代码,将不会执行。 | ||
| 1234 | + index = 1; | ||
| 1235 | + // 立刻执行一次异步请求 | ||
| 1236 | + let needPolling = await syncPromise(); | ||
| 1237 | + // 根据异步请求结果,判断是否需要开启计时轮询 | ||
| 1238 | + while (needPolling) { | ||
| 1239 | + needPolling = await pollingPromise(); | ||
| 1240 | + } | ||
| 1241 | + console.log('轮询请求处理完成!'); // 若异步请求被 clearTimeout(timer),这里不会被执行打印输出。 | ||
| 1242 | + } | ||
| 1243 | + | ||
| 1244 | + const start = async () => { | ||
| 1245 | + await startPolling(); | ||
| 1246 | + console.log('若异步请求被 clearTimeout(timer),这里将不会被执行'); | ||
| 1247 | + } | ||
| 1248 | + | ||
| 1249 | + start(); | ||
| 1200 | } | 1250 | } |
| 1201 | } | 1251 | } |
| 1202 | } | 1252 | } | ... | ... |
-
Please register or login to post a comment