瀏覽代碼

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

吃个甘蔗嚼一年 3 年之前
父節點
當前提交
395de8bb01

+ 37
- 0
src/app.less 查看文件

1
+.page-index {
2
+  display: flex;
3
+  flex-direction: column;
4
+  width: 100vw;
5
+  height: 100vh;
6
+  overflow: hidden;
7
+  box-sizing: border-box;
8
+
9
+  .index-navbar {
10
+    flex: none;
11
+  }
12
+
13
+  .index-tabber {
14
+    flex: none;
15
+  }
16
+
17
+  .index-container {
18
+    flex: auto;
19
+    overflow: hidden;
20
+    position: relative;
21
+  }
22
+}
23
+
24
+.custom-tabbar {
25
+  background: #ffffff;
26
+  box-shadow: 0px -4px 6px 0px rgba(0, 0, 0, 0.08);
27
+
28
+  .weui-tabbar__label {
29
+    color: #c0c8d3;
30
+  }
31
+
32
+  .weui-bar__item_on {
33
+    .weui-tabbar__label {
34
+      color: #202020;
35
+    }
36
+  }
37
+}

二進制
src/assets/icons/housemantj/dp.jpg 查看文件


二進制
src/assets/icons/housemantj/fd.jpg 查看文件


二進制
src/assets/icons/housemantj/gl.jpg 查看文件


二進制
src/assets/icons/housemantj/mj.jpg 查看文件


二進制
src/assets/icons/housemantj/mj2.jpg 查看文件


二進制
src/assets/icons/housemantj/mj3.jpg 查看文件


+ 81
- 0
src/components/List/index.jsx 查看文件

1
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+import { ScrollView } from '@tarojs/components';
3
+import Taro from '@tarojs/taro';
4
+
5
+export default (props) => {
6
+  const {
7
+    render,
8
+    request,
9
+    params,
10
+    pageSize = 10,
11
+    onError,
12
+    onDataChange,
13
+    ...leftProps
14
+  } = props
15
+
16
+  const loadingRef = useRef(false)
17
+  const [payload, setPayload] = useState({})
18
+  const [list, setList] = useState([])
19
+  const pageRef = useRef({ current: 1, pages: 0 })
20
+
21
+  // 滚动
22
+  const handleScrollToLower = (e) => {
23
+    const loading = loadingRef.current
24
+    const hasMore = pageRef.current.current < pageRef.current.pages
25
+
26
+    if (!loading && hasMore) {
27
+      setPayload({
28
+        ...payload,
29
+        pageNum: pageRef.current.current + 1
30
+      })
31
+    }
32
+  }
33
+
34
+  // 联动状态, 设置查询参数
35
+  useEffect(() => {
36
+    setPayload({
37
+      ...params,
38
+      pageNum: 1,
39
+      pageSize,
40
+    })
41
+  }, [pageSize, params])
42
+
43
+  // 请求数据
44
+  useEffect(() => {
45
+    Taro.showLoading()
46
+    loadingRef.current = true
47
+    request(payload).then((res) => {
48
+      const { records, ...pageInfo } = res || {}
49
+
50
+      const lst = pageInfo.current === 1 ? records || [] : list.concat(records || [])
51
+      setList(lst)
52
+      if (onDataChange) {
53
+        onDataChange(lst)
54
+      }
55
+
56
+      pageRef.current = pageInfo
57
+      loadingRef.current = false
58
+      Taro.hideLoading()
59
+    }).catch((err) => {
60
+      loadingRef.current = false
61
+      console.error(err)
62
+      Taro.hideLoading()
63
+      if (onError) {
64
+        onError(err)
65
+      }
66
+    })
67
+  }, [payload])
68
+
69
+  return (
70
+    <ScrollView
71
+      scrollY
72
+      onScrollToLower={handleScrollToLower}
73
+      {...leftProps}
74
+    >
75
+      { !render
76
+          ? props.children
77
+          : list.map((item, index) => render({ item, index }))
78
+      }
79
+    </ScrollView>
80
+  )
81
+}

+ 1
- 0
src/pages/details/mjDetails/sceneryDetails.jsx 查看文件

