chenlei vor 1 Jahr
Ursprung
Commit
cbf3ee6251
3 geänderte Dateien mit 41 neuen und 25 gelöschten Zeilen
  1. 1 1
      config/index.js
  2. 39 23
      pages/index/index.js
  3. 1 1
      project.private.config.json

+ 1 - 1
config/index.js

@@ -1,4 +1,4 @@
-export const API_BASE_URL = "wss://sxb-socket.4dkankan.com";
+export const API_BASE_URL = "wss://sxbv2-socket.4dkankan.com";
 // export const API_BASE_URL = "ws://192.168.0.76:14000";
 // ws://120.24.252.95:14000
 // wss://sxb-socket.4dkankan.com

+ 39 - 23
pages/index/index.js

@@ -124,7 +124,7 @@ VueLikePage([], {
         daojishi: 0,
         isShot: false,
         isRecord: false,
-        currentScene: 1,
+        currentScene: this.data.scenes[0] ? this.data.scenes[0].id : 1,
         recordjishi: 10,
       });
       if (!noswitch) {
@@ -173,24 +173,29 @@ VueLikePage([], {
     onLoad: function (options) {
       console.log("options: ", options);
 
-      if (options.machineid) {
-        app.id = options.machineid;
-      }
+      wx.showLoading({
+        title: "资源加载中",
+      });
 
-      this.getData(options.projectid);
+      if (options && options.scene) {
+        const [machineid, authorCode] = options.scene.split("_");
 
-      // 1、获取二维码传参
-      if (options.authorCode) {
-        this.setData({
-          authorCode: decodeURIComponent(options.authorCode),
-        });
-        this.start(this.data.authorCode);
-      }
+        app.id = machineid;
+        // 1、获取二维码传参
+        if (authorCode) {
+          this.setData({
+            authorCode: decodeURIComponent(authorCode),
+          });
+          this.start(this.data.authorCode);
+        }
 
-      if (wx.getStorageSync("records")) {
-        this.setData({
-          records: JSON.parse(wx.getStorageSync("records")),
-        });
+        if (wx.getStorageSync("records")) {
+          this.setData({
+            records: JSON.parse(wx.getStorageSync("records")),
+          });
+        }
+      } else {
+        this.getData();
       }
 
       // wx.setStorageSync('records', JSON.stringify(this.data.records))
@@ -210,11 +215,7 @@ VueLikePage([], {
       // })
     },
 
-    getData(prjId = "ZHS2305758-1") {
-      wx.showLoading({
-        title: "资源加载中",
-      });
-
+    getData(prjId = "ZHS2305758-1", scenes) {
       this.setData({
         cdn_url: CDN_URL + "/" + prjId,
       });
@@ -223,10 +224,18 @@ VueLikePage([], {
         url:
           `${VIDEO_BASE_URL}project/4dage-sxb/${prjId}/config.json?t=` +
           new Date().getTime(),
-        success: ({ data: { scenes, title, ...rest } }) => {
+        success: ({ data: { scenes: sourceScenes, title, ...rest } }) => {
+          let scenesData = sourceScenes;
+          if (scenes) {
+            // 只展示 scenes 中存在的id
+            scenesData = scenes.map((id) =>
+              sourceScenes.find((scene) => id === scene.id)
+            );
+          }
           this.setData(
             {
-              scenes: scenes,
+              currentScene: scenesData[0].id,
+              scenes: scenesData,
               info: rest,
             },
             () => {
@@ -479,6 +488,13 @@ VueLikePage([], {
             this.disconnect();
             // app.showAlert("网络异常,请稍后再试");
           }
+
+          try {
+            const res = JSON.parse(data);
+            this.getData(res.projectID, res.scenes);
+          } catch (err) {
+            console.log(err);
+          }
           console.log(data, "data");
         }, authorCode);
       });

+ 1 - 1
project.private.config.json

@@ -9,7 +9,7 @@
         {
           "name": "pages/index/index",
           "pathName": "pages/index/index",
-          "query": "authorCode=12345678&projectId=ZHS2305758-1&machineid=309c23aeaf7a",
+          "query": "scene=309c23aeaf7a_yW0zeyyxxD9ZDWYa",
           "launchMode": "default",
           "scene": null
         },