Your Name 3 år sedan
förälder
incheckning
672069a8bd
1 ändrade filer med 21 tillägg och 6 borttagningar
  1. 21
    6
      src/pages/video/liveDetail/index.jsx

+ 21
- 6
src/pages/video/liveDetail/index.jsx Visa fil

@@ -15,8 +15,8 @@ export default withLayout((props) => {
15 15
   const { id } = router.params;
16 16
 
17 17
   const [data,setData] = useState({})
18
-  // 直播间凭证
19
-  const livingCodeRef = useRef('6990341961664364915')
18
+  // 直播间信息
19
+  const livingRef = useRef()
20 20
   
21 21
   // 本页面分享或者海报参数
22 22
   const paramsRef = useParams({
@@ -40,15 +40,15 @@ export default withLayout((props) => {
40 40
     queryLiveDetail(id).then(res=>{
41 41
         setData(res)
42 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 50
   const handleLive = () => {
51
-    if (!livingCodeRef.current) {
51
+    if (!livingRef.current) {
52 52
       Taro.showToast({
53 53
         title: '查询直播凭证失败, 请退出重试',
54 54
         icon: 'none',
@@ -56,11 +56,26 @@ export default withLayout((props) => {
56 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 75
     Taro.navigateToMiniProgram({
61 76
       // 固定跳转到微信企业直播
62 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