16
 import useLike from "@/utils/hooks/useLike"
16
 import useLike from "@/utils/hooks/useLike"
17
 import Cards from '@/components/foodCards/foodCards.jsx'
17
 import Cards from '@/components/foodCards/foodCards.jsx'
18
 import Taro,{ useShareAppMessage } from '@tarojs/taro'
18
 import Taro,{ useShareAppMessage } from '@tarojs/taro'
19
+import { getResourceList } from '@/services/home'
19
 import Extend from '../components/Extend/extend'
20
 import Extend from '../components/Extend/extend'
20
 import './sceneryDetails.less'
21
 import './sceneryDetails.less'
21
 
22
 

+ 4
- 4
src/pages/index/components/Card.js 查看文件

10
 
10
 
11
 export default (props) => {
11
 export default (props) => {
12
 
12
 
13
-  const { item } = props
13
+  const { item, style } = props
14
 
14
 
15
   const [isSaved, toggleSave] = useSave(item.isSaved, item.targetType, item.targetId)
15
   const [isSaved, toggleSave] = useSave(item.isSaved, item.targetType, item.targetId)
16
   const Detail = () => {
16
   const Detail = () => {
17
     if (item.targetType == 'tourist') {
17
     if (item.targetType == 'tourist') {
18
-      let location = item.lng + ',' + item.lat
19
-      Taro.navigateTo({ url: `/pages/details/mjDetails/sceneryDetails?id=${item.targetId}&distance=${(item.distance / 1000).toFixed(2)}&location=${location}` });
18
+      let loc = item.lng + ',' + item.lat
19
+      Taro.navigateTo({ url: `/pages/details/mjDetails/sceneryDetails?id=${item.targetId}&distance=${(item.distance / 1000).toFixed(2)}&location=${loc}` });
20
     }
20
     }
21
     else {
21
     else {
22
       Taro.navigateTo({ url: `/pages/details/foodDetails/foodDetails?id=${item.targetId}` })
22
       Taro.navigateTo({ url: `/pages/details/foodDetails/foodDetails?id=${item.targetId}` })
23
     }
23
     }
24
   }
24
   }
25
   return (
25
   return (
26
-    <view className='contentCard'>
26
+    <view className='contentCard' style={style}>
27
       <view className='cardTop'>
27
       <view className='cardTop'>
28
         <image mode='widthFix' onClick={Detail} src={item.poster} className='cCardimg' />
28
         <image mode='widthFix' onClick={Detail} src={item.poster} className='cCardimg' />
29
         <image className='lefttips' src={item.targetType === 'tourist' ? mjTip : msTip} />
29
         <image className='lefttips' src={item.targetType === 'tourist' ? mjTip : msTip} />

+ 0
- 37
src/pages/index/index.less 查看文件

1
-.page-index {
2
-  display: flex;
3
-  flex-direction: column;
4
-  width: 100vw;
5
-  height: 100vh;
6
-  overflow: hidden;
7
-  box-sizing: border-box;
8
-
9
-  .index-navbar {
10
-    flex: none;
11
-  }
12
-
13
-  .index-tabber {
14
-    flex: none;
15
-  }
16
-
17
-  .index-container {
18
-    flex: auto;
19
-    overflow: hidden;
20
-    position: relative;
21
-  }
22
-}
23
-
24
-.custom-tabbar {
25
-  background: #ffffff;
26
-  box-shadow: 0px -4px 6px 0px rgba(0, 0, 0, 0.08);
27
-
28
-  .weui-tabbar__label {
29
-    color: #c0c8d3;
30
-  }
31
-
32
-  .weui-bar__item_on {
33
-    .weui-tabbar__label {
34
-      color: #202020;
35
-    }
36
-  }
37
-}

+ 10
- 13
src/pages/index/tabs/Recommend.jsx 查看文件

3
 import iconsearch from '@/assets/icons/housemantj/search.png'
3
 import iconsearch from '@/assets/icons/housemantj/search.png'
4
 import locationimg from '@/assets/icons/housemantj/location.png'
4
 import locationimg from '@/assets/icons/housemantj/location.png'
5
 import Tip from '@/components/tip'
5
 import Tip from '@/components/tip'
6
+import List from '@/components/List';
6
 import { getIndexType,  getResourceList } from '@/services/home'
7
 import { getIndexType,  getResourceList } from '@/services/home'
7
 import Card from '../components/Card'
8
 import Card from '../components/Card'
8
 import './less/Recommend.less'
9
 import './less/Recommend.less'
34
     }
35
     }
35
   }
36
   }
