张延森 3 年 前
コミット
c1678f8d5d

バイナリ
src/assets/icons/UserCenter/tips.png ファイルの表示


+ 4
- 4
src/components/CouponCard/Cashback/index.jsx ファイルの表示

@@ -4,14 +4,14 @@ import { View, Text } from '@tarojs/components'
4 4
 import './style.less'
5 5
 
6 6
 export default (props) => {
7
-  const { money, prefix = '返', style } = props
7
+  const { money, prefix = '返', style } = props
8 8
 
9
-  const yuan = Number(money / 100).toFixed(2)
9
+  const yuan = Number(money / 100).toFixed(0)
10 10
 
11 11
   return (
12 12
     <View className='cpn_cashback' style={style}>
13
-      <Text>{prefix}</Text>
14
-      <Text>{`${yuan}`}</Text>
13
+      <Text style={{ fontSize: '.6em' }}>{`${prefix}¥`}</Text>
14
+      <Text>{`${yuan}`}</Text>
15 15
     </View>
16 16
   )
17 17
 }

+ 1
- 1
src/components/CouponCard/Cashback/style.less ファイルの表示

@@ -4,7 +4,7 @@
4 4
   background: url('~@/assets/icons/ProCard/ProCard_hot.png') no-repeat;
5 5
   background-size: 100% 100%;
6 6
   padding: 16px 25px 10px 10px;
7
-  font-size: 20px;
7
+  font-size: 44px;
8 8
   color: #fff;
9 9
   line-height: 1em;
10 10
 }

+ 1
- 1
src/components/CouponCard/Media/Header.jsx ファイルの表示

