|
@@ -2,14 +2,15 @@ import { useState, useEffect, useRef } from "react";
|
2
|
2
|
import Taro from "@tarojs/taro";
|
3
|
3
|
import { savePoint } from '@/services/common'
|
4
|
4
|
import withLayout from "@/layout";
|
5
|
|
-import { Image } from "@tarojs/components";
|
|
5
|
+import { Image, View } from "@tarojs/components";
|
6
|
6
|
import { queryLiveDetail } from "@/services/item";
|
7
|
|
-import { fetch } from '@/utils/request'
|
8
|
|
-import { API_VIDEO_DETAIL } from '@/constants/api'
|
9
|
7
|
import useParams from "@/utils/hooks/useParams";
|
10
|
8
|
import useShare from "@/utils/hooks/useShare";
|
11
|
9
|
import { getImgURL } from "@/utils/image";
|
12
|
10
|
import { getLivingCode } from '@/services/activity'
|
|
11
|
+import Overlay from '@/components/Overlay'
|
|
12
|
+import AuthPhone from '@/components/Auth/AuthPhone'
|
|
13
|
+import { useSelector } from 'react-redux'
|
13
|
14
|
import "@/assets/css/iconfont.css";
|
14
|
15
|
import "./index.scss";
|
15
|
16
|
|
|
@@ -19,6 +20,8 @@ export default withLayout((props) => {
|
19
|
20
|
|
20
|
21
|
const [data, setData] = useState({})
|
21
|
22
|
const [CanPlay, setCanPlay] = useState(false)
|
|
23
|
+ const consultant = useSelector(s => s.system.consultant)
|
|
24
|
+ const [authPhone, setAuthPhone] = useState(false)
|
22
|
25
|
// 直播间信息
|
23
|
26
|
const livingRef = useRef()
|
24
|
27
|
|
|
@@ -70,39 +73,58 @@ export default withLayout((props) => {
|
70
|
73
|
}
|
71
|
74
|
}
|
72
|
75
|
|
73
|
|
- const handleLive = () => {
|
74
|
|
- if(type === 'live') {
|
75
|
|
- if (!livingRef.current) {
|
76
|
|
- Taro.showToast({
|
77
|
|
- title: '查询直播凭证失败, 请退出重试',
|
78
|
|
- icon: 'none',
|
79
|
|
- })
|
80
|
|
- return;
|
81
|
|
- }
|
82
|
|
-
|
83
|
|
- // https://work.weixin.qq.com/api/doc/90000/90135/93635
|
84
|
|
- const { livingCode, status } = livingRef.current
|
85
|
|
-
|
86
|
|
- //
|
87
|
|
- if (status >= 3) {
|
88
|
|
- Taro.showToast({
|
89
|
|
- title: `直播活动已${status === 3 ? '过期' : '取消'}`,
|
90
|
|
- icon: 'none',
|
91
|
|
- })
|
92
|
|
- return;
|
93
|
|
- }
|
94
|
|
-
|
95
|
|
- // 如果已经结束的则播放回放
|
96
|
|
- const replay = status === 2 ? '&replay=1' : ''
|
97
|
|
-
|
98
|
|
- // 跳转到直播
|
99
|
|
- Taro.navigateToMiniProgram({
|
100
|
|
- // 固定跳转到微信企业直播
|
101
|
|
- appId: 'wx7424030d69bde86e',
|
102
|
|
- path: `pages/watch/index?living_code=${encodeURIComponent(livingCode)}${replay}`,
|
|
76
|
+ const AuthPhoneSuccess = () => {
|
|
77
|
+ setAuthPhone(false)
|
|
78
|
+ ToLiving()
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ const AuthPhoneError = () => {
|
|
82
|
+ setAuthPhone(false)
|
|
83
|
+ ToLiving()
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ const AuthPhoneCancel = () => {
|
|
87
|
+ setAuthPhone(false)
|
|
88
|
+ ToLiving()
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ const ToLiving = () => {
|
|
92
|
+ if (!livingRef.current) {
|
|
93
|
+ Taro.showToast({
|
|
94
|
+ title: '查询直播凭证失败, 请退出重试',
|
|
95
|
+ icon: 'none',
|
103
|
96
|
})
|
|
97
|
+ return;
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ // https://work.weixin.qq.com/api/doc/90000/90135/93635
|
|
101
|
+ const { livingCode, status } = livingRef.current
|
|
102
|
+
|
|
103
|
+ //
|
|
104
|
+ if (status >= 3) {
|
|
105
|
+ Taro.showToast({
|
|
106
|
+ title: `直播活动已${status === 3 ? '过期' : '取消'}`,
|
|
107
|
+ icon: 'none',
|
|
108
|
+ })
|
|
109
|
+ return;
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ // 如果已经结束的则播放回放
|
|
113
|
+ const replay = status === 2 ? '&replay=1' : ''
|
|
114
|
+
|
|
115
|
+ // 跳转到直播
|
|
116
|
+ Taro.navigateToMiniProgram({
|
|
117
|
+ // 固定跳转到微信企业直播
|
|
118
|
+ appId: 'wx7424030d69bde86e',
|
|
119
|
+ path: `pages/watch/index?living_code=${encodeURIComponent(livingCode)}${replay}`,
|
|
120
|
+ })
|
|
121
|
+ }
|
|
122
|
+
|
|
123
|
+ const handleLive = () => {
|
|
124
|
+ if(person.inited && !person.phone) {
|
|
125
|
+ setAuthPhone(true)
|
104
|
126
|
} else {
|
105
|
|
- setCanPlay(true)
|
|
127
|
+ ToLiving()
|
106
|
128
|
}
|
107
|
129
|
}
|
108
|
130
|
|
|
@@ -113,6 +135,13 @@ export default withLayout((props) => {
|
113
|
135
|
}, [id]);
|
114
|
136
|
//
|
115
|
137
|
return <view className="liveDetail">
|
|
138
|
+
|
|
139
|
+ {/* 授权手机 */}
|
|
140
|
+ <Overlay visible={authPhone} aligin='bottom'>
|
|
141
|
+ <View className='auth-wrapper'>
|
|
142
|
+ <AuthPhone consultant={consultant} router={router} page={page} onSuccess={(AuthPhoneSuccess)} onError={AuthPhoneError} onCancel={AuthPhoneCancel} />
|
|
143
|
+ </View>
|
|
144
|
+ </Overlay>
|
116
|
145
|
{
|
117
|
146
|
type === 'video' && data.videoUrl && CanPlay &&
|
118
|
147
|
<view className="myVideo">
|