Quellcode durchsuchen

fix(choose-seat): 修复canvas动画帧及初始化逻辑兼容性问题

- raf和cancelRaf方法增加多环境兼容性判断,支持canvas和全局函数调用
- 取消debug模式打印,移除CanvasSeatmap.vue中无用console.log
- 优化CanvasSeatmap.vue初始化逻辑,添加必要空行提升代码规范
- 修正config/index.ts中注释代码的调整,保持代码整洁
- 移除manifest.json末尾多余空行
zhangtao vor 6 Tagen
Ursprung
Commit
360b3a5845

+ 2 - 2
src/config/index.ts

@@ -44,9 +44,9 @@ function handleEnvVersion() {
   // #ifdef H5
   const mode = import.meta.env.MODE
   const h5Server = {
-    // development: 'http://47.109.84.152:8081',
+    development: 'http://47.109.84.152:8081',
     // development: 'http://192.168.0.157:8080',
-    development: 'http://192.168.1.21:8080',
+    // development: 'http://192.168.1.21:8080',
     production: 'https://smqjh.api.zswlgz.com',
   }
   return h5Server[mode as 'development' | 'production']

+ 1 - 2
src/subPack-film/choose-seat/components/pages/CanvasSeatmap.vue

@@ -25,8 +25,6 @@ export default {
     async init({ seatList, options }) {
       this.seatList = seatList
       this.options = options
-      console.log(options)
-
       // #ifdef MP-WEIXIN || H5 || MP-ALIPAY
       this.onCanvasReady()
       // #endif
@@ -48,6 +46,7 @@ export default {
         canvas.height = canvasHeight * pixelRatio
         ctx.scale(pixelRatio, pixelRatio)
         // #endif
+
         this.seatmapInstance = new Seatmap({
           canvas,
           seatList,

+ 14 - 6
src/subPack-film/choose-seat/components/pages/canvasOperator.js

@@ -5,15 +5,23 @@ export default class CanvasOperator {
 
   /* ---------- RAF 封装 ---------- */
   raf(cb) {
-    // #ifdef MP-WEIXIN || MP-ALIPAY
-    return this.canvas.requestAnimationFrame(cb)
-    // #endif
+    if (typeof this.canvas.requestAnimationFrame === 'function') {
+      return this.canvas.requestAnimationFrame(cb)
+    }
+    if (typeof requestAnimationFrame === 'function') {
+      return requestAnimationFrame(cb)
+    }
+    return setTimeout(cb, 16)
   }
 
   cancelRaf(id) {
-    // #ifdef MP-WEIXIN || MP-ALIPAY
-    return this.canvas.cancelAnimationFrame(id)
-    // #endif
+    if (typeof this.canvas.cancelAnimationFrame === 'function') {
+      return this.canvas.cancelAnimationFrame(id)
+    }
+    if (typeof cancelAnimationFrame === 'function') {
+      return cancelAnimationFrame(id)
+    }
+    return clearTimeout(id)
   }
 
   /* ---------- 图片加载 ---------- */