吃个甘蔗嚼一年 3 年前
父节点
当前提交
2c9ad5a425

+ 10
- 15
src/components/List/index.jsx 查看文件

99
   }))
99
   }))
100
 
100
 
101
   return (
101
   return (
102
-
103
-    <ScrollView
104
-      scrollY
105
-      enhanced
106
-      onScrollToLower={handleScrollToLower}
107
-      {...leftProps}
108
-      className={`${className} list-view`}
109
-    >
110
-      <SpinBox loading={loading} className='index-container' >
111
-
102
+    <SpinBox loading={loading}>
103
+      <ScrollView
104
+        scrollY
105
+        enhanced
106
+        onScrollToLower={handleScrollToLower}
107
+        {...leftProps}
108
+        className={`${className} list-view`}
109
+      >
112
         {!render
110
         {!render
113
           ? props.children
111
           ? props.children
114
           : list.map((item, index) => render({ item, index }))
112
           : list.map((item, index) => render({ item, index }))
116
         {!list || !list.length && noData}
114
         {!list || !list.length && noData}
117
 
115
 
118
         {list && list.length > 0 && !hasMore &&
116
         {list && list.length > 0 && !hasMore &&
119
-
120
           <view className='botton'>这是我的底线</view>
117
           <view className='botton'>这是我的底线</view>
121
-
122
         }
118
         }
123
-      </SpinBox>
124
-
125
-    </ScrollView>
119
+      </ScrollView>
120
+    </SpinBox>
126
   )
121
   )
127
 })
122
 })

+ 43
- 0
src/components/MasonryLayout/Item.jsx 查看文件

1
+
2
+import React, { useMemo, useEffect } from 'react'
3
+import { View } from '@tarojs/components'
4
+import { classNames, getRect } from './utils';
5
+import './style.less'
6
+
7
+export default (props) => {
8
+  const { className, item, render, onRenderFinish } = props
9
+
10
+  const vid = item.__vid;
11
+  
12
+  useEffect(() => {
13
+    const calcHeight = () => {
14
+      getRect(`.${vid}`).then((res) => {
15
+        if (!res) {
16
+          // 找不到 node , 则一直重复查询
17
+          const t = setTimeout(() => {
18
+            clearTimeout(t)
19
+            calcHeight()
20
+          }, 300)
21
+        } else {
22
+          if (Array.isArray(res)) {
23
+            onRenderFinish(res[0])
24
+          } else {
25
+            onRenderFinish(res)
26
+          }
27
+        }
28
+      })
29
+    }
30
+
31
+    calcHeight()
32
+  })
33
+
34
+
35
+  return (
36
+    <View
37
+      key={vid}
38
+      className={classNames(className, 'masonry-item', vid)}
39
+    >
40
+      {render(item)}
41
+    </View>
42
+  )
43
+}

+ 24
- 53
src/components/MasonryLayout/index.jsx 查看文件

1
 import React, { useEffect, useMemo, useRef, useState } from 'react';
1
 import React, { useEffect, useMemo, useRef, useState } from 'react';
2
 import Taro from '@tarojs/taro';
2
 import Taro from '@tarojs/taro';
3
 import { View } from '@tarojs/components';
3
 import { View } from '@tarojs/components';
4
+import Item from './Item';
4
 import { useList } from './hooks';
5
 import { useList } from './hooks';
5
 import { classNames, getRect } from './utils';
6
 import { classNames, getRect } from './utils';
6
 
7
 
15
   const rightBottom = useRef(0)
16
   const rightBottom = useRef(0)
16
   const [leftList, leftRef, setLeftList] = useList()
17
   const [leftList, leftRef, setLeftList] = useList()
17
   const [rightList, rightRef, setRightList] = useList()
18
   const [rightList, rightRef, setRightList] = useList()
18
-  const vidRef = useRef()
19
-  const [cursor, setCursor] = useState(-1)
19
+  const [cursor, setCursor] = useState(0)
20
 
20
 
21
   const listRef = useRef([])
21
   const listRef = useRef([])
22
   listRef.current = list
22
   listRef.current = list
