吃个甘蔗嚼一年 3 years ago
parent
commit
9a5f38d922
2 changed files with 139 additions and 88 deletions
  1. 23
    9
      src/components/List/index.jsx
  2. 116
    79
      src/pages/index/tabs/Guide.jsx

+ 23
- 9
src/components/List/index.jsx View File

1
 import React, { useEffect, useRef, useState, useImperativeHandle } from 'react';
1
 import React, { useEffect, useRef, useState, useImperativeHandle } from 'react';
2
+import SpinBox from "@/components/Spin/SpinBox";
3
+
2
 import { ScrollView } from '@tarojs/components';
4
 import { ScrollView } from '@tarojs/components';
3
 import Taro from '@tarojs/taro';
5
 import Taro from '@tarojs/taro';
4
 
6
 
14
     className,
16
     className,
15
     ...leftProps
17
     ...leftProps
16
   } = props
18
   } = props
19
+  const [loading, setLoading] = useState(false)
17
 
20
 
18
   const contextRef = useRef()
21
   const contextRef = useRef()
19
   const loadingRef = useRef(false)
22
   const loadingRef = useRef(false)
37
   const fetchList = (params) => {
40
   const fetchList = (params) => {
38
     if (!request) return;
41
     if (!request) return;
39
 
42
 
40
-    Taro.showLoading()
43
+    setLoading(true)
41
     loadingRef.current = true
44
     loadingRef.current = true
42
     request(params).then((res) => {
45
     request(params).then((res) => {
43
       const { records, ...pageInfo } = res || {}
46
       const { records, ...pageInfo } = res || {}
49
 
52
 
50
       pageRef.current = pageInfo
53
       pageRef.current = pageInfo
51
       loadingRef.current = false
54
       loadingRef.current = false
52
-      Taro.hideLoading()
55
+
56
+      setLoading(false)
57
+
53
     }).catch((err) => {
58
     }).catch((err) => {
54
       loadingRef.current = false
59
       loadingRef.current = false
55
       console.error(err)
60
       console.error(err)
56
-      Taro.hideLoading()
61
+      setLoading(false)
62
+
57
       if (onError) {
63
       if (onError) {
58
         onError(err)
64
         onError(err)
59
       }
65
       }
93
   }))
99
   }))
94
 
100
 
95
   return (
101
   return (
102
+
96
     <ScrollView
103
     <ScrollView
97
       scrollY
104
       scrollY
98
       enhanced
105
       enhanced
100
       {...leftProps}
107
       {...leftProps}
101
       className={`${className} list-view`}
108
       className={`${className} list-view`}
102
     >
109
     >
103
-      {!render
104
-        ? props.children
105
-        : list.map((item, index) => render({ item, index }))
106
-      }
107
-      {!list || !list.length && noData}
110
+      <SpinBox loading={loading} className='index-container' >
111
+
112
+        {!render
113
+          ? props.children
114
+          : list.map((item, index) => render({ item, index }))
115
+        }
116
+        {!list || !list.length && noData}
117
+
118
+        {list && list.length > 0 && !hasMore &&
119
+
120
+          <view className='botton'>这是我的底线</view>
108
 
121
 
109
-      {list && list.length > 0 && !hasMore && <view className='botton'>这是我的底线</view>}
122
+        }
123
+      </SpinBox>
110
 
124
 
111
     </ScrollView>
125
     </ScrollView>
112
   )
126
   )

+ 116
- 79
src/pages/index/tabs/Guide.jsx View File

2
 import Taro, { useDidShow } from '@tarojs/taro'
2
 import Taro, { useDidShow } from '@tarojs/taro'
3
 import MoreGuide from "@/components/MoreGuide";
3
 import MoreGuide from "@/components/MoreGuide";
4
 import BossCard from '@/components/BossCard'
4
 import BossCard from '@/components/BossCard'
5
+import SpinBox from "@/components/Spin/SpinBox";
6
+
5
 import GPS from '@/assets/icons/GuideCheck/GPS.png'
7
 import GPS from '@/assets/icons/GuideCheck/GPS.png'
6
 import copy_logo from '@/assets/icons/GuideCheck/copy_logo.png'
8
 import copy_logo from '@/assets/icons/GuideCheck/copy_logo.png'
7
 import Cup from '@/assets/icons/GuideCheck/Cup.png'
