Baozhangchao hace 3 años
padre
commit
64dce4b682

+ 5
- 6
src/components/foodCards/ShopNoteCard/index.jsx Ver fichero

@@ -37,12 +37,11 @@ export default (props) => {
37 37
 
38 38
   useEffect(() => {
39 39
     if (item == []) {
40
-      console.log('asdasdsadasd');
41 40
     }
42
-    setValueList(travelMine.records)
41
+    setValueList(travelMine?.records)
43 42
 
44 43
 
45
-  }, [travelMine.records, item])
44
+  }, [travelMine?.records, item])
46 45
 
47 46
   const onClose = () => {
48 47
     //关闭当前套餐详情弹窗
@@ -57,7 +56,7 @@ export default (props) => {
57 56
 
58 57
   const numberTrave = (new Array(traveCoumun).fill()).map((_, index) => ({ id: index + 1, title: `第 ${index + 1} 天` }))
59 58
 
60
-  const array = [valueList, travelMine.records == '' ? [] : numberTrave]
59
+  const array = [valueList, travelMine?.records == '' ? [] : numberTrave]
61 60
 
62 61
 
63 62
   const handleColumn = e => {
@@ -81,7 +80,7 @@ export default (props) => {
81 80
 
82 81
 
83 82
 
84
-    if (travelMine.records == '') {
83
+    if (travelMine?.records == '') {
85 84
 
86 85
 
87 86
       console.log('没有行程');
@@ -142,7 +141,7 @@ export default (props) => {
142 141
 
143 142
 
144 143
   const handlePayClick = () => {
145
-    if (travelMine.records == '') {
144
+    if (travelMine?.records == '') {
146 145
       Taro.showToast({
147 146
         title: '暂无行程,已自动创建',
148 147
         icon: 'none',

+ 57
- 3
src/pages/details/NoteDetails/index.jsx Ver fichero

@@ -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