23
-    
24
-  useEffect(() => {
25
-    if (list && list.length) {
26
-      setCursor(0)
23
+
24
+  const handleRenderFinish = (direct) => (rect) => {
25
+    const { bottom } = rect
26
+
27
+    if (direct === 'left') {
28
+      leftBottom.current = bottom
27
     } else {
29
     } else {
28
-      setCursor(-1)
29
-      setLeftList([])
30
-      setRightList([])
30
+      rightBottom.current = bottom
31
     }
31
     }
32
-  }, [list])
33
 
32
 
33
+    setCursor(cursor + 1)
34
+  }
35
+    
34
   useEffect(() => {
36
   useEffect(() => {
35
-    const len = !listRef.current ? 0 : listRef.current.length;
37
+    setCursor(0)
38
+    setLeftList([])
39
+    setRightList([])
40
+    listRef.current = list ? list.slice() : []
41
+  }, [list])
36
 
42
 
43
+  useEffect(() => {
44
+    const len = !list ? 0 : list.length;
37
     if (leftRef.current.length + rightRef.current.length >= len) return;
45
     if (leftRef.current.length + rightRef.current.length >= len) return;
38
 
46
 
39
-    const item = listRef.current[cursor] || {}
47
+    const item = listRef.current.shift()
40
     item.__vid = `f-${Math.random().toString(36).substring(2)}`
48
     item.__vid = `f-${Math.random().toString(36).substring(2)}`
41
-    vidRef.current = item.__vid
42
 
49
 
43
     if (leftBottom.current <= rightBottom.current) {
50
     if (leftBottom.current <= rightBottom.current) {
44
       setLeftList([...leftRef.current, item])
51
       setLeftList([...leftRef.current, item])
45
     } else {
52
     } else {
46
       setRightList([...rightRef.current, item])
53
       setRightList([...rightRef.current, item])
47
     }
54
     }
48
-  }, [cursor])
49
-
50
-  useEffect(() => {
51
-    const setHeight = (rect) => {
52
-      const { bottom } = rect
53
-      if (cursor % 2 === 0) {
54
-        leftBottom.current = bottom
55
-      } else {
56
-        rightBottom.current = bottom
57
-      }
58
-      setCursor(cursor + 1)
59
-    }
60
-
61
-    const calcHeight = () => {
62
-      getRect(`.${vidRef.current}`).then((res) => {
63
-        if (!res) {
64
-          // 找不到 node , 则一直重复查询
65
-          const t = setTimeout(() => {
66
-            clearTimeout(t)
67
-            calcHeight()
68
-          }, 300)
69
-        } else {
70
-          if (Array.isArray(res)) {
71
-            setHeight(res[0])
72
-          } else {
73
-            setHeight(res)
74
-          }
75
-        }
76
-      })
77
-    }
78
-
79
-    calcHeight()
80
-  })
55
+  }, [cursor, list])
81
 
56
 
