吃个甘蔗嚼一年 3 lat temu
rodzic
commit
e4eac5842f

+ 35
- 0
src/components/List/index.jsx Wyświetl plik

@@ -14,6 +14,7 @@ export default React.forwardRef((props, ref) => {
14 14
     onDataChange,
15 15
     noData,
16 16
     className,
17
+    refres,
17 18
     ...leftProps
18 19
   } = props
19 20
 
@@ -65,6 +66,7 @@ export default React.forwardRef((props, ref) => {
65 66
     })
66 67
   }
67 68
 
69
+
68 70
   const fetchRef = useRef()
69 71
   fetchRef.current = fetchList
70 72
 
@@ -85,7 +87,38 @@ export default React.forwardRef((props, ref) => {
85 87
       }).exec()
86 88
     })
87 89
   }, [])
90
+  const asd = () => {
91
+    request({
92
+      ...params,
93
+      pageSize,
94
+      pageNum: pageRef.current.current
95
+    }).then((res) => {
96
+      const { records, ...pageInfo } = res || {}
97
+      const lst = pageInfo.current === 1 ? records || [] : list.concat(records || [])
98
+      setList(lst)
99
+      setHasMore(pageInfo.current < pageInfo.pages)
100
+
101
+      if (onDataChange) {
102
+        onDataChange(lst, { paramsChanged: pageInfo.current === 1 })
103
+      }
104
+
88 105
 
106
+      pageRef.current = pageInfo
107
+      setLoading(false)
108
+      refres()
109
+
110
+
111
+    }).catch((err) => {
112
+      console.error(err)
113
+      setLoading(false)
114
+      refres()
115
+
116
+      if (onError) {
117
+        onError(err)
118
+      }
119
+    })
120
+
121
+  }
89 122
   // https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.html
90 123
   // ScrollViewContext 透传给父组件
91 124
   //https://zh-hans.reactjs.org/docs/hooks-reference.html#useimperativehandle