9
 import Cup from '@/assets/icons/GuideCheck/Cup.png'
21
   const [extend, setExtend] = useState([])
23
   const [extend, setExtend] = useState([])
22
   const [ifroomId, setIfroomId] = useState('havenot')
24
   const [ifroomId, setIfroomId] = useState('havenot')
23
   const [spackage, setPackage] = useState([])
25
   const [spackage, setPackage] = useState([])
26
+  const [loading, setLoading] = useState(false)
24
 
27
 
25
   const { roomId: rid } = useModel('hotel')
28
   const { roomId: rid } = useModel('hotel')
26
 
29
 
76
     goContent()
79
     goContent()
77
     if (roomId) {
80
     if (roomId) {
78
       // 点击’去这里‘跳转导航
81
       // 点击’去这里‘跳转导航
82
+      setLoading(true)
79
       getTaRoom(roomId).then((res) => {
83
       getTaRoom(roomId).then((res) => {
80
         Roomlog.current = (res.location).toString().split(',')[0]
84
         Roomlog.current = (res.location).toString().split(',')[0]
81
         Roomlat.current = (res.location).toString().split(',')[1]
85
         Roomlat.current = (res.location).toString().split(',')[1]
82
         Parklog.current = (res.parkingLocation).toString().split(',')[0]
86
         Parklog.current = (res.parkingLocation).toString().split(',')[0]
83
         Parklat.current = (res.parkingLocation).toString().split(',')[1]
87
         Parklat.current = (res.parkingLocation).toString().split(',')[1]
84
         setTaRoomContent(res || [])
88
         setTaRoomContent(res || [])
89
+        setLoading(false)
90
+
85
       })
91
       })
86
       //更多指引
92
       //更多指引
93
+      setLoading(true)
94
+
87
       getExtendContent('room', roomId).then((res) => {
95
       getExtendContent('room', roomId).then((res) => {
88
         setExtend(res.records || [])
96
         setExtend(res.records || [])
89
         setIfroomId('reality')
97
         setIfroomId('reality')
90
         setAllextNum(res.total)
98
         setAllextNum(res.total)
91
         setNewextNum(res.records.length)
99
         setNewextNum(res.records.length)
100
+        setLoading(false)
101
+
92
       })
102
       })
103
+      setLoading(true)
104
+
93
       getRecommendList({ location: location }).then((res) => {
105
       getRecommendList({ location: location }).then((res) => {
94
         setPackage(res || [])
106
         setPackage(res || [])
107
+        setLoading(false)
108
+
95
       })
109
       })
110
+
96
     } else {
111
     } else {
112
+      setLoading(true)
113
+
97
       getRecommendList({ location: location }).then((res) => {
114
       getRecommendList({ location: location }).then((res) => {
98
         setPackage(res || [])
115
         setPackage(res || [])
116
+        setLoading(false)
117
+
99
       })
118
       })
100
       return
119
       return
101
     }
120
     }
