Selaa lähdekoodia

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

李志伟 3 vuotta sitten
vanhempi
commit
29f707c256

+ 2
- 1
config/dev.js Näytä tiedosto

@@ -4,7 +4,8 @@ module.exports = {
4 4
   },
5 5
   defineConstants: {
6 6
     // HOST: '"http://192.168.89.147:8080"',
7
-    HOST: '"http://sgl-v2-test.njyunzhi.com"',
7
+    HOST: '"https://sgl-v2.njyunzhi.com"',
8
+    OSS: '"yz-shigongli.oss-accelerate.aliyuncs.com"',
8 9
   },
9 10
   mini: {},
10 11
   h5: {}

+ 2
- 1
config/prod.js Näytä tiedosto

@@ -3,7 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"production"'
4 4
   },
5 5
   defineConstants: {
6
-    HOST: '"http://sgl-v2.njyunzhi.com"',
6
+    HOST: '"https://sgl-v2.njyunzhi.com"',
7
+    OSS: '"yz-shigongli.oss-accelerate.aliyuncs.com"',
7 8
   },
8 9
   mini: {},
9 10
   h5: {

+ 2
- 1
src/pages/index/components/Card/index.jsx Näytä tiedosto

@@ -2,6 +2,7 @@
2 2
 import { useMemo } from 'react'
3 3
 import Taro from '@tarojs/taro'
4 4
 import useSave from "@/utils/hooks/useSave"
5
+import { compressImage } from '@/utils'
5 6
 import msTip from '@/assets/icons/housemantj/foodtip.png'
6 7
 import mjTip from '@/assets/icons/housemantj/mjtip.png'
7 8
 import location from '@/assets/icons/housemantj/location.png'
@@ -39,7 +40,7 @@ export default (props) => {
39 40
     <view className={uqClass} style={{ overflow: 'hidden' }}>
40 41
       <view className='contentCard' style={style}>
41 42
         <view className='cardTop'>
42
-          <image mode='widthFix' onClick={Detail} src={item.poster} className='cCardimg' onLoad={handleLoad} />
43
+          <image mode='widthFix' onClick={Detail} src={compressImage(item.poster)} className='cCardimg' onLoad={handleLoad} />
43 44
           <image className='lefttips' src={item.targetType === 'tourist' ? mjTip : msTip} />
44 45
           <image onClick={toggleSave} src={isSaved > 0 ? onlove : love} className='loveharde'></image>
45 46
         </view>

+ 82
- 91
src/pages/index/tabs/Guide.jsx Näytä tiedosto

@@ -33,13 +33,12 @@ export default (props) => {
33 33
   const trackClick = useTrackClick(router)
34 34
 
35 35
   const [taRoomContent, setTaRoomContent] = useState([])
36
-  const RoomLocation = taRoomContent?.location
37 36
   //没有停车 wifi的就不显示按钮
38 37
   const [wifiButtonStyle, setWifiButtonStyle] = useState('')
39 38
   const [parkingButtonStyle, setParkingButtonStyle] = useState('')
40 39
   const [guideStyle, setGuideStyle] = useState('')
41
-  const parkingGps = taRoomContent?.parkingLocation
42
-  const roomGps = taRoomContent?.location
40
+  const parkingGps = taRoomContent.parkingLocation || []
41
+  const roomGps = taRoomContent.location || []
43 42
 
44 43
 
45 44
 
@@ -81,26 +80,17 @@ export default (props) => {
81 80
       setLoading(true)
82 81
       // 点击’去这里‘跳转导航
83 82
       getTaRoom(roomId).then((res) => {
84
-        // Roomlog.current = (!res.location).toString().split(',')[0]
85
-        // Roomlat.current = (!res.location).toString().split(',')[1]
86
-        // Parklog.current = (!res.parkingLocation).toString().split(',')[0]
87
-        // Parklat.current = (!res.parkingLocation).toString().split(',')[1]
88 83
         setTaRoomContent(res || [])
89 84
         setLoading(false)
90 85
       })
91 86
       //更多指引
92 87
       geiZy()
93
-
94
-      getRecommendList({ location: location }).then((res) => {
88
+      getRecommendList({ location: roomGps }).then((res) => {
95 89
         setPackage(res || [])
96 90
         setLoading(false)
97
-
98 91
       })
99
-      // setLoading(false)
100
-
101 92
     } else {
102 93
       setLoading(true)
103
-
104 94
       getRecommendList({ location: location }).then((res) => {
105 95
         setPackage(res || [])
106 96
         setLoading(false)
@@ -114,7 +104,7 @@ export default (props) => {
114 104
     if (taRoomContent?.parkingAddress === "") {
115 105
       setParkingButtonStyle('none')
116 106
     }
117
-  }, [roomId, RoomLocation, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
107
+  }, [roomId, roomGps, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
118 108
 
119 109
 
120 110
   const goRoomMap = () => {
@@ -160,102 +150,103 @@ export default (props) => {
160 150
 
161 151
   return (
162 152
     <scroll-view scrollY style={{ height: '100%' }}  >
163
-        <view className='Guide-Home-box'>
164
-          {
165
-            ifroomId === 'havenot' && (
166
-              <view className='Guide-image-text-box'>
167
-                <image className='Guide-images' src={sleep} />
168
-                <view className='Guide-text'>您还没有入住订单哟~</view>
169
-              </view>
170
-            )
171
-          }
172
-          {/* 有民宿的情况下 */}
173
-          {
174
-            ifroomId === 'reality' && (
175
-              <SpinBox loading={loading}>
176
-                <view className='room-box-info-ROOM'>
177
-                  <view className='room-bi-name-ROOM' >
178
-                    <view className='room-bin-title-ROOM'>房屋名称</view>
179
-                    <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
180
-                    </view>
153
+      <view className='Guide-Home-box'>
154
+        {
155
+          ifroomId === 'havenot' && (
156
+            <view className='Guide-image-text-box'>
157
+              <image className='Guide-images' src={sleep} />
158
+              <view className='Guide-text'>您还没有入住订单哟~</view>
159
+            </view>
160
+          )
161
+        }
162
+        {/* 有民宿的情况下 */}
163
+        {
164
+          ifroomId === 'reality' && (
165
+            <SpinBox loading={loading}>
166
+              <view className='room-box-info-ROOM'>
167
+                <view className='room-bi-name-ROOM' >
168
+                  <view className='room-bin-title-ROOM'>房屋名称</view>
169
+                  <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
181 170
                   </view>
182 171
                 </view>
183
-                {/* --------房屋位置-------- */}
184
-                {
185
-                  !roomGps ? <view></view>
186
-                    :
187
-                    <view className='room-box-info-HouLocation'>
188
-                      <view className='room-bi-name-HouLocation' >
189
-                        <view className='room-bin-title-HouLocation'>房屋位置</view>
190
-                        <view className='room-bint-nameInfo-HouLocation'>
191
-                          <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
192
-                          <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
193
-                            <image className='room-bintn-image-HouLocation' src={GPS} />
194
-                            <text className='room-bintn-text-HouLocation'>去这里</text>
195
-                          </view>
172
+              </view>
173
+              {/* --------房屋位置-------- */}
174
+              {
175
+                !roomGps ? <view></view>
176
+                  :
177
+                  <view className='room-box-info-HouLocation'>
178
+                    <view className='room-bi-name-HouLocation' >
179
+                      <view className='room-bin-title-HouLocation'>房屋位置</view>
180
+                      <view className='room-bint-nameInfo-HouLocation'>
181
+                        <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
182
+                        <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
183
+                          <image className='room-bintn-image-HouLocation' src={GPS} />
184
+                          <text className='room-bintn-text-HouLocation'>去这里</text>
196 185
                         </view>
197 186
                       </view>
198 187
                     </view>
199
-                }
188
+                  </view>
200 189
 
201
-                {/* --------停车场-------- */}
202
-                {
203
-                  !parkingGps ? <view></view>
204
-                    :
205
-                    <view className='room-box-info-Parking'>
206
-                      <view className='room-bi-name-Parking' >
207
-                        <view className='room-bin-title-Parking'>停车位置</view>
208
-                        <view className='room-bint-nameInfo-Parking'>
209
-                          <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
210
-                          <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
211
-                            <image className='room-bintn-image-Parking' src={GPS} />
212
-                            <text className='room-bintn-text-Parking'>去这里</text>
213
-                          </view>
190
+              }
191
+
192
+
193
+              {/* --------停车场-------- */}
194
+              {
195
+                !parkingGps ? <view></view>
196
+                  :
197
+                  <view className='room-box-info-Parking'>
198
+                    <view className='room-bi-name-Parking' >
199
+                      <view className='room-bin-title-Parking'>停车位置</view>
200
+                      <view className='room-bint-nameInfo-Parking'>
201
+                        <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
202
+                        <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
203
+                          <image className='room-bintn-image-Parking' src={GPS} />
204
+                          <text className='room-bintn-text-Parking'>去这里</text>
214 205
                         </view>
215 206
                       </view>
216 207
                     </view>
208
+                  </view>
217 209
 
218
-                }
210
+              }
219 211
 
220 212
 
221
-                {/* --------无线网-------- */}
222
-                <view className='room-box-info-WIFIContent'>
223
-                  <view className='room-bi-name-WIFIContent' >
224
-                    <view className='room-bin-title-WIFIContent'>WiFi信息</view>
225
-                    <view className='room-bint-nameInfo-WIFIContent'>
226
-                      <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
227
-                      <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
228
-                      <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
229
-                        <image className='room-bintn-image-WIFIContent' src={copy_logo} />
230
-                        <text className='room-bintn-text-WIFIContent'>复制</text>
231
-                      </view>
213
+              {/* --------无线网-------- */}
214
+              <view className='room-box-info-WIFIContent'>
215
+                <view className='room-bi-name-WIFIContent' >
216
+                  <view className='room-bin-title-WIFIContent'>WiFi信息</view>
217
+                  <view className='room-bint-nameInfo-WIFIContent'>
218
+                    <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
219
+                    <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
220
+                    <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
221
+                      <image className='room-bintn-image-WIFIContent' src={copy_logo} />
222
+                      <text className='room-bintn-text-WIFIContent'>复制</text>
232 223
                     </view>
233 224
                   </view>
234 225
                 </view>
226
+              </view>
235 227
 
236
-                <view className='Guide-Content-box'  >
237
-                  <view className='title-image' style={{ display: guideStyle }} >
238
-                    <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
239
-                    <text className='title-title-boss' >更多指引</text>
240
-                  </view>
241
-                  <view style={{ padding: '0 30rpx', boxSizing: 'border-box' }}>
242
-                    {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
243
-                  </view>
228
+              <view className='Guide-Content-box'  >
229
+                <view className='title-image' style={{ display: guideStyle }} >
230
+                  <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
231
+                  <text className='title-title-boss' >更多指引</text>
244 232
                 </view>
245
-              </SpinBox>
246
-            )
247
-          }
248
-          <view className='Guide-Content-box'>
249
-            <view className='title-image'>
250
-              <image mode='scaleToFill' className='title-image-cup' src={Cup} />
251
-              <text className='title-title-boss' >老板推荐好吃的</text>
252
-            </view>
253
-          </view>
254
-          <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
255
-            {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
233
+                <view style={{ padding: '0 30rpx', boxSizing: 'border-box' }}>
234
+                  {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
235
+                </view>
236
+              </view>
237
+            </SpinBox>
238
+          )
239
+        }
240
+        <view className='Guide-Content-box'>
241
+          <view className='title-image'>
242
+            <image mode='scaleToFill' className='title-image-cup' src={Cup} />
243
+            <text className='title-title-boss' >老板推荐好吃的</text>
256 244
           </view>
257
-
258 245
         </view>
246
+        <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
247
+          {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
248
+        </view>
249
+      </view>
259 250
     </scroll-view>
260 251
   )
261 252
 }

+ 23
- 27
src/pages/index/tabs/Recommend.jsx Näytä tiedosto

@@ -26,6 +26,8 @@ export default (props) => {
26 26
   // 获取资源表信息
27 27
   // const [alllist, setAllList] = useState([])
28 28
   const [listData, setListData] = useState({ list: [], rfTimes: 0 })
29
+  const { isSaved } = listData
30
+
29 31
 
30 32
   //分类标签
31 33
   const tabs = [{ title: '附近' }].concat(typeList.map(x => ({ ...x, title: x.typeName })))
@@ -54,6 +56,7 @@ export default (props) => {
54 56
     setListData({ list: value, rfTimes: rfTimes.current })
55 57
   }
56 58
 
59
+
57 60
   useEffect(() => {
58 61
     //查询分类标签表
59 62
     getIndexType({ pageSize: 20 }).then((res) => {
@@ -65,17 +68,10 @@ export default (props) => {
65 68
     // 用绝对路径
66 69
     Taro.navigateTo({ url: '/pages/search/search' });
67 70
   }
68
-  // // 联动收藏
69
-  // const likeLook = () => {
70
-  //   getResourceList().then(e => {
71
-  //     setAllList(e.records)
72
-  //   })
73
-
74
-  // }
75 71
 
76
-  // useDidShow(() => {
77
-  //   likeLook()
78
-  // })
72
+  useDidShow(() => {
73
+    setQueryParams({ ...queryParams })
74
+  })
79 75
 
80 76
   return (
81 77
     // <view style={{ height: '100%', overflow: 'hidden',display:'flex',flexDirection:'column' }}>
@@ -106,22 +102,22 @@ export default (props) => {
106 102
         </scroll-view>
107 103
       </view>
108 104
       {/* <View style={{ flex:'auto' }}> */}
109
-        <List
110
-          ref={listRef}
111
-          style={listStyle}
112
-          request={getResourceList}
113
-          params={queryParams}
114
-          onDataChange={handleDataChange}
115
-        >
116
-          <view style={{ padding: '30rpx 15rpx' }}>
117
-            <MasonryLayout
118
-              itemKey='resourceNo'
119
-              listData={listData}
120
-              render={(item, callback) => <Card item={item} onImageLoad={callback} />}
121
-            />
122
-          </view>
123
-
124
-          {/* {
105
+      <List
106
+        ref={listRef}
107
+        style={listStyle}
108
+        request={getResourceList}
109
+        params={queryParams}
110
+        onDataChange={handleDataChange}
111
+      >
112
+        <view style={{ padding: '30rpx 15rpx' }}>
113
+          <MasonryLayout
114
+            itemKey='resourceNo'
115
+            listData={listData}
116
+            render={(item, callback) => <Card item={item} onImageLoad={callback} />}
117
+          />
118
+        </view>
119
+
120
+        {/* {
125 121
             alllist.length == 0 ?
126 122
               <NoData /> :
127 123
               <view className='waterfall'>
@@ -130,7 +126,7 @@ export default (props) => {
130 126
                 }
131 127
               </view>
132 128
           } */}
133
-        </List>
129
+      </List>
134 130
       {/* </View> */}
135 131
     </view>
136 132
   )

+ 19
- 0
src/utils/index.js Näytä tiedosto

@@ -44,3 +44,22 @@ export function getQueryString(params) {
44 44
 
45 45
   return arr.filter(Boolean).join('&')
46 46
 }
47
+
48
+/**
49
+ * 压缩图片
50
+ * @param {*} url 
51
+ * @returns 
52
+ */
53
+export function compressImage(url) {
54
+  if (!url) return url;
55
+
56
+  // GIF 不压缩
57
+  if (url.indexOf('.gif') > -1) return url;
58
+
59
+  // eslint-disable-next-line no-undef
60
+  if (url.indexOf(OSS) > -1) {
61
+    return `${url}?x-oss-process=style/cmp80`
62
+  }
63
+
64
+  return url;
65
+}