Baozhangchao 3 years ago
parent
commit
aeef0f4287

BIN
src/assets/icons/housemantj/grassNO.png View File


BIN
src/assets/icons/housemantj/grassOFF.png View File


+ 1
- 2
src/components/CouponCard/Media/Header.jsx View File

@@ -19,8 +19,7 @@ export default (props) => {
19 19
   return (
20 20
     <View className='coupun-media_header'>
21 21
       {enableCashback && <Cashback money={cashback} style={{ marginTop: '-10px' }} />}
22
-      <View className='coupun-media_thumb' style={{marginTop:enableCashback?'':'20px'}}>
23
-        <BadgeTag type={badge} />
22
+      <View className='coupun-media_thumb' style={{ marginTop: enableCashback ? '' : '20px' }}>
24 23
         <View className='image' style={backStyle}></View>
25 24
       </View>
26 25
     </View>

+ 3
- 2
src/components/MasonryLayout/index.jsx View File

@@ -18,6 +18,7 @@ import './style.less'
18 18
 
19 19
 export default (props) => {
20 20
   const { className, listData, render } = props
21
+  console.log("🚀 ~ file: index.jsx ~ line 21 ~ listData", listData)
21 22
 
22 23
   // rfTimes 用来区分是否更换数据源
23 24
   const { list, rfTimes: refresh } = listData
@@ -36,7 +37,7 @@ export default (props) => {
36 37
   // const [rightList, appendRight, setRightList] = useColumn()
37 38
   const [leftList, setLeftList] = useState([])
38 39
   const [rightList, setRightList] = useState([])
39
-  
40
+
40 41
   // 渲染逻辑
41 42
   // const forceRender = useRenderFunc(renderListRef, leftHeight, rightHeight, appendLeft, appendRight)
42 43
 
@@ -51,7 +52,7 @@ export default (props) => {
51 52
     // //
52 53
     // forceRender.current()
53 54
   }
54
-  
55
+
55 56
   // console.debug('------leftHeight------->', leftHeight.current)
56 57
   // console.debug('------rightHeight------->', rightHeight.current)
57 58
   // console.debug('------renderListRef------->', renderListRef.current)

+ 78
- 0
src/components/foodCards/NoteCard/index.jsx View File

@@ -0,0 +1,78 @@
1
+import { useState } from 'react'
2
+
3
+import Taro from '@tarojs/taro'
4
+import { View, Text, Image, Button, ScrollView } from '@tarojs/components'
5
+import CouponCard from '@/components/CouponCard'
6
+import { compressImage } from '@/utils'
7
+import SaveIcon from '@/components/SaveIcon'
8
+import grassOFF from '@/assets/icons/housemantj/grassOFF.png'
9
+import grassNO from '@/assets/icons/housemantj/grassNO.png'
10
+import Popup from '@/components/Popup'
11
+import './style.less'
12
+
13
+
14
+const CouponMedia = CouponCard.Media
15
+const Action = CouponCard.Action
16
+
17
+//套餐卡片
18
+export default (props) => {
19
+  const { item, st, det, editable, setScroll, goshop, scene, subOrderId, id } = props
20
+  const { shopId } = props.item
21
+  const goFood = () => {
22
+    Taro.navigateTo({ url: `/pages/details/foodDetails/foodDetails?id=${shopId}` })
23
+  }
24
+  const [showCutover, setShowCutover] = useState(false)
25
+  const goDetail = () => {
26
+    //打开当前套餐详情弹窗
27
+    setShowCutover(true)
28
+    //使父组件禁止滚动
29
+    setScroll(false)
30
+  }
31
+  const onClose = () => {
32
+    //关闭当前套餐详情弹窗
33
+    setShowCutover(false)
34
+    //使父组件恢复滚动
35
+    setScroll(true)
36
+  }
37
+
38
+
39
+
40
+  const handlePayClick = () => {
41
+    Taro.navigateTo({ url: `/pages/PayOrder/index?packageId=${item.packageId}&scene=${scene || ''}&subOrderId=${subOrderId}&id=${id}` })
42
+  }
43
+  const PayAction = <Action.Icon icon={grassOFF} text='种草' onClick={handlePayClick} />
44
+  return (
45
+    <View style={{ margin: '15px 5px' }} >
46
+      <View className='packageDetail' style={{ display: goshop ? '' : 'none' }}>
47
+        <Popup show={showCutover} maskClosable={showCutover} onClose={onClose}>
48
+          <ScrollView
49
+            scrollY
50
+            style={{ maxHeight: '60vh' }}
51
+          >
52
+            <Image mode='widthFix' src={item.details ? item.details : item.poster} />
53
+          </ScrollView>
54
+        </Popup >
55
+      </View>
56
+      <CouponCard action={PayAction}>
57
+        <CouponMedia onClick={goshop ? goDetail : goFood}>
58
+          <CouponMedia.Header
59
+            cashback={item.cashback}
60
+            image={compressImage(item.poster)}
61
+            badge='note'
62
+          />
63
+          <CouponMedia.Body star={st}>
64
+            <View className='foodCard'>
65
+              <View className='cpn-card-text'>
66
+                {(item.title).toString().length > 25 ? (item.title).substring(0, 25) + '...' : (item.title)}
67
+              </View>
68
+              <View className='cpn-md-act'>
69
+                {/* <Location {...det} /> */}
70
+                <SaveIcon saved={item.isSaved > 0} targetType='shop_package' editable={editable} targetId={item.packageId} />
71
+              </View>
72
+            </View>
73
+          </CouponMedia.Body>
74
+        </CouponMedia>
75
+      </CouponCard>
76
+    </View>
77
+  )
78
+}

+ 47
- 0
src/components/foodCards/NoteCard/style.less View File

@@ -0,0 +1,47 @@
1
+.foodCard{
2
+  .cpn-card-text {
3
+    font-size: 24px;
4
+    font-weight: 400;
5
+    color: #333333;
6
+    line-height: 40px;
7
+    vertical-align: baseline;
8
+
9
+    & > text {
10
+      display: inline-block;
11
+
12
+      & + text {
13
+        margin-left: 8px;
14
+      }
15
+    }
16
+    &_mn {
17
+      font-size: 24px;
18
+      font-weight: bold;
19
+      color: #333333;
20
+    }
21
+
22
+    &_rm {
23
+      font-size: 18px;
24
+      font-weight: 400;
25
+      text-decoration: line-through;
26
+      color: #666666;
27
+    }
28
+  }
29
+
30
+  .cpn-md-act {
31
+    display: flex;
32
+    margin-top: 10px;
33
+
34
+    & > view {
35
+      flex: 1;
36
+    }
37
+  }
38
+}
39
+.packageDetail{
40
+  Image{
41
+    width: 100%;
42
+  }
43
+  .weui-dialog__bd{
44
+    padding: 0;
45
+    margin: 0;
46
+  }
47
+}

+ 42
- 58
src/pages/details/NoteDetails/index.jsx View File

@@ -13,6 +13,8 @@ import weibaozan from '@/assets/icons/housemantj/unLike.png'
13 13
 import zhuandao from "@/assets/icons/housemantj/backTop.png";
14 14
 import withLayout from '@/layouts'
15 15
 import SpinBox from "@/components/Spin/SpinBox";
16
+import { getNoteList, getNoteID } from '@/services/note'
17
+
16 18
 import TabIcon from '@/components/HorTabbar/TabIcon'
17 19
 import { useState, useEffect } from 'react'
18 20
 import { getTouristDetail, getExtendContent, getRecommendList } from '@/services/home'
@@ -20,7 +22,7 @@ import logo from "@/assets/icons/UserCenter/laba.png"
20 22
 import { Swiper, SwiperItem, Button, View, Ad } from '@tarojs/components';
21 23
 import useSave from "@/utils/hooks/useSave"
22 24
 import useLike from "@/utils/hooks/useLike"
23
-import Cards from '@/components/foodCards/foodCards.jsx'
25
+import NoteCards from '@/components/foodCards/NoteCard/index'
24 26
 import Taro, { useShareAppMessage } from '@tarojs/taro'
25 27
 import Extend from '../components/Extend/extend'
26 28
 import './index.less'
@@ -28,7 +30,7 @@ import './index.less'
28 30
 
29 31
 
30 32
 export default withLayout((props) => {
31
-  const { router, person, location } = props
33
+  const { router, person } = props
32 34
   const { id } = props.router.params
33 35
   const [detail, setDetail] = useState({})
34 36
   const [isSaved, toggleSave] = useSave(detail.isSaved, 'tourist', id)
@@ -48,17 +50,7 @@ export default withLayout((props) => {
48 50
   // 推荐套餐列表
49 51
   const [recommend, setRecommend] = useState([])
50 52
 
51
-  const openMap = () => {
52
-    const [lng, lat] = detail.locaton.split(',')
53 53
 
54
-    Taro.openLocation({
55
-      longitude: lng - 0,
56
-      latitude: lat - 0,
57
-      name: detail.touristName,
58
-      address: detail.address,
59
-      scale: 12,
60
-    })
61
-  }
62 54
   //引导显隐
63 55
   const [guidance, setGuidance] = useState('shareOff')
64 56
   useEffect(() => {
@@ -71,35 +63,33 @@ export default withLayout((props) => {
71 63
   useEffect(() => {
72 64
     if (id) {
73 65
       setLoading(true)
74
-      getTouristDetail(id, { location }).then((res) => {
66
+      getNoteID(id).then((res) => {
75 67
         setDetail(res)
68
+        console.log("🚀 ~ file: index.jsx ~ line 68 ~ getNoteID ~ res", res)
76 69
         setimglist(res.imageList || [])
77
-        getRecommendList({ location: res.locaton }).then((res2) => {
78
-          setRecommend(res2 || [])
79
-        })
80
-      })
81
-      getExtendContent('tourist', id, { pageSize: 500 }).then((res) => {
82
-        setExtend(res.records || [])
83
-        setLoading(false)
70
+        setRecommend(res.wxResourceList || [])
84 71
 
85
-      })
86
-    } else {
87
-      getRecommendList({ location }).then((res2) => {
88
-        setRecommend(res2 || [])
89 72
         setLoading(false)
73
+
90 74
       }).catch(e => {
75
+        console.error("getNoteID错误", e)
91 76
         setLoading(false)
77
+
78
+      })
79
+      getExtendContent('note', id, { pageSize: 500 }).then((res) => {
80
+        setExtend(res.records || [])
81
+        setLoading(false)
82
+
92 83
       })
93 84
     }
94
-  }, [id, location])
85
+  }, [id])
95 86
   // 分享
96 87
   useShareAppMessage(() => {
97 88
     return {
98 89
       title: detail.touristName,
99
-      path: `/pages/details/mjDetails/sceneryDetails?id=${id}&enterType=share`,
90
+      path: `/pages/details/NoteDetails/index?id=${id}&enterType=share`,
100 91
       imageUrl: detail.poster,
101 92
     }
102
-
103 93
   })
104 94
   return (
105 95
     <view className='page-index'>
@@ -118,19 +108,26 @@ export default withLayout((props) => {
118 108
         <scroll-view scrollY style={{ height: '100%' }}>
119 109
           <view className='storeDetails'>
120 110
             <View className='huadong'>
121
-              <Swiper
122
-                className='swiper'
123
-                circular
124
-                onChange={handchange}
125
-              >
126
-                {
127
-                  imglist.map((item, key) => (
128
-                    item.noteType == 'image' ?
129
-                      <SwiperItem key={key}>
130
-                        <image src={compressImage(item.url)} mode='aspectFit' className='storeImage' />
131
-                      </SwiperItem> : <MoreGuide key={key} item={item} />
132
-                  ))}
133
-              </Swiper>
111
+              {
112
+                detail.noteType === 'image' ?
113
+                  <Swiper className='swiper' circular onChange={handchange}>
114
+                    {
115
+                      imglist.map((item, key) => (
116
+                        <SwiperItem key={key}>
117
+                          <image src={compressImage(item.url)} mode='aspectFit' className='storeImage' />
118
+                        </SwiperItem>
119
+                      ))}
120
+                  </Swiper>
121
+                  :
122
+                  <Swiper className='swiper' circular onChange={handchange}>
123
+                    {
124
+                      imglist.map((item, key) => (
125
+                        <MoreGuide key={key} item={item} />
126
+
127
+                      ))}
128
+                  </Swiper>
129
+              }
130
+
134 131
               <view className='tpPage'>
135 132
                 <text>
136 133
                   {index + 1}/{imglist.length}
@@ -138,26 +135,13 @@ export default withLayout((props) => {
138 135
               </view>
139 136
             </View>
140 137
 
141
-            <view className='storeJs'>
142
-              <view className='introduce'>
143
-                <text className='storeName'>{detail.touristName}</text>
144
-              </view>
145
-              <view className='bz'>
146
-                <image src={baozan} style={{ width: '15px', height: '15px', marginRight: '10px', marginBottom: '-2px' }} />
147
-                <text className='bzRight'>爆赞{detail.likeNum}</text>
148
-              </view>
149
-              <view className='wz'>{detail.address}</view>
150
-              <view className='dpPosition' onClick={openMap}>
151
-                <image src={dw} className='dwTip' />
152
-                <view className='distance'>{(detail.distance / 1000).toFixed(2)}公里<image src={zhuandao} className='zhuandao' /></view>
153
-              </view>
154
-            </view>
138
+
155 139
           </view>
156 140
           <view className='jdjs'>
157
-            <view>{detail.description}</view>
141
+            <view>{detail.summary}</view>
158 142
             <view className='line'></view>
159 143
             <view className='sc' onClick={toggleSave}>
160
-              <image className='scTip' src={isSaved > 0 ? ax : good} /><text>{isSaved > 0 ? '已收藏' : '加入收藏'}</text>
144
+              {/* <image className='scTip' src={isSaved > 0 ? ax : good} /><text>{isSaved > 0 ? '已收藏' : '加入收藏'}</text> */}
161 145
             </view>
162 146
           </view>
163 147
           <view class='adContainer'>
@@ -168,14 +152,14 @@ export default withLayout((props) => {
168 152
               <image src={NoteasICO} />笔记详情
169 153
             </view>
170 154
             <View style={{ background: '#FFF' }}>
171
-              {(extend || []).map((item) => <Extend item={item} />)}
155
+              {(extend || []).map((item) => <Extend key={item} item={item} />)}
172 156
             </View>
173 157
           </view>
174 158
           <view style={{ display: recommend == '' ? 'none' : '' }}>
175 159
             <view className='title'>
176 160
               <image src={TextMentioned} />文中提及
177 161
             </view>
178
-            {(recommend || []).map((item) => <Cards item={item} det={item} st={parseFloat(item.score.toFixed(1))} />)}
162
+            {(recommend || []).map((item) => <NoteCards key={item} item={item} det={item} />)}
179 163
           </view>
180 164
           <view className='botton'>这是我的底线</view>
181 165
         </scroll-view>

+ 0
- 1
src/pages/details/NoteDetails/index.less View File

@@ -1,7 +1,6 @@
1 1
 .storeDetails {
2 2
   background-color: #fff;
3 3
   border-radius: 12px;
4
-  margin-bottom: 20px;
5 4
   .huadong {
6 5
     position: relative;
7 6
     .swiper {

+ 43
- 0
src/pages/index/components/NoteCard/index.jsx View File

@@ -0,0 +1,43 @@
1
+
2
+import { useMemo } from 'react'
3
+import Taro from '@tarojs/taro'
4
+import useSave from "@/utils/hooks/useSave"
5
+import { compressImage, random } from '@/utils'
6
+import msTip from '@/assets/icons/housemantj/foodtip.png'
7
+import mjTip from '@/assets/icons/housemantj/mjtip.png'
8
+import location from '@/assets/icons/housemantj/location.png'
9
+import onlove from '@/assets/icons/housemantj/onlove.png'
10
+import love from '@/assets/icons/housemantj/bheart.png'
11
+import './style.less'
12
+
13
+export default (props) => {
14
+
15
+  const { className, item, style, } = props
16
+
17
+  const uqClass = useMemo(() => random('f'), [])
18
+
19
+  // const cls = useMemo(() => [className, 'contentCard', uqClass].filter(Boolean).join(' '), [className, uqClass])
20
+
21
+  const [isSaved, toggleSave] = useSave(item.isSaved, item.targetType, item.targetId)
22
+  const Detail = () => {
23
+
24
+    Taro.navigateTo({ url: `/pages/details/NoteDetails/index?id=${item.noteId}` });
25
+
26
+
27
+  }
28
+  return (
29
+    <view className={uqClass} style={{ overflow: 'hidden' }}>
30
+      <view className='contentCard' style={style}>
31
+        <view className='cardTop'>
32
+          <image mode='widthFix' onClick={Detail} src={compressImage(item.poster)} className='cCardimg' />
33
+          {/* <image className='lefttips' src={item.targetType === 'tourist' ? mjTip : msTip} /> */}
34
+          <image onClick={toggleSave} src={isSaved > 0 ? onlove : love} className='loveharde'></image>
35
+        </view>
36
+        <view className='bContent' onClick={Detail}>
37
+          <view className='cCword'>{(item.summary).toString().length > 35 ? (item.summary).substring(0, 35) + '...' : (item.summary)}</view>
38
+        </view>
39
+      </view>
40
+    </view>
41
+  )
42
+
43
+}

+ 75
- 0
src/pages/index/components/NoteCard/style.less View File

@@ -0,0 +1,75 @@
1
+.contentCard {
2
+  background: #fff;
3
+  box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
4
+  border-radius: 24px;
5
+  overflow: hidden;
6
+  margin-bottom: 30px;
7
+  break-inside: avoid;
8
+  position: relative;
9
+  width: calc(100% - 30px);
10
+  box-sizing: border-box;
11
+  margin-left: 15px;
12
+  .cardTop {
13
+    border-radius: 24px 24px 0px 0px;
14
+    .cCardimg {
15
+      width: 100%;
16
+      border-radius: 24px 24px 0px 0px;
17
+    }
18
+    .lefttips {
19
+      width: 99px;
20
+      height: 37px;
21
+      position: absolute;
22
+      left: 0;
23
+      top: 0;
24
+    }
25
+    .loveharde {
26
+      width: 28px;
27
+      height: 26px;
28
+      position: absolute;
29
+      right: 20px;
30
+      top: 10px;
31
+    }
32
+  }
33
+  .bContent {
34
+    padding: 20px;
35
+    .cCword {
36
+      font-size: 24px;
37
+      font-weight: bold;
38
+      color: #404040;
39
+      text-align: justify;
40
+      padding-bottom: 40px;
41
+    }
42
+    .cCBottom {
43
+      display: flex;
44
+      .cCleft {
45
+        flex: 3;
46
+        position: relative;
47
+        padding: 40px 0 30px 0;
48
+        .cCicon {
49
+          width: 17px;
50
+          height: 21px;
51
+          position: absolute;
52
+          left: 0;
53
+          top: 48px;
54
+        }
55
+        .distance {
56
+          padding-left: 24px;
57
+          font-size: 24px;
58
+          color: #c0c8d3;
59
+        }
60
+      }
61
+      .cCright {
62
+        flex: 2;
63
+        position: relative;
64
+        padding: 40px 0 30px 0;
65
+        .price {
66
+          font-size: 24px;
67
+          color: #ff3434;
68
+          .money {
69
+            font-size: 20px;
70
+          }
71
+        }
72
+      }
73
+    }
74
+  }
75
+}

+ 45
- 48
src/pages/index/tabs/Recommend.jsx View File

@@ -7,9 +7,12 @@ import List from '@/components/List';
7 7
 import MasonryLayout from '@/components/MasonryLayout';
8 8
 import { getIndexType, getResourceList } from '@/services/home'
9 9
 import { random } from '@/utils'
10
+import { getNoteList } from '@/services/note'
11
+
10 12
 import Card from '../components/Card'
13
+import NoteCard from '../components/NoteCard'
11 14
 import './less/Recommend.less'
12
-
15
+import RecommendNote from './RecommendNote'
13 16
 
14 17
 const listStyle = { height: '100%' }
15 18
 
@@ -17,12 +20,9 @@ export default (props) => {
17 20
   const { router, person, location } = props
18 21
   const listClass = useMemo(() => random('f'), [])
19 22
   const [activeTab, setActiveTab] = useState(0)
20
-  const [typeList, setTypeList] = useState([])
21 23
   const listRef = useRef()
22 24
 
23
-  const [queryParams, setQueryParams] = useState({ location, pageNum: 1, pageSize: 10, typeId: '' })//地点
24
-
25
-  // const [queryParams, setQueryParams] = useState({ location, pageNum: 1, pageSize: 10, typeId: '' })//笔记
25
+  const [queryParams, setQueryParams] = useState({ location, pageNum: 1, pageSize: 10, typeId: '' })
26 26
   const rfTimes = useRef(0)
27 27
 
28 28
   // 获取资源表信息
@@ -30,32 +30,20 @@ export default (props) => {
30 30
 
31 31
 
32 32
   //分类标签
33
-  const tabs = [{ title: '地点' }, { title: '笔记' }].concat(typeList.map(x => ({ ...x, title: x.typeName })))
34
-
35
-  //笔记
36
-  const penDetails = (index, tab) => {
37
-    // setActiveTab(index)
38
-    // setQueryParams({
39
-    //   ...queryParams,
40
-    //   typeId: tab
41
-    // })
42
-  }
33
+  const tabs = [{ title: '地点' }, { title: '笔记' }]
34
+
35
+  const details = (index, tab) => {
36
+
43 37
 
44 38
 
45
-  const placeDetails = (index, tab) => {
46
-    setActiveTab(index)
47
-    setQueryParams({
48
-      ...queryParams,
49
-      typeId: tab
50
-    })
51 39
   }
52 40
   //切换上面的标签
53 41
   const handleTabChange = (e) => {
54 42
     const { index } = e.detail
55
-    // if (index = 0) {
43
+    setActiveTab(index)
44
+    setQueryParams({ ...queryParams })
56 45
 
57
-    // }
58
-    placeDetails(index, tabs[index].typeId || '')
46
+    details(index, tabs[index].typeId || '')
59 47
   }
60 48
 
61 49
   const handleDataChange = (value, e) => {
@@ -69,13 +57,7 @@ export default (props) => {
69 57
     setListData({ list: value, rfTimes: rfTimes.current })
70 58
   }
71 59
 
72
-  useEffect(() => {
73
-    //查询分类标签表
74
-    getIndexType({ pageSize: 20 }).then((res) => {
75
-      setTypeList(res.records || [])
76
-      placeDetails(1, res.records[0]?.typeId)
77
-    })
78
-  }, [])
60
+
79 61
 
80 62
   const onSearch = () => {
81 63
     // 用绝对路径
@@ -114,23 +96,38 @@ export default (props) => {
114 96
         </scroll-view>
115 97
       </view>
116 98
       <view className={listClass} style={{ flex: '1', overflow: 'hidden' }}>
117
-        <List
118
-          ref={listRef}
119
-          style={listStyle}
120
-          request={getResourceList}
121
-          params={queryParams}
122
-          refresherEnabled={false}
123
-          onDataChange={handleDataChange}
124
-        >
125
-          <view style={{ padding: '30rpx 15rpx' }}>
126
-            <MasonryLayout
127
-              itemKey='resourceNo'
128
-              listData={listData}
129
-              render={(item) => <Card key={item.resourceNo} item={item} />}
130
-            />
131
-          </view>
132
-        </List>
99
+        {
100
+          activeTab == 0 ?
101
+            <List
102
+              ref={listRef}
103
+              style={listStyle}
104
+              request={getResourceList}
105
+              params={queryParams}
106
+              refresherEnabled={false}
107
+              onDataChange={handleDataChange}
108
+            >
109
+              <view style={{ padding: '30rpx 15rpx' }}>
110
+
111
+                <MasonryLayout
112
+                  itemKey='resourceNo'
113
+                  listData={listData}
114
+                  render={(item) => <Card key={item.resourceNo} item={item} />}
115
+                />
116
+              </view>
117
+            </List>
118
+            :
119
+            <RecommendNote />
120
+
121
+
122
+
123
+
124
+
125
+
126
+        }
127
+
133 128
       </view>
129
+
130
+
134 131
     </view>
135 132
   )
136
-}
133
+}

+ 100
- 0
src/pages/index/tabs/RecommendNote/index.jsx View File

@@ -0,0 +1,100 @@
1
+import Taro, { useDidShow } from '@tarojs/taro'
2
+import { React, useState, useEffect, useRef, useMemo } from 'react'
3
+import iconsearch from '@/assets/icons/housemantj/search.png'
4
+import locationimg from '@/assets/icons/housemantj/location.png'
5
+import Tip from '@/components/tip'
6
+import List from '@/components/List';
7
+import MasonryLayout from '@/components/MasonryLayout';
8
+import { getIndexType, getResourceList } from '@/services/home'
9
+import { random } from '@/utils'
10
+import { getNoteList } from '@/services/note'
11
+
12
+import NoteCard from '../../components/NoteCard'
13
+
14
+const listStyle = { height: '100%' }
15
+
16
+export default (props) => {
17
+  const { router, person, location } = props
18
+  const listClass = useMemo(() => random('f'), [])
19
+  const [activeTab, setActiveTab] = useState(0)
20
+  const listRef = useRef()
21
+
22
+  const [queryParams, setQueryParams] = useState({ location, pageNum: 1, pageSize: 10, })
23
+  const rfTimes = useRef(0)
24
+
25
+  // 获取资源表信息
26
+  const [listData, setListData] = useState({ list: [], rfTimes: 0 })
27
+
28
+
29
+  //分类标签
30
+  const tabs = [{ title: '地点' }, { title: '笔记' }]
31
+
32
+  const details = (index, tab) => {
33
+
34
+    // if (index === 1) {
35
+
36
+    //   getNoteList({ location: location }).then(res => {
37
+
38
+    //     setListData({ list: res.records })
39
+
40
+    //   })
41
+    // }
42
+
43
+  }
44
+  //切换上面的标签
45
+  const handleTabChange = (e) => {
46
+    const { index } = e.detail
47
+    setActiveTab(index)
48
+    setQueryParams({ ...queryParams })
49
+
50
+    details(index, tabs[index].typeId || '')
51
+  }
52
+
53
+  const handleDataChange = (value, e) => {
54
+    if (e.paramsChanged) {
55
+      rfTimes.current += 1
56
+      //如果context有的话代表他滚动了   那么切换tab页就置顶
57
+      if (listRef.current?.context) {
58
+        listRef.current.context.scrollTo({ top: 0 })
59
+      }
60
+    }
61
+    setListData({ list: value, rfTimes: rfTimes.current })
62
+  }
63
+
64
+
65
+
66
+  const onSearch = () => {
67
+    // 用绝对路径
68
+    Taro.navigateTo({ url: '/pages/search/search' });
69
+  }
70
+
71
+
72
+  return (
73
+    <view style={{ height: '100%', overflow: 'hidden', display: 'flex', flexDirection: 'column' }}>
74
+
75
+      <List
76
+        ref={listRef}
77
+        style={listStyle}
78
+        request={getNoteList}
79
+        params={queryParams}
80
+        refresherEnabled={false}
81
+        onDataChange={handleDataChange}
82
+      >
83
+        <view style={{ padding: '30rpx 15rpx' }}>
84
+
85
+          <MasonryLayout
86
+            itemKey='noteId'
87
+            listData={listData}
88
+            render={(item) => <NoteCard key={item.noteId} item={item} />}
89
+          />
90
+        </view>
91
+      </List>
92
+
93
+
94
+
95
+
96
+
97
+
98
+    </view>
99
+  )
100
+}

+ 6
- 44
src/pages/searchResult/searchResult.jsx View File

@@ -1,16 +1,16 @@
1 1
 import { React, useState, useRef } from 'react'
2 2
 // .就是当前路径
3
-import iconsearch from '../../assets/icons/housemantj/search.png'
4 3
 import CustomNav from '@/components/CustomNav'
5 4
 import Taro from '@tarojs/taro'
6 5
 import { View } from '@tarojs/components';
7
-import Card from '../index/components/Card'
8 6
 import { getResourceList } from '@/services/home'
9 7
 import MasonryLayout from '@/components/MasonryLayout';
10 8
 import NoData from '@/components/NoData'
11 9
 import List from '@/components/List';
12 10
 import withLayout from '@/layouts'
13 11
 import './searchResult.less'
12
+import Card from '../index/components/Card'
13
+import iconsearch from '../../assets/icons/housemantj/search.png'
14 14
 
15 15
 
16 16
 const listStyle = { height: '100%' }
@@ -22,40 +22,13 @@ export default withLayout((props) => {
22 22
   const [listData, setListData] = useState({ list: [], rfTimes: 0 })
23 23
 
24 24
   // 横向tab
25
-  const [activeTab, setActiveTab] = useState(0)
26 25
   const [queryParams, setQueryParams] = useState({ q: q, location, pageNum: 1, pageSize: 10, typeId: '' })
27 26
   const rfTimes = useRef(0)
28 27
 
29
-  const tabs = [
30
-    {
31
-      title: '全部',
32
-    },
33
-    {
34
-      title: '美食',
35
-    },
36
-    {
37
-      title: '景点',
38
-    },
39
-  ]
28
+
40 29
   const listRef = useRef()
41 30
 
42
-  const handleTabChange = (e) => {
43
-    const { index } = e.detail
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
-      setQueryParams({ q: q, targetType: 'shop', location: location, pageNum: 1, pageSize: 10, typeId: '' })
50
-    }
51
-    else {
52
-      setQueryParams({ q: q, targetType: 'tourist', location: location, pageNum: 1, pageSize: 10, typeId: '' })
53
-    }
54
-    //如果context有的话代表他滚动了   那么切换tab页就置顶
55
-    if (listRef.current?.context) {
56
-      listRef.current.context.scrollTo({ top: 0 })
57
-    }
58
-  }
31
+
59 32
 
60 33
   const handleDataChange = (value, e) => {
61 34
     if (e.paramsChanged) {
@@ -84,19 +57,8 @@ export default withLayout((props) => {
84 57
           <image className='searchicon' src={iconsearch} />
85 58
           <view className='lineSearch'></view>
86 59
         </view>
87
-        <view className='index-tabs'>
88
-          <mp-tabs
89
-            tabClass='tabs-Unselected'
90
-            swiperClass='tabs-swiper'
91
-            activeClass='tabs-Selected'
92
-            tabs={tabs}
93
-            current={activeTab}
94
-            onChange={handleTabChange}
95
-            activeTab={activeTab}
96
-          >
97
-          </mp-tabs>
98
-        </view>
99
-        <View style={{ flex:1, overflow: 'hidden'}}>
60
+
61
+        <View style={{ flex: 1, overflow: 'hidden' }}>
100 62
           <List
101 63
             ref={listRef}
102 64
             style={listStyle}

+ 26
- 0
src/services/note.js View File

@@ -0,0 +1,26 @@
1
+
2
+import request from '@/utils/request'
3
+
4
+
5
+
6
+
7
+/**
8
+ * 笔记查询
9
+ * @param {*} 
10
+ * @returns 
11
+ */
12
+
13
+export const getNoteList = (params) => request(`/note`, { params })
14
+
15
+
16
+/**
17
+ * 笔记查询根据ID
18
+ * @param {*} id 
19
+ * @returns 
20
+ */
21
+
22
+export const getNoteID = (id, params) => request(`/note/${id}`, { params })
23
+
24
+
25
+
26
+