112
   useEffect(() => {
131
   useEffect(() => {
113
 
132
 
114
     if (roomId) {
133
     if (roomId) {
134
+      setLoading(true)
115
       // 点击’去这里‘跳转导航
135
       // 点击’去这里‘跳转导航
116
       getTaRoom(roomId).then((res) => {
136
       getTaRoom(roomId).then((res) => {
117
         Roomlog.current = (res.location).toString().split(',')[0]
137
         Roomlog.current = (res.location).toString().split(',')[0]
119
         Parklog.current = (res.parkingLocation).toString().split(',')[0]
139
         Parklog.current = (res.parkingLocation).toString().split(',')[0]
120
         Parklat.current = (res.parkingLocation).toString().split(',')[1]
140
         Parklat.current = (res.parkingLocation).toString().split(',')[1]
121
         setTaRoomContent(res || [])
141
         setTaRoomContent(res || [])
142
+        setLoading(false)
122
       })
143
       })
123
       //更多指引
144
       //更多指引
145
+      setLoading(true)
146
+
124
       getExtendContent('room', roomId).then((res) => {
147
       getExtendContent('room', roomId).then((res) => {
125
         setExtend(res.records || [])
148
         setExtend(res.records || [])
126
         setIfroomId('reality')
149
         setIfroomId('reality')
127
         setAllextNum(res.total)
150
         setAllextNum(res.total)
128
         setNewextNum(res.records.length)
151
         setNewextNum(res.records.length)
152
+        setLoading(false)
153
+
129
       })
154
       })
155
+      setLoading(true)
156
+
130
       getRecommendList({ location: location }).then((res) => {
157
       getRecommendList({ location: location }).then((res) => {
131
         setPackage(res || [])
158
         setPackage(res || [])
159
+        setLoading(false)
160
+
132
       })
161
       })
162
+      // setLoading(false)
163
+
133
     } else {
164
     } else {
165
+      setLoading(true)
166
+
134
       getRecommendList({ location: location }).then((res) => {
167
       getRecommendList({ location: location }).then((res) => {
135
         setPackage(res || [])
168
         setPackage(res || [])
169
+        setLoading(false)
170
+
136
       })
171
       })
137
       return
172
       return
138
     }
173
     }
186
 
221
 
187
   return (
222
   return (
188
     <scroll-view scrollY style='height:100%;'  >
223
     <scroll-view scrollY style='height:100%;'  >
189
-
190
-      <view className='Guide-Home-box'>
191
-        {
192
-          ifroomId === 'havenot' && (
193
-            <view className='Guide-image-text-box'>
194
-              <image className='Guide-images' src={sleep} />
195
-              <view className='Guide-text'>您还没有入住订单哟~</view>
196
-            </view>
197
-          )
198
-        }
199
-        {/* 有民宿的情况下 */}
200
-        {
201
-          ifroomId === 'reality' && (
202
-            <view>
203
-
204
-              <view className='room-box-info-ROOM'>
205
-                <view className='room-bi-name-ROOM' >
206
-                  <view className='room-bin-title-ROOM'>房屋名称</view>
207
-                  <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
224
+      <SpinBox loading={loading} className='index-container' >
225
+
226
+        <view className='Guide-Home-box'>
227
+          {
228
+            ifroomId === 'havenot' && (
229
+              <view className='Guide-image-text-box'>
230
+                <image className='Guide-images' src={sleep} />
231
+                <view className='Guide-text'>您还没有入住订单哟~</view>
232
+              </view>
233
+            )
234
+          }
235
+          {/* 有民宿的情况下 */}
236
+          {
237
+            ifroomId === 'reality' && (
238
+              <view>
239
+
240
+                <view className='room-box-info-ROOM'>
241
+                  <view className='room-bi-name-ROOM' >
242
+                    <view className='room-bin-title-ROOM'>房屋名称</view>
243
+                    <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
244
+                    </view>
208
                   </view>
245
                   </view>
209
                 </view>
246
                 </view>
210
-              </view>
211
-              {/* --------房屋位置-------- */}
212
-              {
213
-                !roomGps ? <view></view>
214
-                  :
215
-                  <view className='room-box-info-HouLocation'>
216
-                    <view className='room-bi-name-HouLocation' >
217
-                      <view className='room-bin-title-HouLocation'>房屋位置</view>
218
-                      <view className='room-bint-nameInfo-HouLocation'>
219
-                        <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
220
-                        <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
221
-                          <image className='room-bintn-image-HouLocation' src={GPS} />
222
-                          <text className='room-bintn-text-HouLocation'>去这里</text>
247
+                {/* --------房屋位置-------- */}
248
+                {
249
+                  !roomGps ? <view></view>
250
+                    :
251
+                    <view className='room-box-info-HouLocation'>
252
+                      <view className='room-bi-name-HouLocation' >
253
+                        <view className='room-bin-title-HouLocation'>房屋位置</view>
254
+                        <view className='room-bint-nameInfo-HouLocation'>
255
+                          <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
256
+                          <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
257
+                            <image className='room-bintn-image-HouLocation' src={GPS} />
258
+                            <text className='room-bintn-text-HouLocation'>去这里</text>
259
+                          </view>
223
                         </view>
260
                         </view>
224
                       </view>
261
                       </view>
225
                     </view>
262
                     </view>
226
-                  </view>
227
 
263
 
228
-              }
229
-
230
-
231
-              {/* --------停车场-------- */}
232
-              {
233
-                !parkingGps ? <view></view>
234
-                  :
235
-                  <view className='room-box-info-Parking'>
236
-                    <view className='room-bi-name-Parking' >
237
-                      <view className='room-bin-title-Parking'>停车位置</view>
238
-                      <view className='room-bint-nameInfo-Parking'>
239
-                        <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
240
-                        <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
241
-                          <image className='room-bintn-image-Parking' src={GPS} />
242
-                          <text className='room-bintn-text-Parking'>去这里</text>
264
+                }
265
+
266
+
267
+                {/* --------停车场-------- */}
268
+                {
269
+                  !parkingGps ? <view></view>
270
+                    :
271
+                    <view className='room-box-info-Parking'>
272
+                      <view className='room-bi-name-Parking' >
273
+                        <view className='room-bin-title-Parking'>停车位置</view>
274
+                        <view className='room-bint-nameInfo-Parking'>
275
+                          <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
276
+                          <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
277
+                            <image className='room-bintn-image-Parking' src={GPS} />
278
+                            <text className='room-bintn-text-Parking'>去这里</text>
279
+                          </view>
243
                         </view>
280
                         </view>
244
                       </view>
281
                       </view>
245
                     </view>
282
                     </view>
246
-                  </view>
247
 
283
 
248
-              }
284
+                }
249
 
285
 
250
 
286
 
251
-              {/* --------无线网-------- */}
252
-              <view className='room-box-info-WIFIContent'>
253
-                <view className='room-bi-name-WIFIContent' >
254
-                  <view className='room-bin-title-WIFIContent'>WiFi信息</view>
255
-                  <view className='room-bint-nameInfo-WIFIContent'>
256
-                    <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
257
-                    <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
258
-                    <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
259
-                      <image className='room-bintn-image-WIFIContent' src={copy_logo} />
260
-                      <text className='room-bintn-text-WIFIContent'>复制</text>
287
+                {/* --------无线网-------- */}
288
+                <view className='room-box-info-WIFIContent'>
289
+                  <view className='room-bi-name-WIFIContent' >
290
+                    <view className='room-bin-title-WIFIContent'>WiFi信息</view>
291
+                    <view className='room-bint-nameInfo-WIFIContent'>
292
+                      <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
293
+                      <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
294
+                      <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
295
+                        <image className='room-bintn-image-WIFIContent' src={copy_logo} />
296
+                        <text className='room-bintn-text-WIFIContent'>复制</text>
297
+                      </view>
261
                     </view>
298
                     </view>
262
                   </view>
299
                   </view>
263
                 </view>
300
                 </view>
264
-              </view>
265
 
301
 
266
-              <view className='Guide-Content-box'  >
267
-                <view className='title-image' style={{ display: guideStyle }} >
268
-                  <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
269
-                  <text className='title-title-boss' >更多指引</text>
270
-                </view>
271
-                {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
272
-                {/* 
302
+                <view className='Guide-Content-box'  >
303
+                  <view className='title-image' style={{ display: guideStyle }} >
304
+                    <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
305
+                    <text className='title-title-boss' >更多指引</text>
306
+                  </view>
307
+                  {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
308
+                  {/* 
273
                 <view className='showMore' style={{ display: newextNum == AllextNum ? 'none' : '' }} onClick={extendMore}>
309
                 <view className='showMore' style={{ display: newextNum == AllextNum ? 'none' : '' }} onClick={extendMore}>
274
                   <view>点击查看更多</view>
310
                   <view>点击查看更多</view>
275
                   <image src={showMore} className='moreTip' />
311
                   <image src={showMore} className='moreTip' />
276
                 </view> */}
312
                 </view> */}
313
+                </view>
277
               </view>
314
               </view>
315
+            )
316
+          }
317
+          <view className='Guide-Content-box'>
318
+            <view className='title-image'>
319
+              <image mode='scaleToFill' className='title-image-cup' src={Cup} />
320
+              <text className='title-title-boss' >老板推荐好吃的</text>
278
             </view>
321
             </view>
279
-          )
280
-        }
281
-        <view className='Guide-Content-box'>
282
-          <view className='title-image'>
283
-            <image mode='scaleToFill' className='title-image-cup' src={Cup} />
284
-            <text className='title-title-boss' >老板推荐好吃的</text>
285
           </view>
322
           </view>
286
-        </view>
287
-        <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
288
-          {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
289
-        </view>
323
+          <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
324
+            {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
325
+          </view>
290
 
326
 
291
-      </view>
327
+        </view>
328
+      </SpinBox>
292
     </scroll-view>
329
     </scroll-view>
293
   )
330
   )
294
 }
331
 }