82
   return (
57
   return (
83
     <View
58
     <View
84
-      className={classNames(className, 'masonry-layout')}
85
       style={style}
59
       style={style}
60
+      className={classNames(className, 'masonry-layout')}
86
     >
61
     >
87
       <View className='masonry-column'>
62
       <View className='masonry-column'>
88
         {
63
         {
89
-          leftList.map((item) => (
90
-            <View key={item.__vid} className={classNames(itemClassName, 'masonry-item', item.__vid)}>{render(item)}</View>
91
-          ))
64
+          leftList.map(item => <Item key={item.__vid} className={itemClassName} item={item} render={render} onRenderFinish={handleRenderFinish('left')} />)
92
         }
65
         }
93
       </View>
66
       </View>
94
       <View className='masonry-split' style={splitStyle} />
67
       <View className='masonry-split' style={splitStyle} />
95
       <View className='masonry-column'>
68
       <View className='masonry-column'>
96
         {
69
         {
97
-          rightList.map((item) => (
98
-            <View key={item.__vid} className={classNames(itemClassName, 'masonry-item', item.__vid)}>{render(item)}</View>
99
-          ))
70
+          rightList.map(item => <Item key={item.__vid} className={itemClassName} item={item} render={render} onRenderFinish={handleRenderFinish('right')} />)
100
         }
71
         }
101
       </View>
72
       </View>
102
     </View>
73
     </View>

+ 1
- 1
src/components/toggleRole/ToggleRole.jsx 查看文件

31
   return (
31
   return (
32
 
32
 
33
     <Popup show={showCutover} maskClosable={maskClosable} onClose={onClose}>
33
     <Popup show={showCutover} maskClosable={maskClosable} onClose={onClose}>
34
-      <SpinBox loading={loading} className='index-container' >
34
+      <SpinBox loading={loading}>
35
         <view className='User-box-sths' >
35
         <view className='User-box-sths' >
36
           <view className='User-box-selectUser'>请选择身份:</view>
36
           <view className='User-box-selectUser'>请选择身份:</view>
37
           <view className='User-box-tourist' onClick={goToPerson}>
37
           <view className='User-box-tourist' onClick={goToPerson}>

+ 4
- 3
src/hotel/components/HouseManage/houseManage.jsx 查看文件

21
   const { hotel, hotelList, onHotelChange } = props
21
   const { hotel, hotelList, onHotelChange } = props
22
   const [detail, setDetail] = useState([])
22
   const [detail, setDetail] = useState([])
23
 
23
 
24
-  const fetchAPI = useMemo(() => hotel.hotelId ? () => getRoomList({ hotelId: hotel.hotelId }) : undefined, [hotel?.hotelId])
25
-  const queryParams = useMemo(() => ({}), [])
24
+  const queryParams = useMemo(() => ({
25
+    hotelId: hotel.hotelId
26
+  }), [hotel.hotelId])
26
 
27
 
27
   const shareDataRef = useRef()
28
   const shareDataRef = useRef()
28
 
29
 
163
         <ShareCard showCutover={showCard} onClose={onClose2} />
164
         <ShareCard showCutover={showCard} onClose={onClose2} />
164
         <List
165
         <List
165
           style={{ height: 'calc(100vh - 290px)' }}
166
           style={{ height: 'calc(100vh - 290px)' }}
166
-          request={fetchAPI}
167
+          request={getRoomList}
167
           params={queryParams}
168
           params={queryParams}
168
           onDataChange={setDetail}
169
           onDataChange={setDetail}
169
           noData="暂无房源信息"
170
           noData="暂无房源信息"

+ 8
- 2
src/hotel/pages/components/Extend/index.jsx 查看文件

1
 import { useState } from 'react';
1
 import { useState } from 'react';
2
 import Taro from '@tarojs/taro';
2
 import Taro from '@tarojs/taro';
3
 import Popup from '@/components/Popup'
3
 import Popup from '@/components/Popup'
4
-import { View,  Image, Textarea, Label, Button } from '@tarojs/components';
4
+import { View, Image, Textarea, Label, Button, Video } from '@tarojs/components';
5
 import { update, deleteExtend } from '@/services/landlord'
5
 import { update, deleteExtend } from '@/services/landlord'
6
 import SlideView from '@/components/SlideView';
6
 import SlideView from '@/components/SlideView';
7
 import './style.less'
7
 import './style.less'
106
                 <View className='storezn' onClick={showText}>{content}</View>
106
                 <View className='storezn' onClick={showText}>{content}</View>
107
               </SlideView>
107
               </SlideView>
108
             </View>
108
             </View>
109
-            : null
109
+            : item.contentType == 'video' ?
110
+              <View>
111
+                <SlideView del onDelete={handelDelete}>
112
+                  <Video className='storezn' style={{ width: '100%', display: 'block' }} src={eimg} />
113
+                </SlideView>
114
+              </View>
115
+              : null
110
       }
116
       }
111
     </View>
117
     </View>
112
   )
118
   )

+ 0
- 2
src/hotel/pages/landlord/roomOrder/roomOrder.jsx 查看文件

9
 import './roomOrder.less'
9
 import './roomOrder.less'
10
 
10
 
11
 
11
 
