Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/shigongli/miniapp-v2 into dev

张延森 3 years ago
parent
commit
f4f05e621b
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,4 +1,6 @@
1 1
 import React, { useEffect, useRef, useState, useImperativeHandle } from 'react';
2
+import SpinBox from "@/components/Spin/SpinBox";
3
+
2 4
 import { ScrollView } from '@tarojs/components';
3 5
 import Taro from '@tarojs/taro';
4 6
 
@@ -14,6 +16,7 @@ export default React.forwardRef((props, ref) => {
14 16
     className,
15 17
     ...leftProps
16 18
   } = props
19
+  const [loading, setLoading] = useState(false)
17 20
 
18 21
   const contextRef = useRef()
19 22
   const loadingRef = useRef(false)
@@ -37,7 +40,7 @@ export default React.forwardRef((props, ref) => {
37 40
   const fetchList = (params) => {
38 41
     if (!request) return;
39 42
 
40
-    Taro.showLoading()
43
+    setLoading(true)
41 44
     loadingRef.current = true
42 45
     request(params).then((res) => {
43 46
       const { records, ...pageInfo } = res || {}
@@ -49,11 +52,14 @@ export default React.forwardRef((props, ref) => {
49 52
 
50 53
       pageRef.current = pageInfo
51 54
       loadingRef.current = false
52
-      Taro.hideLoading()
55
+
56
+      setLoading(false)
57
+
53 58
     }).catch((err) => {
54 59
       loadingRef.current = false
55 60
       console.error(err)
56
-      Taro.hideLoading()
61
+      setLoading(false)
62
+
57 63
       if (onError) {
58 64
         onError(err)
59 65
       }
@@ -93,6 +99,7 @@ export default React.forwardRef((props, ref) => {
93 99
   }))
94 100
 
95 101
   return (
102
+
96 103
     <ScrollView
97 104
       scrollY
98 105
       enhanced
@@ -100,13 +107,20 @@ export default React.forwardRef((props, ref) => {
100 107
       {...leftProps}
101 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 125
     </ScrollView>
112 126
   )

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

@@ -2,6 +2,8 @@ import { useState, useEffect, useRef } from "react";
2 2
 import Taro, { useDidShow } from '@tarojs/taro'
3 3
 import MoreGuide from "@/components/MoreGuide";
4 4
 import BossCard from '@/components/BossCard'
5
+import SpinBox from "@/components/Spin/SpinBox";
6
+
5 7
 import GPS from '@/assets/icons/GuideCheck/GPS.png'
6 8
 import copy_logo from '@/assets/icons/GuideCheck/copy_logo.png'
7 9
 import Cup from '@/assets/icons/GuideCheck/Cup.png'
@@ -21,6 +23,7 @@ export default (props) => {
21 23
   const [extend, setExtend] = useState([])
22 24
   const [ifroomId, setIfroomId] = useState('havenot')
23 25
   const [spackage, setPackage] = useState([])
26
+  const [loading, setLoading] = useState(false)
24 27
 
25 28
   const { roomId: rid } = useModel('hotel')
26 29
 
@@ -76,26 +79,42 @@ export default (props) => {
76 79
     goContent()
77 80
     if (roomId) {
78 81
       // 点击’去这里‘跳转导航
82
+      setLoading(true)
79 83
       getTaRoom(roomId).then((res) => {
80 84
         Roomlog.current = (res.location).toString().split(',')[0]
81 85
         Roomlat.current = (res.location).toString().split(',')[1]
82 86
         Parklog.current = (res.parkingLocation).toString().split(',')[0]
83 87
         Parklat.current = (res.parkingLocation).toString().split(',')[1]
84 88
         setTaRoomContent(res || [])
89
+        setLoading(false)
90
+
85 91
       })
86 92
       //更多指引
93
+      setLoading(true)
94
+
87 95
       getExtendContent('room', roomId).then((res) => {
88 96
         setExtend(res.records || [])
89 97
         setIfroomId('reality')
90 98
         setAllextNum(res.total)
91 99
         setNewextNum(res.records.length)
100
+        setLoading(false)
101
+
92 102
       })
103
+      setLoading(true)
104
+
93 105
       getRecommendList({ location: location }).then((res) => {
94 106
         setPackage(res || [])
107
+        setLoading(false)
108
+
95 109
       })
110
+
96 111
     } else {
112
+      setLoading(true)
113
+
97 114
       getRecommendList({ location: location }).then((res) => {
98 115
         setPackage(res || [])
116
+        setLoading(false)
117
+
99 118
       })
100 119
       return
101 120
     }
@@ -112,6 +131,7 @@ export default (props) => {
112 131
   useEffect(() => {
113 132
 
114 133
     if (roomId) {
134
+      setLoading(true)
115 135
       // 点击’去这里‘跳转导航
116 136
       getTaRoom(roomId).then((res) => {
117 137
         Roomlog.current = (res.location).toString().split(',')[0]
@@ -119,20 +139,35 @@ export default (props) => {
119 139
         Parklog.current = (res.parkingLocation).toString().split(',')[0]
120 140
         Parklat.current = (res.parkingLocation).toString().split(',')[1]
121 141
         setTaRoomContent(res || [])
142
+        setLoading(false)
122 143
       })
123 144
       //更多指引
145
+      setLoading(true)
146
+
124 147
       getExtendContent('room', roomId).then((res) => {
125 148
         setExtend(res.records || [])
126 149
         setIfroomId('reality')
127 150
         setAllextNum(res.total)
128 151
         setNewextNum(res.records.length)
152
+        setLoading(false)
153
+
129 154
       })
155
+      setLoading(true)
156
+
130 157
       getRecommendList({ location: location }).then((res) => {
131 158
         setPackage(res || [])
159
+        setLoading(false)
160
+
132 161
       })
162
+      // setLoading(false)
163
+
133 164
     } else {
165
+      setLoading(true)
166
+
134 167
       getRecommendList({ location: location }).then((res) => {
135 168
         setPackage(res || [])
169
+        setLoading(false)
170
+
136 171
       })
137 172
       return
138 173
     }
@@ -186,109 +221,111 @@ export default (props) => {
186 221
 
187 222
   return (
188 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 245
                   </view>
209 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 260
                         </view>
224 261
                       </view>
225 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 280
                         </view>
244 281
                       </view>
245 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 298
                     </view>
262 299
                   </view>
263 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 309
                 <view className='showMore' style={{ display: newextNum == AllextNum ? 'none' : '' }} onClick={extendMore}>
274 310
                   <view>点击查看更多</view>
275 311
                   <image src={showMore} className='moreTip' />
276 312
                 </view> */}
313
+                </view>
277 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 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 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 329
     </scroll-view>
293 330
   )
294 331
 }