Baozhangchao 3 年前
父节点
当前提交
64dce4b682
共有 2 个文件被更改,包括 62 次插入9 次删除
  1. 5
    6
      src/components/foodCards/ShopNoteCard/index.jsx
  2. 57
    3
      src/pages/details/NoteDetails/index.jsx

+ 5
- 6
src/components/foodCards/ShopNoteCard/index.jsx 查看文件

37
 
37
 
38
   useEffect(() => {
38
   useEffect(() => {
39
     if (item == []) {
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
   const onClose = () => {
46
   const onClose = () => {
48
     //关闭当前套餐详情弹窗
47
     //关闭当前套餐详情弹窗
57
 
56
 
58
   const numberTrave = (new Array(traveCoumun).fill()).map((_, index) => ({ id: index + 1, title: `第 ${index + 1} 天` }))
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
   const handleColumn = e => {
62
   const handleColumn = e => {
81
 
80
 
82
 
81
 
83
 
82
 
84
-    if (travelMine.records == '') {
83
+    if (travelMine?.records == '') {
85
 
84
 
86
 
85
 
87
       console.log('没有行程');
86
       console.log('没有行程');
142
 
141
 
143
 
142
 
144
   const handlePayClick = () => {
143
   const handlePayClick = () => {
145
-    if (travelMine.records == '') {
144
+    if (travelMine?.records == '') {
146
       Taro.showToast({
145
       Taro.showToast({
147
         title: '暂无行程,已自动创建',
146
         title: '暂无行程,已自动创建',
148
         icon: 'none',
147
         icon: 'none',

+ 57
- 3
src/pages/details/NoteDetails/index.jsx 查看文件

50
 
50
 
51
   // 推荐套餐列表
51
   // 推荐套餐列表
52
   const [recommend, setRecommend] = useState([])
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
   const [guidance, setGuidance] = useState('shareOff')
59
   const [guidance, setGuidance] = useState('shareOff')
60
+
57
   useEffect(() => {
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
     if (router.params.enterType === "share") {
81
     if (router.params.enterType === "share") {
59
       setGuidance('shareOn')
82
       setGuidance('shareOn')
60
     }
83
     }
61
   }, [router.params.enterType])
84
   }, [router.params.enterType])
85
+
86
+
62
   const resourceList = () => {
87
   const resourceList = () => {
63
     getNoteID(id).then((res) => {
88
     getNoteID(id).then((res) => {
64
       setDetail(res)
89
       setDetail(res)
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
   useEffect(() => {
135
   useEffect(() => {
145
                     controls
196
                     controls
146
                     autoplay={false}
197
                     autoplay={false}
147
                     loop={false}
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
                   </Video>
204
                   </Video>
151
               }
205
               }
192
           <TabIcon icon={isSaved > 0 ? ax : good} text={isSaved > 0 ? "已收藏" : "加入收藏"} />
246
           <TabIcon icon={isSaved > 0 ? ax : good} text={isSaved > 0 ? "已收藏" : "加入收藏"} />
193
         </view>
247
         </view>
194
       </view>
248
       </view>
195
-    </view>
249
+    </view >
196
   )
250
   )
197
 })
251
 })
198
 
252