12
-
13
-
14
 export default withLayout((props) => {
12
 export default withLayout((props) => {
15
   const { hotelId, roomId, roomName } = props.router.params
13
   const { hotelId, roomId, roomName } = props.router.params
16
   const [detail, setDetail] = useState([])
14
   const [detail, setDetail] = useState([])

+ 1
- 1
src/pages/MineUserAll/RefundMoney/CheckRefund/index.jsx 查看文件

124
       <View className='index-container'>
124
       <View className='index-container'>
125
         <View className='box-content'>
125
         <View className='box-content'>
126
           <scroll-view scroll-y style='height: 100%;' >
126
           <scroll-view scroll-y style='height: 100%;' >
127
-            <SpinBox loading={loading} className='index-container' >
127
+            <SpinBox loading={loading}>
128
 
128
 
129
               <view className='Refund-Content-box'>
129
               <view className='Refund-Content-box'>
130
                 <view className='title-image'>
130
                 <view className='title-image'>

+ 1
- 1
src/pages/MineUserAll/RefundMoney/index.jsx 查看文件

66
       <view className='index-navbar'>
66
       <view className='index-navbar'>
67
         <CustomNav title='售后退款' />
67
         <CustomNav title='售后退款' />
68
       </view>
68
       </view>
69
-      <SpinBox loading={loading} className='index-container' >
69
+      <SpinBox loading={loading}>
70
         <scroll-view
70
         <scroll-view
71
           scrollY
71
           scrollY
72
           style='height: calc(100vh - 176rpx);'
72
           style='height: calc(100vh - 176rpx);'

+ 28
- 32
src/pages/index/tabs/Guide.jsx 查看文件

33
 
33
 
34
   const trackClick = useTrackClick(router)
34
   const trackClick = useTrackClick(router)
35
 
35
 
36
-  // 住宿经纬度
37
-  const Roomlog = useRef('')
38
-  const Roomlat = useRef('')
39
-  // 停车场经纬度
40
-  const Parklog = useRef('')
41
-  const Parklat = useRef('')
42
   const [taRoomContent, setTaRoomContent] = useState([])
36
   const [taRoomContent, setTaRoomContent] = useState([])
43
   const RoomLocation = taRoomContent?.location
37
   const RoomLocation = taRoomContent?.location
44
   //没有停车 wifi的就不显示按钮
38
   //没有停车 wifi的就不显示按钮
69
 
63
 
70
   useDidShow(() => {
64
   useDidShow(() => {
71
     goContent()
65
     goContent()
72
-
73
   })
66
   })
67
+
74
   const geiZy = () => {
68
   const geiZy = () => {
75
     setLoading(true)
69
     setLoading(true)
76
     getExtendContent('room', roomId, {
70
     getExtendContent('room', roomId, {
90
       setLoading(true)
84
       setLoading(true)
91
       // 点击’去这里‘跳转导航
85
       // 点击’去这里‘跳转导航
92
       getTaRoom(roomId).then((res) => {
86
       getTaRoom(roomId).then((res) => {
93
-        Roomlog.current = (!res.location).toString().split(',')[0]
94
-        Roomlat.current = (!res.location).toString().split(',')[1]
95
-        Parklog.current = (!res.parkingLocation).toString().split(',')[0]
96
-        Parklat.current = (!res.parkingLocation).toString().split(',')[1]
87
+        // Roomlog.current = (!res.location).toString().split(',')[0]
88
+        // Roomlat.current = (!res.location).toString().split(',')[1]
89
+        // Parklog.current = (!res.parkingLocation).toString().split(',')[0]
90
+        // Parklat.current = (!res.parkingLocation).toString().split(',')[1]
97
         setTaRoomContent(res || [])
91
         setTaRoomContent(res || [])
98
         setLoading(false)
92
         setLoading(false)
99
       })
93
       })
127
 
121
 
128
 
122
 
129
   const goRoomMap = () => {
123
   const goRoomMap = () => {
130
-    Taro.openLocation({
131
-      longitude: Roomlog.current - 0,
132
-      latitude: Roomlat.current - 0,
133
-      name: taRoomContent.roomName,
134
-      address: taRoomContent.address,
135
-      scale: 12,
136
-    })
124
+    if (taRoomContent.location) {
125
+      const [longitude, latitude] = taRoomContent.location.split(',').map(x => x - 0)
126
+
127
+      Taro.openLocation({
128
+        longitude,
129
+        latitude,
130
+        name: taRoomContent.roomName,
131
+        address: taRoomContent.address,
132
+        scale: 12,
133
+      })
134
+    }
137
   }
135
   }
138
 
136
 
139
   const goParkMap = () => {
137
   const goParkMap = () => {
140
-    Taro.openLocation({
141
-      longitude: Parklog.current - 0,
142
-      latitude: Parklat.current - 0,
143
-      name: taRoomContent.parkingAddress,
144
-      address: taRoomContent.parkingAddress,
145
-      scale: 12,
146
-    })
138
+    if (taRoomContent.parkingLocation) {
139
+      const [longitude, latitude] = taRoomContent.parkingLocation.split(',').map(x => x - 0)
140
+
141
+      Taro.openLocation({
142
+        longitude,
143
+        latitude,
144
+        name: taRoomContent.parkingAddress,
145
+        address: taRoomContent.parkingAddress,
146
+        scale: 12,
147
+      })
148
+    }
147
   }
149
   }
148
 
150
 
149
-
150
-
151
-
152
   const wifiCopy = () => {
151
   const wifiCopy = () => {
153
     Taro.setClipboardData({
152
     Taro.setClipboardData({
154
       data: taRoomContent?.wifiPassword,
153
       data: taRoomContent?.wifiPassword,
162
     })
161
     })
163
   }
162
   }
164
 
163
 
165
-
166
-
167
-
168
   return (
164
   return (
169
     <scroll-view scrollY style='height:100%;'  >
165
     <scroll-view scrollY style='height:100%;'  >
170
-      <SpinBox loading={loading}  >
166
+      <SpinBox loading={loading}>
171
 
167
 
172
         <view className='Guide-Home-box'>
168
         <view className='Guide-Home-box'>
173
           {
169
           {

+ 1
- 2
src/pages/index/tabs/Recommend.jsx 查看文件

6
 import Tip from '@/components/tip'
6
 import Tip from '@/components/tip'
7
 import List from '@/components/List';
7
 import List from '@/components/List';
8
 import NoData from '@/components/NoData'
8
 import NoData from '@/components/NoData'
9
-import SpinBox from '@/components/Spin/SpinBox';
9
+import MasonryLayout from '@/components/MasonryLayout';
10
 import { getIndexType, getResourceList } from '@/services/home'
10
 import { getIndexType, getResourceList } from '@/services/home'
11
 import Card from '../components/Card'
11
 import Card from '../components/Card'
12
 import './less/Recommend.less'
12
 import './less/Recommend.less'
109
           onDataChange={setAllList}
109
           onDataChange={setAllList}
110
         >
110
         >
111
           {/* <MasonryLayout
111
           {/* <MasonryLayout
112
-            className='waterfall'
113
             list={alllist}
112
             list={alllist}
114
             render={item => <Card item={item} />}
113
             render={item => <Card item={item} />}
115
           /> */}
114
           /> */}

+ 0
- 10
src/shop/components/ShopKeeper/shopKeeper.jsx 查看文件

23
   const [activeTab, setActiveTab] = useState(0)
23
   const [activeTab, setActiveTab] = useState(0)
24
   const [phonea, setPhone] = useState()
24
   const [phonea, setPhone] = useState()
25
   const [isVerifieda, setisVerified] = useState(0)
25
   const [isVerifieda, setisVerified] = useState(0)
26
-  // const [queryParams, setQueryParams] = useState({ isVerified: isVerified, pageNum: 1, pageSize: 10, shopId: shop?.shopId, phone: phone })
27
-
28
   const queryParams = useMemo(() => ({
26
   const queryParams = useMemo(() => ({
29
     shopId: shop?.shopId,
27
     shopId: shop?.shopId,
30
     isVerified: isVerifieda,
28
     isVerified: isVerifieda,
31
-    // `${tabJump}` === '1' ? 1 : 0,
32
     phone: phonea || '',
29
     phone: phonea || '',
33
   }), [phonea, shop?.shopId, isVerifieda])
30
   }), [phonea, shop?.shopId, isVerifieda])
34
 
31
 
45
   const handleMonth = () => {
42
   const handleMonth = () => {
46
     isMomth ? setMonth(false) : setMonth(true)
43
     isMomth ? setMonth(false) : setMonth(true)
47
   }
44
   }
48
-
49
-
50
   const handleHotelChange = (e, current) => {
45
   const handleHotelChange = (e, current) => {
51
     onHotelChange(current)
46
     onHotelChange(current)
52
   }
47
   }
146
           {activeTab === 0 &&
141
           {activeTab === 0 &&
147
             <>
142
             <>
148
               <scroll-view scrollY style={{ height: 'calc(100vh - 120px)' }}>
143
               <scroll-view scrollY style={{ height: 'calc(100vh - 120px)' }}>
149
-
150
                 <List
144
                 <List
151
                   style={{ height: '50%' }}
145
                   style={{ height: '50%' }}
152
                   request={getVerifiedOrder}
146
                   request={getVerifiedOrder}
158
                 >
152
                 >
159
                 </List>
153
                 </List>
160
               </scroll-view>
154
               </scroll-view>
161
-
162
             </>
155
             </>
163
-
164
           }
156
           }
165
           {/* 已核销 */}
157
           {/* 已核销 */}
166
           {activeTab === 1 &&
158
           {activeTab === 1 &&
176
                 >
168
                 >
177
                 </List>
169
                 </List>
178
               </scroll-view>
170
               </scroll-view>
179
-
180
             </>
171
             </>
181
           }
172
           }
182
         </view>
173
         </view>
183
-
184
         {/* <view className='botton'>这是我的底线</view> */}
174
         {/* <view className='botton'>这是我的底线</view> */}
185
       </view>
175
       </view>
186
     </view>
176
     </view>