@@ -97,6 +130,8 @@ export default React.forwardRef((props, ref) => {
97 130
     <ScrollView
98 131
       scrollY
99 132
       enhanced
133
+      refresherEnabled={props}
134
+      onRefresherrefresh={asd}
100 135
       onScrollToLower={handleScrollToLower}
101 136
       {...leftProps}
102 137
       className={`${className} ${uqCls} list-view`}

+ 2
- 0
src/hotel/components/HouseManage/houseManage.jsx Wyświetl plik

@@ -167,6 +167,8 @@ export default React.forwardRef((props, ref) => {
167 167
           request={getRoomList}
168 168
           params={queryParams}
169 169
           onDataChange={setDetail}
170
+          refresherEnabled={false}
171
+
170 172
           noData="暂无房源信息"
171 173
         >
172 174
           <view className='waterfall'>

+ 6
- 4
src/hotel/components/Income/income.jsx Wyświetl plik

@@ -13,11 +13,11 @@ import './income.less'
13 13
 const getList = id => params => getAccountLogList(id, params)
14 14
 
15 15
 export default (props) => {
16
-  const {  hotel, account } = props
16
+  const { hotel, account } = props
17 17
 
18 18
   const queryParams = useMemo(() => ({}), [])
19 19
 
20
-  const fetchAPI = useMemo(()=>account.accountId ? getList(account.accountId) : undefined, [account?.accountId])
20
+  const fetchAPI = useMemo(() => account.accountId ? getList(account.accountId) : undefined, [account?.accountId])
21 21
 
22 22
   const [isyear, setYear] = useState(true)
23 23
   const [isMomth, setMonth] = useState(false)
@@ -36,7 +36,7 @@ export default (props) => {
36 36
             <view className='sleft'>
37 37
               <view className='lword'>全年收入(税前)</view>
38 38
               <view className='yearMoney'>
39
-                <text>{isyear ? formatPrice(account?.amounts): '******'}</text>元
39
+                <text>{isyear ? formatPrice(account?.amounts) : '******'}</text>元
40 40
                 <image className='micon' src={isyear ? eyes : ceyes} onClick={handleYear} />
41 41
               </view>
42 42
             </view>
@@ -57,7 +57,9 @@ export default (props) => {
57 57
           request={fetchAPI}
58 58
           params={queryParams}
59 59
           noData={<NoData />}
60
-          render={({item, index}) => (
60
+          refresherEnabled={false}
61
+
62
+          render={({ item, index }) => (
61 63
             <view className='spreadCard' key={index}>
62 64
               <view className='card'>
63 65
                 <view className='spreadTime'>时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间:<text>{formatTime(item.createDate, 'yyyy/MM/dd hh:mm:ss')}</text></view>

+ 2
- 0
src/pages/MineUserAll/Collect/index.jsx Wyświetl plik

@@ -25,6 +25,8 @@ export default withLayout((props) => {
25 25
           style={{ height: '100%' }}
26 26
           request={getCollectList}
27 27
           params={queryParams}
28
+          refresherEnabled={false}
29
+
28 30
           onDataChange={setCollectContent}
29 31
         >
30 32
           {

+ 3
- 1
src/pages/searchResult/searchResult.jsx Wyświetl plik

@@ -1,4 +1,4 @@
1
-import { React, useState,useRef } from 'react'
1
+import { React, useState, useRef } from 'react'
2 2
 // .就是当前路径
3 3
 import iconsearch from '../../assets/icons/housemantj/search.png'
4 4
 import CustomNav from '@/components/CustomNav'
@@ -90,6 +90,8 @@ export default withLayout((props) => {
90 90
           request={getResourceList}
91 91
           params={queryParams}
92 92
           onDataChange={setAllList}
93
+          refresherEnabled={false}
94
+
93 95
         >
94 96
           {
95 97
             alllist.length == 0 ?

+ 25
- 1
src/shop/components/ShopKeeper/shopKeeper.jsx Wyświetl plik

@@ -34,7 +34,23 @@ export default (props) => {
34 34
 
35 35
   const [isyear, setYear] = useState(true)
36 36
   const [isMomth, setMonth] = useState(false)
37
-  //小眼睛开关
37
+  const [refres, setRefres] = useState(true)
38
+
39
+  /**
40
+   *s 刷新结束后关闭
41
+   */
42
+  const refresOff = () => {
43
+    setRefres(false)
44
+    Taro.showToast({
45
+      title: '刷新成功',
46
+      icon: 'none'
47
+    })
48
+    setTimeout(() => {
49
+      setRefres(true)
50
+
51
+    }, 2000);
52
+  }
53
+
38 54
   const handleYear = () => {
39 55
     isyear ? setYear(false) : setYear(true)
40 56
   }
@@ -51,6 +67,7 @@ export default (props) => {
51 67
     const val = e.detail.value
52 68
     setPhone(val)
53 69
   }
70
+
54 71
   useEffect(() => {
55 72
     if (tabJump) {
56 73
       setActiveTab(tabJump - 0)
@@ -59,6 +76,9 @@ export default (props) => {
59 76
 
60 77
 
61 78
 
79
+
80
+
81
+
62 82
   const handleTabChange = (e) => {
63 83
     const { index } = e.detail
64 84
     setActiveTab(index)
@@ -143,6 +163,8 @@ export default (props) => {
143 163
                 request={getVerifiedOrder}
144 164
                 params={queryParams}
145 165
                 onDataChange={setAllList}
166
+                refresherEnabled={refres}
167
+                refres={refresOff}
146 168
                 noData={<NoData />}
147 169
                 render={({ item, index }) =>
148 170
                   <ShopUnused key={(index)} item={item} />}
@@ -159,6 +181,8 @@ export default (props) => {
159 181
                 noData={<NoData />}
160 182
                 request={getVerifiedOrder}
161 183
                 params={queryParams}
184
+                refresherEnabled={refres}
185
+
162 186
                 onDataChange={setAllList}
163 187
                 render={({ item, index }) => <ShopUsed verifiedOrder={verifiedOrder} key={(index)} item={item} />}
164 188
               >

+ 2
- 0
src/shop/components/Sparead/spreadMoney.jsx Wyświetl plik

@@ -90,6 +90,8 @@ export default (props) => {
90 90
             request={reqestAPI}
91 91
             params={queryParams}
92 92
             noData={<NoData />}
93
+            refresherEnabled
94
+
93 95
             render={({ item, index }) => <ShopCommission key={(index)} item={item} />}
94 96
           >
95 97
           </List>