Your Name 3 years ago
parent
commit
672069a8bd
1 changed files with 21 additions and 6 deletions
  1. 21
    6
      src/pages/video/liveDetail/index.jsx

+ 21
- 6
src/pages/video/liveDetail/index.jsx View File

15
   const { id } = router.params;
15
   const { id } = router.params;
16
 
16
 
17
   const [data,setData] = useState({})
17
   const [data,setData] = useState({})
18
-  // 直播间凭证
19
-  const livingCodeRef = useRef('6990341961664364915')
18
+  // 直播间信息
19
+  const livingRef = useRef()
20
   
20
   
21
   // 本页面分享或者海报参数
21
   // 本页面分享或者海报参数
22
   const paramsRef = useParams({
22
   const paramsRef = useParams({
40
     queryLiveDetail(id).then(res=>{
40
     queryLiveDetail(id).then(res=>{
41
         setData(res)
41
         setData(res)
42
         if (res?.liveRoomParam) {
42
         if (res?.liveRoomParam) {
43
-          getLivingCode(res.liveRoomParam).then((r) => {
44
-            livingCodeRef.current = r
43
+          getLivingCode(res.liveRoomParam).then((liveInfo) => {
44
+            livingRef.current = liveInfo
45
           })
45
           })
46
         }
46
         }
47
     })
47
     })
48
   };
48
   };
49
 
49
 
50
   const handleLive = () => {
50
   const handleLive = () => {
51
-    if (!livingCodeRef.current) {
51
+    if (!livingRef.current) {
52
       Taro.showToast({
52
       Taro.showToast({
53
         title: '查询直播凭证失败, 请退出重试',
53
         title: '查询直播凭证失败, 请退出重试',
54
         icon: 'none',
54
         icon: 'none',
56
       return;
56
       return;
57
     }
57
     }
58
 
58
 
59
+    // https://work.weixin.qq.com/api/doc/90000/90135/93635
60
+    const { livingCode, status  } =  livingRef.current
61
+
62
+    //
63
+    if (status >= 3) {
64
+      Taro.showToast({
65
+        title: `直播活动已${status === 3 ? '过期' : '取消'}`,
66
+        icon: 'none',
67
+      })
68
+      return;
69
+    }
70
+
71
+    // 如果已经结束的则播放回放
72
+    const replay = status === 2 ? '&replay=1' : ''
73
+
59
     // 跳转到直播
74
     // 跳转到直播
60
     Taro.navigateToMiniProgram({
75
     Taro.navigateToMiniProgram({
61
       // 固定跳转到微信企业直播
76
       // 固定跳转到微信企业直播
62
       appId: 'wx7424030d69bde86e',
77
       appId: 'wx7424030d69bde86e',
63
-      path: `pages/watch/index?living_code=${encodeURIComponent(livingCodeRef.current)}`,
78
+      path: `pages/watch/index?living_code=${encodeURIComponent(livingCode)}${replay}`,
64
     })
79
     })
65
   }
80
   }
66
 
81