Browse Source

fix:优化

kele 2 years ago
parent
commit
3f36f8704f
1 changed files with 29 additions and 12 deletions
  1. 29 12
      sheep/components/s-live-block/s-live-block.vue

+ 29 - 12
sheep/components/s-live-block/s-live-block.vue

@@ -78,32 +78,49 @@
     return data;
     return data;
   }
   }
   function goRoom(id) {
   function goRoom(id) {
-    // wx.navigateTo({
-    //   url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${id}&custom_params=${customParams}`,
-    // });
+    // #ifdef MP-WEIXIN
+    uni.navigateTo({
+      url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${id}`,
+    });
+    // #endif
+
+    // #ifndef MP-WEIXIN
+    uni.showModal({
+      title: '提示',
+      confirmText: '允许',
+      content: '将打开小程序访问',
+      success: async function (res) {
+        if (res.confirm) {
+          getMpLink();
+        }
+      },
+    });
+    // #endif
+  }
+
+  function goMpLink() {
     // #ifdef H5
     // #ifdef H5
     window.location = state.mpLink;
     window.location = state.mpLink;
     // #endif
     // #endif
     // #ifdef APP-PLUS
     // #ifdef APP-PLUS
     plus.runtime.openURL(state.mpLink);
     plus.runtime.openURL(state.mpLink);
     // #endif
     // #endif
-    // #ifdef MP-WEIXIN
-    wx.navigateTo({
-      url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${id}`,
-    });
-    // #endif
   }
   }
 
 
   async function getMpLink() {
   async function getMpLink() {
-    const { error, data } = await sheep.$api.app.mplive.getMpLink();
-    if (error === 0) {
-      state.mpLink = data;
+    // #ifndef MP-WEIXIN
+    if (state.mpLink === '') {
+      const { error, data } = await sheep.$api.app.mplive.getMpLink();
+      if (error === 0) {
+        state.mpLink = data;
+      }
     }
     }
+    goMpLink();
+    // #endif
   }
   }
 
 
   onMounted(async () => {
   onMounted(async () => {
     state.liveList = await getLiveListByIds(mpliveIds);
     state.liveList = await getLiveListByIds(mpliveIds);
-    getMpLink();
   });
   });
 </script>
 </script>
 <style lang="scss" scoped>
 <style lang="scss" scoped>