张延森 3 年 前
コミット
241c0555d4
共有3 個のファイルを変更した26 個の追加25 個の削除を含む
  1. 4
    4
      src/components/List/index.jsx
  2. 14
    7
      src/components/Spin/SpinBox.jsx
  3. 8
    14
      src/components/Spin/style.less

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

@@ -27,7 +27,7 @@ export default React.forwardRef((props, ref) => {
27 27
 
28 28
   // 滚动
29 29
   const handleScrollToLower = (e) => {
30
-    const loading = loadingRef.current
30
+    // const loading = loadingRef.current
31 31
 
32 32
     if (!loading && hasMore) {
33 33
       setPayload({
@@ -41,7 +41,7 @@ export default React.forwardRef((props, ref) => {
41 41
     if (!request) return;
42 42
 
43 43
     setLoading(true)
44
-    loadingRef.current = true
44
+    // loadingRef.current = true
45 45
     request(params).then((res) => {
46 46
       const { records, ...pageInfo } = res || {}
47 47
       const lst = pageInfo.current === 1 ? records || [] : list.concat(records || [])
@@ -51,12 +51,12 @@ export default React.forwardRef((props, ref) => {
51 51
       }
52 52
 
53 53
       pageRef.current = pageInfo
54
-      loadingRef.current = false
54
+      // loadingRef.current = false
55 55
 
56 56
       setLoading(false)
57 57
 
58 58
     }).catch((err) => {
59
-      loadingRef.current = false
59
+      // loadingRef.current = false
60 60
       console.error(err)
61 61
       setLoading(false)
62 62
 

+ 14
- 7
src/components/Spin/SpinBox.jsx ファイルの表示

@@ -4,6 +4,19 @@ import { View } from '@tarojs/components'
4 4
 import Spin from '.'
5 5
 import './style.less'
6 6
 
7
+const Loading = (props) => {
8
+  const { loading, size = '64rpx', ...leftProps } = props
9
+
10
+  const cls = ['loading-box', loading? 'active' : undefined].filter(Boolean).join(' ')
11
+
12
+  return (
13
+    <View className={cls}>
14
+      <Spin size={size} {...leftProps} />
15
+    </View>
16
+  )
17
+}
18
+
19
+
7 20
 export default (props) => {
8 21
   const { className, style, loading, size = '64rpx', ...leftProps } = props
9 22
 
@@ -11,14 +24,8 @@ export default (props) => {
11 24
 
12 25
   return (
13 26
     <View className={cls} style={style}>
14
-      {
15
-        loading && (
16
-          <View className='loading-box'>
17
-            <Spin size={size} {...leftProps} />
18
-          </View>
19
-        )
20
-      }
21 27
       {props.children}
28
+      <Loading loading={loading} size={size} {...leftProps} />
22 29
     </View>
23 30
   )
24 31
 }

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

@@ -140,22 +140,11 @@
140 140
 .loading-wrapper {
141 141
   height: 100%;
142 142
   position: relative;
143
+  overflow: hidden;
143 144
 
144 145
   .loading-box {
145
-    // position: absolute;
146
-    // z-index: 10;
147
-    // top: 0;
148
-    // left: 0;
149
-    // width: 100%;
150
-    // height: 100%;
151
-    // min-height: 72px;
152
-    // padding-top: 60%;
153
-    // padding-left: 50%;
154
-    // background: rgba(255, 255, 255, .95);
155
-    // box-sizing: border-box;
156
-
157 146
     position: absolute;
158
-    z-index: 10;
147
+    z-index: -10;
159 148
     top: 0;
160 149
     left: 0;
161 150
     width: 100%;
@@ -164,7 +153,12 @@
164 153
     padding-top: 35%;
165 154
     padding-left: 50%;
166 155
     background: rgba(255, 255, 255, 0.95);
167
-    -webkit-box-sizing: border-box;
168 156
     box-sizing: border-box;
157
+    opacity: 0;
158
+
159
+    &.active {
160
+      opacity: 1;
161
+      z-index: 10;
162
+    }
169 163
   }
170 164
 }