36
 
37
 
37
-  useEffect(() => {    
38
+  useEffect(() => {
38
     //查询分类标签表
39
     //查询分类标签表
39
     getIndexType({ pageSize: 20 }).then((res) => {
40
     getIndexType({ pageSize: 20 }).then((res) => {
40
       setTypeList(res.records || [])
41
       setTypeList(res.records || [])
41
     })    
42
     })    
42
   }, [])
43
   }, [])
43
-
44
-  useEffect(() => {
45
-      getResourceList(queryParams).then((res) => {
46
-        setAllList(res.records || [])
47
-      })
48
-    }, [queryParams])
49
-
50
   const onSearch = () => {
44
   const onSearch = () => {
51
     // 用绝对路径
45
     // 用绝对路径
52
     Taro.navigateTo({ url: '/pages/search/search' });
46
     Taro.navigateTo({ url: '/pages/search/search' });
53
   }
47
   }
54
 
48
 
55
   return (
49
   return (
56
-    <view style={{ height: '100%', overflow: 'auto' }}>
50
+    <view style={{ height: '100%', overflow: 'hidden' }}>
57
       <view className='search' onClick={onSearch}>
51
       <view className='search' onClick={onSearch}>
58
         <input className='searchInput' disabled />
52
         <input className='searchInput' disabled />
59
         <image className='searchicon' src={iconsearch} />
53
         <image className='searchicon' src={iconsearch} />
79
           </mp-tabs>
73
           </mp-tabs>
80
         </scroll-view>
74
         </scroll-view>
81
       </view>
75
       </view>
82
-      <scroll-view scroll-y='true' scroll-view='true'  	bindscrolltolower='lower' bindscrolltoupper='upper'	 bindscroll='scroll'
83
-      
76
+
77
+      <List
78
+        style={{ height: 'calc(100% - 160px)' }}
79
+        request={getResourceList}
80
+        params={queryParams}
81
+        onDataChange={setAllList}
84
       >
82
       >
85
         <view className='waterfall'>
83
         <view className='waterfall'>
86
           {
84
           {
87
             alllist.map((item) => <Card key={item.resourceNo} item={item} />)
85
             alllist.map((item) => <Card key={item.resourceNo} item={item} />)
88
           }
86
           }
89
         </view>
87
         </view>
90
-        <view className='botton'>已经到底了~</view>
91
-      </scroll-view>
88
+      </List>
92
     </view>
89
     </view>
93
   )
90
   )
94
 }
91
 }

+ 0
- 15
src/pages/search/search.jsx 查看文件

37
                     {
37
                     {
38
                         hotList?.map((item) => <view onClick={()=>hotSearch(item.word)}>{item.word}</view>)
38
                         hotList?.map((item) => <view onClick={()=>hotSearch(item.word)}>{item.word}</view>)
39
                     }
39
                     }
40
-                    {/* <view onClick={goLook}>小龙虾</view>
41
-                    <view>小笼包</view>
42
-                    <view>小笼包</view>
43
-                    <view>小笼包</view>
44
-                    <view>小笼包</view>
45
-                    <view>小笼包</view>
46
-                    <view>小笼包</view>
47
-                    <view>小笼包</view>
48
-                    <view>小笼包</view>
49
-                    <view>小笼包</view>
50
-                    <view>小笼包</view>
51
-                    <view>小笼包</view>
52
-                    <view>小笼包</view>
53
-                    <view>小笼包</view>
54
-                    <view>小笼包</view> */}
55
                 </view>
40
                 </view>
56
             </view>
41
             </view>
57
 
42
 

+ 9
- 13
src/pages/searchResult/searchResult.jsx 查看文件

1
 import { React, useState, useEffect, } from 'react'
1
 import { React, useState, useEffect, } from 'react'