@@ -11,7 +11,7 @@ export default (props) => {
11 11
 
12 12
   return (
13 13
     <View className='coupun-media_header'>
14
-      {enableCashback && <Cashback money={cashback} style={{ marginTop: '10px' }} />}
14
+      {enableCashback && <Cashback money={cashback} style={{ marginTop: '-10px' }} />}
15 15
       <View className='coupun-media_thumb'>
16 16
         <BadgeTag type={badge} />
17 17
         <Image src={image} />

+ 20
- 27
src/components/List/index.jsx ファイルの表示

@@ -16,47 +16,44 @@ export default React.forwardRef((props, ref) => {
16 16
     className,
17 17
     ...leftProps
18 18
   } = props
19
-  const [loading, setLoading] = useState(false)
20 19
 
20
+  const [loading, setLoading] = useState(false)
21 21
   const contextRef = useRef()
22
-  const loadingRef = useRef(false)
23
-  const [payload, setPayload] = useState(params)
22
+  const [forceUpdate, setForceUpdate] = useState(0)
24 23
   const [list, setList] = useState([])
25
-  const pageRef = useRef({ current: 1, pages: 0 })
26
-  const hasMore = pageRef.current.current < pageRef.current.pages
24
+  const pageRef = useRef({ current: 1 })
25
+  const [hasMore, setHasMore] = useState(false)
27 26
 
28 27
   // 滚动
29 28
   const handleScrollToLower = (e) => {
30
-    // const loading = loadingRef.current
31
-
32 29
     if (!loading && hasMore) {
33
-      setPayload({
34
-        ...payload,
35
-        pageNum: pageRef.current.current + 1
36
-      })
30
+      pageRef.current.current += 1
31
+      setForceUpdate(forceUpdate + 1)
37 32
     }
38 33
   }
39 34
 
40
-  const fetchList = (params) => {
35
+  const fetchList = () => {
41 36
     if (!request) return;
42 37
 
43 38
     setLoading(true)
44
-    // loadingRef.current = true
45
-    request(params).then((res) => {
39
+    request({
40
+      ...params,
41
+      pageSize,
42
+      pageNum: pageRef.current.current
43
+    }).then((res) => {
46 44
       const { records, ...pageInfo } = res || {}
47 45
       const lst = pageInfo.current === 1 ? records || [] : list.concat(records || [])
48 46
       setList(lst)
47
+      setHasMore(pageInfo.current < pageInfo.pages)
48
+
49 49
       if (onDataChange) {
50 50
         onDataChange(lst)
51 51
       }
52 52
 
53 53
       pageRef.current = pageInfo
54
-      // loadingRef.current = false
55
-
56 54
       setLoading(false)
57 55
 
58 56
     }).catch((err) => {
59
-      // loadingRef.current = false
60 57
       console.error(err)
61 58
       setLoading(false)
62 59
 
@@ -69,20 +66,16 @@ export default React.forwardRef((props, ref) => {
69 66
   const fetchRef = useRef()
70 67
   fetchRef.current = fetchList
71 68
 
72
-  // 联动状态, 设置查询参数
69
+  
73 70
   useEffect(() => {
74
-    setPayload({
75
-      ...params || {},
76
-      pageNum: 1,
77
-      pageSize,
78
-    })
79
-  }, [pageSize, params])
71
+    pageRef.current.current = 1
72
+    setHasMore(false)
73
+  }, [params])
80 74
 
81 75
   // 请求数据
82 76
   useEffect(() => {
83
-    fetchRef.current(payload)
84
-    console.log('------------list----------------', payload, request)
85
-  }, [payload, request])
77
+    fetchRef.current()
78
+  }, [params, forceUpdate])
86 79
 
87 80
   useEffect(() => {
88 81
     Taro.nextTick(() => {

+ 23
- 17
src/components/MasonryLayout/Item.jsx ファイルの表示

@@ -1,5 +1,6 @@
1 1
 
2 2
 import React, { useMemo, useEffect } from 'react'
3
+import Taro from '@tarojs/taro';
3 4
 import { View } from '@tarojs/components'
4 5
 import { classNames, getRect } from './utils';
5 6
 import './style.less'
@@ -10,25 +11,30 @@ export default (props) => {
10 11
   const vid = item.__vid;
11 12
   
12 13
   useEffect(() => {
13
-    const calcHeight = () => {
14
-      getRect(`.${vid}`).then((res) => {
15
-        if (!res) {
16
-          // 找不到 node , 则一直重复查询
17
-          const t = setTimeout(() => {
18
-            clearTimeout(t)
19
-            calcHeight()
20
-          }, 300)
21
-        } else {
22
-          if (Array.isArray(res)) {
23
-            onRenderFinish(res[0])
14
+    Taro.nextTick(() => {
15
+      const calcHeight = () => {
16
+        getRect(`.${vid}`).then((res) => {
17
+          if (!res) {
18
+            // 找不到 node , 则一直重复查询
19
+            const t = setTimeout(() => {
20
+              clearTimeout(t)
21
+              calcHeight()
22
+            }, 100)
24 23
           } else {
25
-            onRenderFinish(res)
24
+            const t = setTimeout(() => {
25
+              if (Array.isArray(res)) {
26
+                onRenderFinish(res[0])
27
+              } else {
28
+                onRenderFinish(res)
29
+              }
30
+              clearTimeout(t)
31
+            }, 100)
26 32
           }
27
-        }
28
-      })
29
-    }
30
-
31
-    calcHeight()
33
+        })
34
+      }
35
+  
36
+      calcHeight()
37
+    })
32 38
   })
33 39
 
34 40
 

+ 48
- 0
src/components/MasonryLayout/Waterfall.jsx ファイルの表示

@@ -0,0 +1,48 @@
1
+import React, { useEffect, useMemo, useState } from 'react'
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components'
4
+import { classNames, getRect } from './utils';
5
+import './style.less'
6
+
7
+export default (props) => {
8
+  const { className, itemClassName, style, gutter = 0, list, render, ...leftProps } = props
9
+  const uqClass = useMemo(() => `f-${Math.random().toString(36).substring(2)}`, [])
10
+
11
+  const [styles, setStyles] = useState([])
12
+
13
+  const handleImage = index => (e) => {
14
+    const { height } = e
15
+    const span = Math.ceil(height / 10)
16
+
17
+    const itemStyle = { gridRow: `auto/span ${span}` }
18
+    styles[index] = itemStyle
19
+    
20
+    if (styles.filter(Boolean).length === list.length) {    
21
+      setStyles(styles.slice())
22
+    }
23
+  }
24
+
25
+  // useEffect(() => {
26
+  //   const t = setTimeout(() => {
27
+  //     Taro.createSelectorQuery().selectAll(`.${uqClass} .waterfall-item`).boundingClientRect(rects => {
28
+  //       console.log('---------waterfall-item---------->', rects)
29
+  //     }).exec()
30
+  //     clearTimeout(t)
31
+  //   }, 500)
32
+  // }, [list, uqClass])
33
+
34
+  return (
35
+    <View className={classNames(className, 'waterfall-wrapper', uqClass)}>
36
+      {
37
+        list.map((item, index) => {
38
+          const st = styles[index]
39
+          return (
40
+            <View key={index} className={classNames(itemClassName, 'waterfall-item')} style={st}>
41
+              {render(item, handleImage(index))}
42
+            </View>
43
+          )
44
+        })
45
+      }
46
+    </View>
47
+  )
48
+}

+ 14
- 0
src/components/MasonryLayout/style.less ファイルの表示

@@ -17,3 +17,17 @@
17 17
     overflow-x: hidden;
18 18
   }
19 19
 }
20
+
21
+
22
+.waterfall-wrapper {
23
+  display: grid;
24
+  grid-template-columns: repeat(auto-fill, minmax(50%, 1fr));
25
+  grid-gap: 0;
26
+  grid-auto-flow: row dense;
27
+  grid-auto-rows: 20px;
28
+
29
+  .waterfall-item {
30
+    width: 100%;
31
+    grid-row: auto/span 10;
32
+  }
33
+}

+ 1
- 1
src/hotel/components/HouseManage/houseManage.jsx ファイルの表示

@@ -99,7 +99,7 @@ export default React.forwardRef((props, ref) => {
99 99
       setShowCard(false)
100 100
       console.log(`/pages/index/index?tab=1&roomId=${room.roomId}&roomOrderId=${roomOrderId}&fromType=hotel&recommender=${hotel.hotelId}`)
101 101
       return {
102
-        title: room.roomName,
102
+        title: `欢迎来到${room.roomName}`,
103 103
         path: `/pages/index/index?tab=1&roomId=${room.roomId}&roomOrderId=${roomOrderId}&fromType=hotel&recommender=${hotel.hotelId}`,
104 104
         imageUrl: shareImage,
105 105
       }

+ 3
- 7
src/pages/MineUserAll/RefundMoney/CheckRefund/index.jsx ファイルの表示

@@ -122,10 +122,8 @@ export default withLayout((props) => {
122 122
         <CustomNav title='售后退款' />
123 123
       </view>
124 124
       <View className='index-container'>
125
-        <View className='box-content'>
126
-          <scroll-view scroll-y style='height: 100%;' >
127
-            <SpinBox loading={loading}>
128
-
125
+        <SpinBox loading={loading} className='box-content'>
126
+          <scroll-view scroll-y style={{ height: '100%' }} >
129 127
               <view className='Refund-Content-box'>
130 128
                 <view className='title-image'>
131 129
                   <image
@@ -220,10 +218,8 @@ export default withLayout((props) => {
220 218
                   提交申请
221 219
                 </Button>
222 220
               </view>
223
-            </SpinBox>
224
-
225 221
           </scroll-view>
226
-        </View>
222
+        </SpinBox>
227 223
       </View>
228 224
 
229 225
     </view >

+ 31
- 16
src/pages/index/components/Card/index.jsx ファイルの表示

@@ -1,5 +1,6 @@
1 1
 
2
-import Taro, { useDidShow } from '@tarojs/taro'
2
+import { useMemo } from 'react'
3
+import Taro from '@tarojs/taro'
3 4
 import useSave from "@/utils/hooks/useSave"
4 5
 import msTip from '@/assets/icons/housemantj/foodtip.png'
5 6
 import mjTip from '@/assets/icons/housemantj/mjtip.png'
@@ -10,7 +11,13 @@ import './style.less'
10 11
 
11 12
 export default (props) => {
12 13
 
13
-  const { item, style } = props
14
+  const { className, item, style, onImageLoad } = props
15
+  
16
+  const uqClass = useMemo(() => {
17
+    return `f-${Math.random().toString(36).substring(2)}`
18
+  }, [])
19
+
20
+  const cls = useMemo(() => [className, 'contentCard', uqClass].filter(Boolean).join(' '), [className, uqClass])
14 21
 
15 22
   const [isSaved, toggleSave] = useSave(item.isSaved, item.targetType, item.targetId)
16 23
   const Detail = () => {
@@ -22,23 +29,31 @@ export default (props) => {
22 29
     }
23 30
   }
24 31
 
25
-
32
+  const handleLoad = () => {
33
+    Taro.createSelectorQuery().select(`.${uqClass}`).boundingClientRect(rect => {
34
+      onImageLoad(rect)
35
+    }).exec()
36
+  }
26 37
 
27 38
   return (
28
-    <view className='contentCard' style={style}>
29
-      <view className='cardTop'>
30
-        <image mode='widthFix' onClick={Detail} src={item.poster} className='cCardimg' />
31
-        <image className='lefttips' src={item.targetType === 'tourist' ? mjTip : msTip} />
32
-        <image onClick={toggleSave} src={isSaved > 0 ? onlove : love} className='loveharde'></image>
33
-      </view>
34
-      <view className='bContent' onClick={Detail}>
35
-        <view className='cCword'>{(item.title).toString().length > 35 ? (item.title).substring(0, 35) + '...' : (item.title)}</view>
36
-        <view className='cCleft'>
37
-          <image src={location} className='cCicon'></image>
38
-          <view className='distance'><text>{(item.distance / 1000).toFixed(2)}</text>公里</view>
39
+    <view className={uqClass} style={{ overflow: 'hidden' }}>
40
+      <view className='contentCard' style={style}>
41
+        <view className='cardTop'>
42
+          <image mode='widthFix' onClick={Detail} src={item.poster} className='cCardimg' onLoad={handleLoad} />
43
+          <image className='lefttips' src={item.targetType === 'tourist' ? mjTip : msTip} />
44
+          <image onClick={toggleSave} src={isSaved > 0 ? onlove : love} className='loveharde'></image>
39 45
         </view>
40
-        <view className='cCright'>
41
-          <view className='price'><text className='money'>¥</text><text>{item.averagePrice / 100}</text>/人</view>
46
+        <view className='bContent' onClick={Detail}>
47
+          <view className='cCword'>{(item.title).toString().length > 35 ? (item.title).substring(0, 35) + '...' : (item.title)}</view>
48
+          <view className='cCBottom'>
49
+            <view className='cCleft'>
50
+              <image src={location} className='cCicon'></image>
51
+              <view className='distance'><text>{(item.distance / 1000).toFixed(2)}</text>公里</view>
52
+            </view>
53
+            <view className='cCright'>
54
+              <view className='price'><text className='money'>¥</text><text>{item.averagePrice / 100}</text>/人</view>
55
+            </view>
56
+          </view>
42 57
         </view>
43 58
       </view>
44 59
     </view>

+ 34
- 26
src/pages/index/components/Card/style.less ファイルの表示

@@ -3,10 +3,14 @@
3 3
   box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
4 4
   border-radius: 24px;
5 5
   overflow: hidden;
6
-  margin-bottom:50px;
6
+  margin-bottom: 30px;
7 7
   break-inside: avoid;
8 8
   position: relative;
9 9
 
10
+  width: calc(100% - 30px);
11
+  box-sizing: border-box;
12
+  margin-left: 15px;
13
+
10 14
   .cardTop{
11 15
     border-radius: 24px 24px 0px 0px;
12 16
     .cCardimg{
@@ -36,33 +40,37 @@
36 40
       color: #404040;
37 41
       text-align: justify;
38 42
     }
43
+
44
+    .cCBottom {
45
+      display: flex;
39 46
     
40
-    .cCleft{
41
-      float: left;
42
-      position: relative;
43
-      padding:40px 0 30px 0;
44
-      .cCicon{
45
-        width: 17px;
46
-        height: 21px;
47
-        position: absolute;
48
-        left: 0;
49
-        top: 48px;
50
-      }
51
-      .distance{
52
-        padding-left: 24px;
53
-        font-size: 24px;
54
-        color: #C0C8D3;
47
+      .cCleft{
48
+        flex: 1;
49
+        position: relative;
50
+        padding:40px 0 30px 0;
51
+        .cCicon{
52
+          width: 17px;
53
+          height: 21px;
54
+          position: absolute;
55
+          left: 0;
56
+          top: 48px;
57
+        }
58
+        .distance{
59
+          padding-left: 24px;
60
+          font-size: 24px;
61
+          color: #C0C8D3;
62
+        }
55 63
       }
56
-    }
57
-    .cCright{
58
-      position: relative;
59
-      float: right;
60
-      padding:40px 0 30px 0;
61
-      .price{          
62
-        font-size: 24px;
63
-        color: #FF3434;
64
-        .money{
65
-          font-size: 20px;
64
+      .cCright{
65
+        flex: 1;
66
+        position: relative;
67
+        padding:40px 0 30px 0;
68
+        .price{          
69
+          font-size: 24px;
70
+          color: #FF3434;
71
+          .money{
72
+            font-size: 20px;
73
+          }
66 74
         }
67 75
       }
68 76
     }

+ 1
- 4
src/pages/index/index.jsx ファイルの表示

@@ -4,7 +4,6 @@ import React, { useState, useEffect } from 'react'
4 4
 import Taro, { useDidShow } from '@tarojs/taro'
5 5
 import CustomNav from '@/components/CustomNav'
6 6
 import logo from '@/assets/icons/comm/logo_small.png'
7
-import tips from '@/assets/icons/UserCenter/tips.png'
8 7
 
9 8
 import { getHotelDetail } from '@/services/landlord'
10 9
 import { getTaRoom } from '@/services/taRoom​'
@@ -19,7 +18,7 @@ import Recommend from './tabs/Recommend'
19 18
 
20 19
 import './index.less'
21 20
 
22
-
21
+const tips = 'https://yz-shigongli.oss-cn-shanghai.aliyuncs.com/images/sgl-v2-tips.png'
23 22
 
24 23
 export default withLayout((props) => {
25 24
   const { router, person, location } = props
@@ -42,8 +41,6 @@ export default withLayout((props) => {
42 41
     roomId = rid
43 42
   }
44 43
 
45
-
46
-
47 44
   useDidShow(() => {
48 45
     setIsDidShow(isDidShow + 1)
49 46
   })

+ 1
- 1
src/pages/index/tabs/Guide.jsx ファイルの表示

@@ -48,7 +48,7 @@ export default (props) => {
48 48
     if (roomOrderId) {
49 49
       goToRoomForm(roomOrderId).then((res) => {
50 50
         if (res.status !== 1 && res.personNum > 0) {
51
-          Taro.navigateTo({
51
+          Taro.reLaunch({
52 52
             url: `/pages/RoomOrder/index?roomOrderId=${roomOrderId}&status=${res.status}&roomId=${roomId}`,
53 53
           })
54 54
         }

+ 11
- 13
src/pages/index/tabs/Recommend.jsx ファイルの表示

@@ -7,6 +7,7 @@ import Tip from '@/components/tip'
7 7
 import List from '@/components/List';
8 8
 import NoData from '@/components/NoData'
9 9
 import MasonryLayout from '@/components/MasonryLayout';
10
+import Waterfall from '@/components/MasonryLayout/Waterfall';
10 11
 import { getIndexType, getResourceList } from '@/services/home'
11 12
 import Card from '../components/Card'
12 13
 import './less/Recommend.less'
@@ -28,7 +29,6 @@ export default (props) => {
28 29
   const tabs = [{ title: '附近' }].concat(typeList.map(x => ({ ...x, title: x.typeName })))
29 30
   //切换上面的标签
30 31
   const handleTabChange = (e) => {
31
-    console.log('------------handleTabChange-------', queryParams)
32 32
     const { index } = e.detail
33 33
     setActiveTab(index)
34 34
     const tab = tabs[index].typeId || ''
@@ -43,6 +43,7 @@ export default (props) => {
43 43
       listRef.current.context.scrollTo({ top: 0 })
44 44
     }
45 45
   }
46
+
46 47
   useEffect(() => {
47 48
     //查询分类标签表
48 49
     getIndexType({ pageSize: 20 }).then((res) => {
@@ -50,8 +51,6 @@ export default (props) => {
50 51
     })
51 52
   }, [])
52 53
 
53
-
54
-
55 54
   const onSearch = () => {
56 55
     // 用绝对路径
57 56
     Taro.navigateTo({ url: '/pages/search/search' });
@@ -64,9 +63,6 @@ export default (props) => {
64 63
 
65 64
   }
66 65
 
67
-  console.log('-------------------', queryParams)
68
-
69
-
70 66
   useDidShow(() => {
71 67
     likeLook()
72 68
   })
@@ -109,12 +105,14 @@ export default (props) => {
109 105
           params={queryParams}
110 106
           onDataChange={setAllList}
111 107
         >
112
-          {/* <MasonryLayout
113
-            list={alllist}
114
-            render={item => <Card item={item} />}
115
-          /> */}
116
-
117
-          {
108
+          <view style={{ padding: '30rpx 15rpx' }}>
109
+            <Waterfall
110
+              list={alllist}
111
+              render={(item, callback) => <Card item={item} onImageLoad={callback} />}
112
+            />
113
+          </view>
114
+
115
+          {/* {
118 116
             alllist.length == 0 ?
119 117
               <NoData /> :
120 118
               <view className='waterfall'>
@@ -122,7 +120,7 @@ export default (props) => {
122 120
                   alllist.map((item) => <Card key={item.resourceNo} item={item} />)
123 121
                 }
124 122
               </view>
125
-          }
123
+          } */}
126 124
         </List>
127 125
       {/* </View> */}
128 126
     </view>

+ 14
- 8
src/pages/index/tabs/less/Recommend.less ファイルの表示

@@ -27,12 +27,12 @@
27 27
       letter-spacing: 0.2em;
28 28
     }
29 29
 }
30
-.waterfall{
31
-  column-count: 2;      //分两列
32
-  column-gap: 30px;    //列间距
33
-  background-color: #F8F8F8;
34
-  padding:30px 30px 0 30px; 
35
-}
30
+// .waterfall{
31
+//   column-count: 2;      //分两列
32
+//   column-gap: 30px;    //列间距
33
+//   background-color: #F8F8F8;
34
+//   padding:30px 30px 0 30px; 
35
+// }
36 36
 .botton{
37 37
   font-size: 28px;
38 38
   color: #C0C8D3;
@@ -70,21 +70,27 @@
70 70
     }
71 71
   }
72 72
   .tabs-Unselected {
73
-    width: 25vw;      
73
+    // width: 25vw;
74 74
     color: #C0C8D3; 
75 75
     text-align: center;
76 76
     font-size: 28px;
77 77
     line-height: 91px;
78
+    box-sizing: border-box;
79
+    padding: 0 32px;
80
+    letter-spacing: 2px;
78 81
   }
79 82
   .tabs-swiper {
80 83
     max-height: 0;
81 84
   }
82 85
   .tabs-Selected {
86
+    box-sizing: border-box;
83 87
     font-size: 32px;
84 88
     color: #4C4C4C;
85
-    width: 25vw;      
89
+    // width: 25vw;
86 90
     font-weight: bold;
87 91
     text-align: center;
88 92
     border-bottom: 6px solid #4C4C4C;
93
+    padding: 0 32px;
94
+    letter-spacing: 2px;
89 95
   }
90 96
 }