Преглед на файлове

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

吃个甘蔗嚼一年 преди 3 години
родител
ревизия
04f3ec744c

+ 16
- 13
src/components/MasonryLayout/index.jsx Целия файл

@@ -4,8 +4,12 @@ import { View } from '@tarojs/components';
4 4
 import { useList } from './hooks';
5 5
 import { classNames, getRect } from './utils';
6 6
 
7
+import './style.less'
8
+
7 9
 export default (props) => {
8
-  const { className, itemClassName, style, gutter = 0, list = [], render, ...leftProps } = props
10
+  const { className, itemClassName, style, gutter = 0, list, render, ...leftProps } = props
11
+
12
+  const splitStyle = { width: `${gutter}rpx` }
9 13
 
10 14
   const leftBottom = useRef(0)
11 15
   const rightBottom = useRef(0)
@@ -20,25 +24,22 @@ export default (props) => {
20 24
   useEffect(() => {
21 25
     if (list && list.length) {
22 26
       setCursor(0)
23
-      setLeftList([])
24
-      setRightList([])
25
-      console.log('----------useEffect--------')
26 27
     } else {
27 28
       setCursor(-1)
29
+      setLeftList([])
30
+      setRightList([])
28 31
     }
29 32
   }, [list])
30 33
 
31 34
   useEffect(() => {
32 35
     const len = !listRef.current ? 0 : listRef.current.length;
33 36
 
34
-    if (!len || cursor >= len) return;
37
+    if (leftRef.current.length + rightRef.current.length >= len) return;
35 38
 
36 39
     const item = listRef.current[cursor] || {}
37 40
     item.__vid = `f-${Math.random().toString(36).substring(2)}`
38 41
     vidRef.current = item.__vid
39 42
 
40
-    console.log('----------leftRef.current--------', leftRef.current, rightRef.current)
41
-
42 43
     if (leftBottom.current <= rightBottom.current) {
43 44
       setLeftList([...leftRef.current, item])
44 45
     } else {
@@ -46,12 +47,8 @@ export default (props) => {
46 47
     }
47 48
   }, [cursor])
48 49
 
49
-  
50
-  console.log('---------dddddddd------', vidRef.current, leftRef.current.length, leftList)
51
-
52 50
   useEffect(() => {
53 51
     const setHeight = (rect) => {
54
-      console.log('---------rect------', rect)
55 52
       const { bottom } = rect
56 53
       if (cursor % 2 === 0) {
57 54
         leftBottom.current = bottom
@@ -63,13 +60,18 @@ export default (props) => {
63 60
 
64 61
     const calcHeight = () => {
65 62
       getRect(`.${vidRef.current}`).then((res) => {
66
-        if (!res || !res.length) {
63
+        if (!res) {
64
+          // 找不到 node , 则一直重复查询
67 65
           const t = setTimeout(() => {
68 66
             clearTimeout(t)
69 67
             calcHeight()
70 68
           }, 300)
71 69
         } else {
72
-          setHeight(res[0])
70
+          if (Array.isArray(res)) {
71
+            setHeight(res[0])
72
+          } else {
73
+            setHeight(res)
74
+          }
73 75
         }
74 76
       })
75 77
     }
@@ -89,6 +91,7 @@ export default (props) => {
89 91
           ))
90 92
         }
91 93
       </View>
94
+      <View className='masonry-split' style={splitStyle} />
92 95
       <View className='masonry-column'>
93 96
         {
94 97
           rightList.map((item) => (

+ 4
- 0
src/components/MasonryLayout/style.less Целия файл

@@ -7,6 +7,10 @@
7 7
   .masonry-column {
8 8
     flex: 1;
9 9
   }
10
+  
11
+  .masonry-split {
12
+    flex: none;
13
+  }
10 14
 
11 15
   .masonry-item {
12 16
     width: 100%;

+ 4
- 2
src/components/tip/index.jsx Целия файл

@@ -4,7 +4,9 @@ import { useState, useEffect } from 'react';
4 4
 import icontip from '@/assets/icons/housemantj/tip.png'
5 5
 import './index.less'
6 6
 
7
-export default () => {
7
+export default (props) => {
8
+  const { style } = props
9
+
8 10
   const [tips, setTips] = useState([])
9 11
   useEffect(() => {
10 12
     getTipList(1).then((res) => {
@@ -12,7 +14,7 @@ export default () => {
12 14
     })
13 15
   }, [])
14 16
   return (
15
-    <view className='tip'>
17
+    <view className='tip' style={style}>
16 18
       <image className='tipicon' src={icontip} />
17 19
       <Swiper
18 20
         className='swp'

+ 6
- 6
src/pages/PayOrder/index.jsx Целия файл

@@ -89,10 +89,10 @@ export default withLayout((props) => {
89 89
 
90 90
   const onShowPay = (e) => {
91 91
     if (agreement) {
92
-      if (payInfo) {
93
-        requestPayment(payInfo);
94
-        return;
95
-      }
92
+      // if (payInfo) {
93
+      //   requestPayment(payInfo);
94
+      //   return;
95
+      // }
96 96
 
97 97
       Taro.showLoading({
98 98
         title: '支付中',
@@ -108,7 +108,7 @@ export default withLayout((props) => {
108 108
             };
109 109
           })
110 110
         ).then((res) => {
111
-          setPayInfo(res);
111
+          // setPayInfo(res);
112 112
           requestPayment(res);
113 113
         }).catch(() => {
114 114
           Taro.hideLoading()
@@ -121,7 +121,7 @@ export default withLayout((props) => {
121 121
       }
122 122
       if (orderId) {
123 123
         payOrder(orderId).then((res) => {
124
-          setPayInfo(res);
124
+          // setPayInfo(res);
125 125
           requestPayment(res);
126 126
         }).catch(() => {
127 127
           Taro.hideLoading()

+ 27
- 26
src/pages/index/tabs/Recommend.jsx Целия файл

@@ -6,7 +6,7 @@ import locationimg from '@/assets/icons/housemantj/location.png'
6 6
 import Tip from '@/components/tip'
7 7
 import List from '@/components/List';
8 8
 import NoData from '@/components/NoData'
9
-import MasonryLayout from '@/components/MasonryLayout';
9
+import SpinBox from '@/components/Spin/SpinBox';
10 10
 import { getIndexType, getResourceList } from '@/services/home'
11 11
 import Card from '../components/Card'
12 12
 import './less/Recommend.less'
@@ -74,7 +74,7 @@ export default (props) => {
74 74
   return (
75 75
     // <view style={{ height: '100%', overflow: 'hidden',display:'flex',flexDirection:'column' }}>
76 76
     <view style={{ height: '100%', overflow: 'hidden' }}>
77
-      <view className='search' onClick={onSearch}>
77
+      <view className='search' onClick={onSearch} >
78 78
         <input className='searchInput' disabled />
79 79
         <image className='searchicon' src={iconsearch} />
80 80
         <view className='searchword'>搜索</view>
@@ -99,30 +99,31 @@ export default (props) => {
99 99
           </mp-tabs>
100 100
         </scroll-view>
101 101
       </view>
102
-      {/* <View style={{flex:'auto'}}> */}
103
-      <List
104
-        ref={listRef}
105
-        // style={{ height: '100%' }}
106
-        style={{ height: 'calc(100% - 145px)' }}
107
-        request={getResourceList}
108
-        params={queryParams}
109
-        onDataChange={setAllList}
110
-      >
111
-        {/* <MasonryLayout
112
-          list={alllist}
113
-          render={item => <Card item={item} />}
114
-        /> */}
115
-
116
-        {
117
-          alllist.length == 0 ?
118
-            <NoData /> :
119
-            <view className='waterfall'>
120
-              {
121
-                alllist.map((item) => <Card key={item.resourceNo} item={item} />)
122
-              }
123
-            </view>
124
-        }
125
-      </List>
102
+      {/* <View style={{ flex:'auto' }}> */}
103
+        <List
104
+          ref={listRef}
105
+          style={{ height: 'calc(100% - 145px)' }}
106
+          // style={{ flex: 'auto', height: '100%' }}
107
+          request={getResourceList}
108
+          params={queryParams}
109
+          onDataChange={setAllList}
110
+        >
111
+          {/* <MasonryLayout
112
+            className='waterfall'
113
+            list={alllist}
114
+            render={item => <Card item={item} />}
115
+          /> */}
116
+
117
+          {
118
+            alllist.length == 0 ?
119
+              <NoData /> :
120
+              <view className='waterfall'>
121
+                {
122
+                  alllist.map((item) => <Card key={item.resourceNo} item={item} />)
123
+                }
124
+              </view>
125
+          }
126
+        </List>
126 127
       {/* </View> */}
127 128
     </view>
128 129
   )

+ 2
- 2
src/pages/index/tabs/less/Recommend.less Целия файл

@@ -32,7 +32,7 @@
32 32
   column-gap: 30px;    //列间距
33 33
   background-color: #F8F8F8;
34 34
   padding:30px 30px 0 30px; 
35
-} 
35
+}
36 36
 .botton{
37 37
   font-size: 28px;
38 38
   color: #C0C8D3;
@@ -87,4 +87,4 @@
87 87
     text-align: center;
88 88
     border-bottom: 6px solid #4C4C4C;
89 89
   }
90
-}
90
+}