2
 // .就是当前路径
2
 // .就是当前路径
3
 import iconsearch from '../../assets/icons/housemantj/search.png'
3
 import iconsearch from '../../assets/icons/housemantj/search.png'
4
-import msImage from '../../assets/icons/housemantj/ms.jpg'
5
-import mjImage from '../../assets/icons/housemantj/mj.jpg'
6
-import glImage from '../../assets/icons/housemantj/gl.jpg'
7
-import msTip from '../../assets/icons/housemantj/foodtip.png'
8
-import mjTip from '../../assets/icons/housemantj/mjtip.png'
9
-import glTip from '../../assets/icons/housemantj/gltip.png'
10
-import onlove from '../../assets/icons/housemantj/onlove.png'
11
 import CustomNav from '@/components/CustomNav'
4
 import CustomNav from '@/components/CustomNav'
12
 import Taro from '@tarojs/taro'
5
 import Taro from '@tarojs/taro'
13
 import Card from '../index/components/Card'
6
 import Card from '../index/components/Card'
14
-
7
+import {getResourceList } from '@/services/home'
15
 import './searchResult.less'
8
 import './searchResult.less'
16
 import withLayout from '@/layouts'
9
 import withLayout from '@/layouts'
17
 
10
 
21
   const { router, person,location } = props
14
   const { router, person,location } = props
22
   const { q} = props.router.params
15
   const { q} = props.router.params
23
 
16
 
24
-console.log(location,q)
25
   // 横向tab
17
   // 横向tab
26
   const [activeTab, setActiveTab] = useState(0)
18
   const [activeTab, setActiveTab] = useState(0)
27
   const [queryParams, setQueryParams] = useState({q:q, location: location, pageNum: 1, pageSize: 10, typeId: '' })
19
   const [queryParams, setQueryParams] = useState({q:q, location: location, pageNum: 1, pageSize: 10, typeId: '' })
45
     if (index == 0) {
37
     if (index == 0) {
46
       setQueryParams({q:q, location: location, pageNum: 1, pageSize: 10, typeId: '' })
38
       setQueryParams({q:q, location: location, pageNum: 1, pageSize: 10, typeId: '' })
47
     }
39
     }
48
-    // else if(index==1){}
49
-    // else{}
40
+    else if(index==1){
41
+      setQueryParams({q:q,targetType:'shop', location: location, pageNum: 1, pageSize: 10, typeId: '' })      
42
+    }
43
+    else{
44
+      setQueryParams({q:q,targetType:'tourist', location: location, pageNum: 1, pageSize: 10, typeId: '' })
45
+    }
50
   }
46
   }
51
 
47
 
52
 
48
 
69
       <view className='index-navbar'>
65
       <view className='index-navbar'>
70
         <CustomNav title='搜索' />
66
         <CustomNav title='搜索' />
71
       </view>
67
       </view>
72
-      <view style={{ height: '100%', overflow: 'auto' }}>
68
+      <view className='index-container'>
73
         <view className='search'>
69
         <view className='search'>
74
           <input className='searchInput' placeholder='请输入景区/城市搜索' disabled onClick={onSearch} />
70
           <input className='searchInput' placeholder='请输入景区/城市搜索' disabled onClick={onSearch} />
75
           <image className='searchicon' src={iconsearch} />
71
           <image className='searchicon' src={iconsearch} />
87
           </mp-tabs>
83
           </mp-tabs>
88
         </view>
84
         </view>
89
 
85
 
90
-        <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" >
86
+        <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" style={{height:'100vh'}} >
91
           <view className="waterfall">
87
           <view className="waterfall">
92
             {
88
             {
93
               alllist?.map((item) => <Card key={item.resourceNo} item={item} />)
89
               alllist?.map((item) => <Card key={item.resourceNo} item={item} />)

+ 1
- 0
src/pages/searchResult/searchResult.less 查看文件

53
         height:37px;
53
         height:37px;
54
         position: absolute;
54
         position: absolute;
55
         left: 0;
55
         left: 0;
56
+        top: 0;
56
       }
57
       }
57
       .loveharde{
58
       .loveharde{
58
         width: 22px;
59
         width: 22px;