|
@@ -50,15 +50,40 @@ export default withLayout((props) => {
|
50
|
50
|
|
51
|
51
|
// 推荐套餐列表
|
52
|
52
|
const [recommend, setRecommend] = useState([])
|
53
|
|
-
|
|
53
|
+ //视频
|
|
54
|
+ const [videoHeight, setVideoHeight] = useState()
|
|
55
|
+ const [getVideoWidth, setGetVideoWidth] = useState()
|
|
56
|
+ const [proportion, setProportion] = useState()
|
54
|
57
|
|
55
|
58
|
//引导显隐
|
56
|
59
|
const [guidance, setGuidance] = useState('shareOff')
|
|
60
|
+
|
57
|
61
|
useEffect(() => {
|
|
62
|
+
|
|
63
|
+ Taro.nextTick(() => {
|
|
64
|
+ // 在当前同步流程结束后,下一个时间片执行
|
|
65
|
+ //绑定video 标签,拿到他实际的宽度,然后和 取到的高度,计算,才能得到正确的数值
|
|
66
|
+ Taro.createSelectorQuery().selectAll('.get-Video-Width').boundingClientRect(function (rects) {
|
|
67
|
+ rects.forEach(function (rect) {
|
|
68
|
+ setGetVideoWidth(rect.width)
|
|
69
|
+ console.log("🚀 ~ file: index.jsx ~ line 72 ~ rect", rect)
|
|
70
|
+
|
|
71
|
+ })
|
|
72
|
+ }).exec()
|
|
73
|
+
|
|
74
|
+ })
|
|
75
|
+ }, [])
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+ useEffect(() => {
|
|
79
|
+
|
|
80
|
+
|
58
|
81
|
if (router.params.enterType === "share") {
|
59
|
82
|
setGuidance('shareOn')
|
60
|
83
|
}
|
61
|
84
|
}, [router.params.enterType])
|
|
85
|
+
|
|
86
|
+
|
62
|
87
|
const resourceList = () => {
|
63
|
88
|
getNoteID(id).then((res) => {
|
64
|
89
|
setDetail(res)
|
|
@@ -79,6 +104,32 @@ export default withLayout((props) => {
|
79
|
104
|
|
80
|
105
|
})
|
81
|
106
|
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ useEffect(() => {
|
|
110
|
+ //算出当前宽度下高度的数值
|
|
111
|
+ if (getVideoWidth || proportion) {
|
|
112
|
+ const videoHeights = proportion * getVideoWidth;
|
|
113
|
+ setVideoHeight(videoHeights)
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ }, [getVideoWidth, proportion])
|
|
117
|
+
|
|
118
|
+ const hanleLoade = (e) => {
|
|
119
|
+
|
|
120
|
+ //视频的高
|
|
121
|
+ const height = e.detail.height;
|
|
122
|
+ //视频的宽
|
|
123
|
+ const width = e.detail.width;
|
|
124
|
+ //算出视频的比例
|
|
125
|
+ setProportion(height / width)
|
|
126
|
+ //res.windowWidth为手机屏幕的宽。
|
|
127
|
+ // const windowWidth = res.windowWidth;
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
82
|
133
|
}
|
83
|
134
|
|
84
|
135
|
useEffect(() => {
|
|
@@ -145,7 +196,10 @@ export default withLayout((props) => {
|
145
|
196
|
controls
|
146
|
197
|
autoplay={false}
|
147
|
198
|
loop={false}
|
148
|
|
- muted={false} style={{ width: "100%", height: '200px' }} src={detail.videoUrl}
|
|
199
|
+ className='get-Video-Width'
|
|
200
|
+ poster={detail.poster}
|
|
201
|
+ onLoadedmetadata={hanleLoade}
|
|
202
|
+ muted={false} style={{ width: "100%", height: `${videoHeight}px` }} src={detail.videoUrl}
|
149
|
203
|
>
|
150
|
204
|
</Video>
|
151
|
205
|
}
|
|
@@ -192,7 +246,7 @@ export default withLayout((props) => {
|
192
|
246
|
<TabIcon icon={isSaved > 0 ? ax : good} text={isSaved > 0 ? "已收藏" : "加入收藏"} />
|
193
|
247
|
</view>
|
194
|
248
|
</view>
|
195
|
|
- </view>
|
|
249
|
+ </view >
|
196
|
250
|
)
|
197
|
251
|
})
|
198
|
252
|
|