李志伟 3 lat temu
rodzic
commit
d27540e534

+ 1
- 0
src/components/foodCards/style.less Wyświetl plik

@@ -3,6 +3,7 @@
3 3
   box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
4 4
   border-radius: 12px;
5 5
   position: relative;
6
+  margin: 15px 5px;
6 7
   margin-bottom: 30px;
7 8
   overflow: hidden;
8 9
   background: radial-gradient(circle at 82% top,transparent 20px,#fff 0) top,

+ 2
- 9
src/pages/index/tabs/Recommend.jsx Wyświetl plik

@@ -1,20 +1,16 @@
1
-import Taro, { useRouter } from '@tarojs/taro'
2
-import { React, useState, useEffect, useRef } from 'react'
1
+import Taro from '@tarojs/taro'
2
+import { React, useState, useEffect } from 'react'
3 3
 import iconsearch from '@/assets/icons/housemantj/search.png'
4 4
 import locationimg from '@/assets/icons/housemantj/location.png'
5 5
 import Tip from '@/components/tip'
6 6
 import { getIndexType,  getResourceList } from '@/services/home'
7 7
 import Card from '../components/Card'
8
-import { getLocation } from '@/utils/location'
9
-
10 8
 import './less/Recommend.less'
11 9
 
12 10
 
13 11
 export default (props) => {
14 12
   const { router, person, location } = props
15 13
   const [activeTab, setActiveTab] = useState(0)
16
-  const { params } = useRouter()
17
-  const { tabJump } = params || {}
18 14
   const [typeList, setTypeList] = useState([])
19 15
   
20 16
   
@@ -56,9 +52,6 @@ export default (props) => {
56 52
     Taro.navigateTo({ url: '/pages/search/search' });
57 53
   }
58 54
 
59
-
60
-
61
-  
62 55
   return (
63 56
     <view style={{ height: '100%', overflow: 'auto' }}>
64 57
       <view className='search' onClick={onSearch}>

+ 3
- 0
src/pages/search/search.config.js Wyświetl plik

@@ -1,4 +1,7 @@
1 1
 export default {
2 2
     navigationBarTitleText: '搜索',
3 3
     navigationStyle: 'custom',
4
+    usingComponents: {
5
+      "mp-searchbar": "weui-miniprogram/searchbar/searchbar", 
6
+    },
4 7
   }

+ 30
- 19
src/pages/search/search.jsx Wyświetl plik

@@ -1,33 +1,43 @@
1
-import React from 'react'
2
-import iconsearch from '../../assets/icons/housemantj/search.png'
3
-import './search.less'
4 1
 import CustomNav from '@/components/CustomNav'
5
-import '../index/index.less'
6 2
 import Taro from '@tarojs/taro'
7 3
 import withLayout from '@/layouts'
4
+import { getIndexSearch } from '@/services/home'
5
+import { useEffect, useState } from 'react'
6
+import SearchBar from '@/components/SearchBar'
7
+import './search.less'
8
+
8 9
 
9 10
 export default withLayout((props) => {
10
-    const { router, person } = props
11
-    const goLook=()=>{
12
-        Taro.navigateTo({ url:'/pages/searchResult/searchResult'});
11
+    const { router, person } = props    
12
+    const [hotList, setHotList] = useState([])
13
+    const hotSearch = (val) => {
14
+        Taro.navigateTo({ url: `/pages/searchResult/searchResult?q=${val}` });
13 15
     }
14
-    
15
-return (
16
+    const onSearch = (e) => {
17
+        if (e.detail.value !== '') {
18
+            Taro.navigateTo({ url: `/pages/searchResult/searchResult?q=${e.detail.value}` });
19
+        }
20
+    }
21
+    useEffect(() => {
22
+        getIndexSearch().then((res) => {
23
+            setHotList(res || [])
24
+        })
25
+    }, [])
26
+    return (
16 27
         <view className='page-index'>
17 28
             <view className='index-navbar'>
18
-                <CustomNav title='搜索' />                 
19
-            </view>
20
-            
21
-            <view className='search'>
22
-                <input className='searchInput' placeholder='请输入景区/城市搜索'/>
23
-                <image className='searchicon' src={iconsearch} />
24
-                <view className='lineSearch'></view>
29
+                <CustomNav title='搜索' />
25 30
             </view>
31
+
32
+            <SearchBar placeholder='请输入景区/城市搜索' onBlur={onSearch} />
33
+
26 34
             <view className='content'>
27 35
                 <view className='hotSearch'>热门搜索</view>
28 36
                 <view className='hotSearchtip'>
29
-                    <view onClick={goLook}>小龙虾</view>
30
-                    <view>小笼包</view>
37
+                    {
38
+                        hotList?.map((item) => <view onClick={()=>hotSearch(item.word)}>{item.word}</view>)
39
+                    }
40
+                    {/* <view onClick={goLook}>小龙虾</view>
31 41
                     <view>小笼包</view>
32 42
                     <view>小笼包</view>
33 43
                     <view>小笼包</view>
@@ -41,8 +51,9 @@ return (
41 51
                     <view>小笼包</view>
42 52
                     <view>小笼包</view>
43 53
                     <view>小笼包</view>
54
+                    <view>小笼包</view> */}
44 55
                 </view>
45
-            </view>  
56
+            </view>
46 57
 
47 58
         </view>
48 59
     )

+ 0
- 28
src/pages/search/search.less Wyświetl plik

@@ -1,31 +1,3 @@
1
-.search{
2
-  padding: 10px 30px 0 30px;
3
-  position: relative;
4
-  .searchInput{    
5
-      height: 68px;
6
-      background: #F8F8F8;
7
-      border-radius: 34px;
8
-      padding-left: 86px;
9
-      box-sizing: border-box;
10
-      font-size: 24px;
11
-  }
12
-  .searchicon{
13
-    width: 25px;
14
-    height: 25px;
15
-    position: absolute;
16
-    bottom: 21px;
17
-    left: 50px;
18
-  }
19
-  .lineSearch{      
20
-    position: absolute;
21
-    bottom: 19px;
22
-    left: 95px;
23
-    width: 1px;
24
-    height: 28px;
25
-    background: #000;
26
-    opacity: 0.2;
27
-  }    
28
-}
29 1
 .content{
30 2
   padding: 60px 30px;
31 3
   .hotSearch{

+ 22
- 232
src/pages/searchResult/searchResult.jsx Wyświetl plik

@@ -1,7 +1,6 @@
1 1
 import { React, useState, useEffect, } from 'react'
2 2
 // .就是当前路径
3 3
 import iconsearch from '../../assets/icons/housemantj/search.png'
4
-import location from '../../assets/icons/housemantj/location.png'
5 4
 import msImage from '../../assets/icons/housemantj/ms.jpg'
6 5
 import mjImage from '../../assets/icons/housemantj/mj.jpg'
7 6
 import glImage from '../../assets/icons/housemantj/gl.jpg'
@@ -10,45 +9,44 @@ import mjTip from '../../assets/icons/housemantj/mjtip.png'
10 9
 import glTip from '../../assets/icons/housemantj/gltip.png'
11 10
 import onlove from '../../assets/icons/housemantj/onlove.png'
12 11
 import CustomNav from '@/components/CustomNav'
13
-import Taro, { useRouter } from '@tarojs/taro'
12
+import Taro from '@tarojs/taro'
13
+import Card from '../index/components/Card'
14
+
14 15
 import './searchResult.less'
15 16
 import withLayout from '@/layouts'
16 17
 
17 18
 
18 19
 
19 20
 export default withLayout((props) => {
20
-  const { router, person } = props
21
+  const { router, person,location } = props
22
+  const { q} = props.router.params
21 23
 
24
+console.log(location,q)
22 25
   // 横向tab
23 26
   const [activeTab, setActiveTab] = useState(0)
24
-  const { params } = useRouter()
25
-  const { tabJump } = params || {}
26
-  useEffect(() => {
27
-    if (tabJump) {
28
-      setActiveTab(tabJump - 0)
29
-    }
30
-  }, [tabJump])
27
+  const [queryParams, setQueryParams] = useState({q:q, location: location, pageNum: 1, pageSize: 10, typeId: '' })
31 28
 
29
+  // 获取资源表信息
30
+  const [alllist, setAllList] = useState([])
32 31
   const tabs = [
33 32
     {
34 33
       title: '全部',
35 34
     },
36 35
     {
37 36
       title: '美食',
38
-
39 37
     },
40 38
     {
41 39
       title: '景点',
42
-
43
-    },
44
-    {
45
-      title: '攻略',
46
-
47 40
     },
48 41
   ]
49 42
   const handleTabChange = (e) => {
50 43
     const { index } = e.detail
51 44
     setActiveTab(index)
45
+    if (index == 0) {
46
+      setQueryParams({q:q, location: location, pageNum: 1, pageSize: 10, typeId: '' })
47
+    }
48
+    // else if(index==1){}
49
+    // else{}
52 50
   }
53 51
 
54 52
 
@@ -58,7 +56,11 @@ export default withLayout((props) => {
58 56
     Taro.navigateTo({ url: '/pages/search/search' });
59 57
   }
60 58
 
61
-
59
+  useEffect(() => {
60
+    getResourceList(queryParams).then((res) => {
61
+      setAllList(res.records || [])
62
+    })
63
+  }, [queryParams])
62 64
 
63 65
 
64 66
 
@@ -87,221 +89,9 @@ export default withLayout((props) => {
87 89
 
88 90
         <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" >
89 91
           <view className="waterfall">
90
-
91
-            {activeTab === 0 && <>
92
-              <view className='contentCard'>
93
-                <view className='cardTop'>
94
-                  <image mode='widthFix' src={msImage} className='cCardimg' />
95
-                  <image className='lefttips' src={msTip} />
96
-                  <image src={onlove} className='loveharde'></image>
97
-                </view>
98
-                <view className='bContent'>
99
-                  <view className='cCword'>
100
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
101
-                  </view>
102
-                  <view className='cCleft'>
103
-                    <image src={location} className='cCicon'></image>
104
-                    <view className='distance'><text>9.99</text>公里</view>
105
-                  </view>
106
-                  <view className='cCright'>
107
-                    <view className='money'>¥</view>
108
-                    <view className='price'><text>999</text>/人</view>
109
-                  </view>
110
-                </view>
111
-              </view>
112
-              <view className='contentCard'>
113
-                <view className='cardTop'>
114
-                  <image mode='widthFix' src={mjImage} className='cCardimg' />
115
-                  <image className='lefttips' src={mjTip} />
116
-                  <image src={onlove} className='loveharde'></image>
117
-                </view>
118
-                <view className='bContent'>
119
-                  <view className='cCword'>
120
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
121
-                  </view>
122
-                  <view className='cCleft'>
123
-                    <image src={location} className='cCicon'></image>
124
-                    <view className='distance'><text>9.99</text>公里</view>
125
-                  </view>
126
-                  <view className='cCright'>
127
-                    <view className='money'>¥</view>
128
-                    <view className='price'><text>999</text>/人</view>
129
-                  </view>
130
-                </view>
131
-              </view>
132
-              <view className='contentCard'>
133
-                <view className='cardTop'>
134
-                  <image mode='widthFix' src={glImage} className='cCardimg' />
135
-                  <image className='lefttips' src={glTip} />
136
-                  <image src={onlove} className='loveharde'></image>
137
-                </view>
138
-                <view className='bContent'>
139
-                  <view className='cCword'>
140
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
141
-                  </view>
142
-                  <view className='cCleft'>
143
-                    <image src={location} className='cCicon'></image>
144
-                    <view className='distance'><text>9.99</text>公里</view>
145
-                  </view>
146
-                  <view className='cCright'>
147
-                    <view className='money'>¥</view>
148
-                    <view className='price'><text>999</text>/人</view>
149
-                  </view>
150
-                </view>
151
-              </view>
152
-              <view className='contentCard'>
153
-                <view className='cardTop'>
154
-                  <image mode='widthFix' src={mjImage} className='cCardimg' />
155
-                  <image className='lefttips' src={mjTip} />
156
-                  <image src={onlove} className='loveharde'></image>
157
-                </view>
158
-                <view className='bContent'>
159
-                  <view className='cCword'>
160
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
161
-                  </view>
162
-                  <view className='cCleft'>
163
-                    <image src={location} className='cCicon'></image>
164
-                    <view className='distance'><text>9.99</text>公里</view>
165
-                  </view>
166
-                  <view className='cCright'>
167
-                    <view className='money'>¥</view>
168
-                    <view className='price'><text>999</text>/人</view>
169
-                  </view>
170
-                </view>
171
-              </view>
172
-
173
-            </>}
174
-            {activeTab === 1 && <>
175
-              <view className='contentCard'>
176
-                <view className='cardTop'>
177
-                  <image mode='widthFix' src={msImage} className='cCardimg' />
178
-                  <image className='lefttips' src={msTip} />
179
-                  <image src={onlove} className='loveharde'></image>
180
-                </view>
181
-                <view className='bContent'>
182
-                  <view className='cCword'>
183
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
184
-                  </view>
185
-                  <view className='cCleft'>
186
-                    <image src={location} className='cCicon'></image>
187
-                    <view className='distance'><text>9.99</text>公里</view>
188
-                  </view>
189
-                  <view className='cCright'>
190
-                    <view className='money'>¥</view>
191
-                    <view className='price'><text>999</text>/人</view>
192
-                  </view>
193
-                </view>
194
-              </view>
195
-
196
-            </>}
197
-            {activeTab === 2 && <>
198
-              <view className='contentCard'>
199
-                <view className='cardTop'>
200
-                  <image mode='widthFix' src={mjImage} className='cCardimg' />
201
-                  <image className='lefttips' src={mjTip} />
202
-                  <image src={onlove} className='loveharde'></image>
203
-                </view>
204
-                <view className='bContent'>
205
-                  <view className='cCword'>
206
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
207
-                  </view>
208
-                  <view className='cCleft'>
209
-                    <image src={location} className='cCicon'></image>
210
-                    <view className='distance'><text>9.99</text>公里</view>
211
-                  </view>
212
-                  <view className='cCright'>
213
-                    <view className='money'>¥</view>
214
-                    <view className='price'><text>999</text>/人</view>
215
-                  </view>
216
-                </view>
217
-              </view>
218
-              <view className='contentCard'>
219
-                <view className='cardTop'>
220
-                  <image mode='widthFix' src={msImage} className='cCardimg' />
221
-                  <image className='lefttips' src={msTip} />
222
-                  <image src={onlove} className='loveharde'></image>
223
-                </view>
224
-                <view className='bContent'>
225
-                  <view className='cCword'>
226
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
227
-                  </view>
228
-                  <view className='cCleft'>
229
-                    <image src={location} className='cCicon'></image>
230
-                    <view className='distance'><text>9.99</text>公里</view>
231
-                  </view>
232
-                  <view className='cCright'>
233
-                    <view className='money'>¥</view>
234
-                    <view className='price'><text>999</text>/人</view>
235
-                  </view>
236
-                </view>
237
-              </view>
238
-
239
-            </>}
240
-            {activeTab === 3 && <>
241
-              <view className='contentCard'>
242
-                <view className='cardTop'>
243
-                  <image mode='widthFix' src={mjImage} className='cCardimg' />
244
-                  <image className='lefttips' src={mjTip} />
245
-                  <image src={onlove} className='loveharde'></image>
246
-                </view>
247
-                <view className='bContent'>
248
-                  <view className='cCword'>
249
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
250
-                  </view>
251
-                  <view className='cCleft'>
252
-                    <image src={location} className='cCicon'></image>
253
-                    <view className='distance'><text>9.99</text>公里</view>
254
-                  </view>
255
-                  <view className='cCright'>
256
-                    <view className='money'>¥</view>
257
-                    <view className='price'><text>999</text>/人</view>
258
-                  </view>
259
-                </view>
260
-              </view>
261
-              <view className='contentCard'>
262
-                <view className='cardTop'>
263
-                  <image mode='widthFix' src={msImage} className='cCardimg' />
264
-                  <image className='lefttips' src={msTip} />
265
-                  <image src={onlove} className='loveharde'></image>
266
-                </view>
267
-                <view className='bContent'>
268
-                  <view className='cCword'>
269
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
270
-                  </view>
271
-                  <view className='cCleft'>
272
-                    <image src={location} className='cCicon'></image>
273
-                    <view className='distance'><text>9.99</text>公里</view>
274
-                  </view>
275
-                  <view className='cCright'>
276
-                    <view className='money'>¥</view>
277
-                    <view className='price'><text>999</text>/人</view>
278
-                  </view>
279
-                </view>
280
-              </view>
281
-              <view className='contentCard'>
282
-                <view className='cardTop'>
283
-                  <image mode='widthFix' src={mjImage} className='cCardimg' />
284
-                  <image className='lefttips' src={mjTip} />
285
-                  <image src={onlove} className='loveharde'></image>
286
-                </view>
287
-                <view className='bContent'>
288
-                  <view className='cCword'>
289
-                    超划算套餐?这么便宜也是第一次见6荤6素1...
290
-                  </view>
291
-                  <view className='cCleft'>
292
-                    <image src={location} className='cCicon'></image>
293
-                    <view className='distance'><text>9.99</text>公里</view>
294
-                  </view>
295
-                  <view className='cCright'>
296
-                    <view className='money'>¥</view>
297
-                    <view className='price'><text>999</text>/人</view>
298
-                  </view>
299
-                </view>
300
-              </view>
301
-
302
-            </>}
303
-
304
-
92
+            {
93
+              alllist?.map((item) => <Card key={item.resourceNo} item={item} />)
94
+            }
305 95
           </view>
306 96
           <view className='botton'>已经到底了~</view>
307 97
         </scroll-view>

+ 1
- 2
src/services/home.js Wyświetl plik

@@ -112,7 +112,6 @@ export const saveLike = (targetType, targetId) => request(`/${targetType}/like/$
112 112
  */
113 113
 export const removeLike = (targetType, targetId) => request(`/${targetType}/like/${targetId}`, { method: 'delete' })
114 114
 
115
-//缺少套餐订单生成
116 115
 
117 116
 
118 117
 
@@ -120,4 +119,4 @@ export const removeLike = (targetType, targetId) => request(`/${targetType}/like
120 119
  * 获取搜索列表
121 120
  * @returns 
122 121
  */
123
-export const getIndexSearch = (params) => request('/taSearch', { params })
122
+export const getIndexSearch = (params) => request('/hot-word', { params })

+ 0
- 26
src/utils/location.js Wyświetl plik

@@ -1,26 +0,0 @@
1
-
2
-import Taro from '@tarojs/taro'
3
-
4
-export function getLocation() {
5
-  return new Promise((resolve, reject) => {
6
-    Taro.authorize({
7
-      scope: 'scope.userLocation',
8
-      success: () => {
9
-        Taro.getLocation({
10
-          type: 'wgs84',
11
-          success: (res) => {
12
-            resolve(res)
13
-          },
14
-          fail: (err) => {
15
-            console.error(err)
16
-            reject(err)
17
-          }
18
-        })
19
-      },
20
-      fail: (err) => {
21
-        console.error(err)
22
-        reject(err)
23
-      }
24
-    })
25
-  })
26
-}