张延森 3 years ago
parent
commit
7a20f1e55a
4 changed files with 59 additions and 49 deletions
  1. 1
    1
      project.config.json
  2. 20
    21
      src/components/List/index.jsx
  3. 21
    0
      src/components/Spin/Spin3.jsx
  4. 17
    27
      src/pages/index/tabs/Recommend.jsx

+ 1
- 1
project.config.json View File

@@ -2,7 +2,7 @@
2 2
   "miniprogramRoot": "./dist",
3 3
   "projectname": "miniapp",
4 4
   "description": "十公里",
5
-  "appid": "wx06a7372d48d56843",
5
+  "appid": "wx835627a9b9b3932a",
6 6
   "setting": {
7 7
     "urlCheck": true,
8 8
     "es6": false,

+ 20
- 21
src/components/List/index.jsx View File

@@ -1,6 +1,5 @@
1 1
 import React, { useEffect, useRef, useState, useImperativeHandle, useMemo } from 'react';
2
-import SpinBox from "@/components/Spin/SpinBox";
3
-
2
+import Spin3 from '@/components/Spin/Spin3';
4 3
 import { ScrollView } from '@tarojs/components';
5 4
 import Taro from '@tarojs/taro';
6 5
 
@@ -94,24 +93,24 @@ export default React.forwardRef((props, ref) => {
94 93
   }))
95 94
 
96 95
   return (
97
-    <SpinBox loading={loading}>
98
-      <ScrollView
99
-        scrollY
100
-        enhanced
101
-        onScrollToLower={handleScrollToLower}
102
-        {...leftProps}
103
-        className={`${className} ${uqCls} list-view`}
104
-      >
105
-        {!render
106
-          ? props.children
107
-          : list.map((item, index) => render({ item, index }))
108
-        }
109
-        {!list || !list.length && noData}
110
-
111
-        {list && list.length > 0 && !hasMore &&
112
-          <view className='botton'>这是我的底线</view>
113
-        }
114
-      </ScrollView>
115
-    </SpinBox>
96
+    <ScrollView
97
+      scrollY
98
+      enhanced
99
+      onScrollToLower={handleScrollToLower}
100
+      {...leftProps}
101
+      className={`${className} ${uqCls} list-view`}
102
+    >
103
+      {!render
104
+        ? props.children
105
+        : list.map((item, index) => render({ item, index }))
106
+      }
107
+      {!list || !list.length && noData}
108
+
109
+      <Spin3 show={loading} />
110
+
111
+      {list && list.length > 0 && !hasMore &&
112
+        <view className='botton'>这是我的底线</view>
113
+      }
114
+    </ScrollView>
116 115
   )
117 116
 })

+ 21
- 0
src/components/Spin/Spin3.jsx View File

@@ -0,0 +1,21 @@
1
+import React from 'react'
2
+import classNames from 'classnames'
3
+
4
+/**
5
+ * 参考 https://github.com/wechat-miniprogram/weui-miniprogram/blob/master/src/components/loading/loading.wxml
6
+ */
7
+export default (props) => {
8
+  const { className, show, animated, duration = 350, tips = '加载中' } = props
9
+
10
+  const cls = classNames('wx_loading_view', { 'wx_loading_view__animated': animated }, { 'wx_loading_view__hide': !show }, className)
11
+  const style = animated ? { transition: `height ${duration} ms ease` } : {}
12
+
13
+  return (
14
+    <view className={cls} style={style}>
15
+      <view class='weui-loadmore'>
16
+          <view class='weui-loading'></view>
17
+          <view class='weui-loadmore__tips'>{tips}</view>
18
+      </view>
19
+    </view>
20
+  )
21
+}

+ 17
- 27
src/pages/index/tabs/Recommend.jsx View File

@@ -106,33 +106,23 @@ export default (props) => {
106 106
           </mp-tabs>
107 107
         </scroll-view>
108 108
       </view>
109
-      {/* <View style={{ flex:'auto' }}> */}
110
-      <List
111
-        ref={listRef}
112
-        style={listStyle}
113
-        request={getResourceList}
114
-        params={queryParams}
115
-        onDataChange={handleDataChange}
116
-      >
117
-        <view style={{ padding: '30rpx 15rpx' }}>
118
-          <MasonryLayout
119
-            itemKey='resourceNo'
120
-            listData={listData}
121
-            render={(item, callback) => <Card item={item} onImageLoad={callback} />}
122
-          />
123
-        </view>
124
-
125
-        {/* {
126
-            alllist.length == 0 ?
127
-              <NoData /> :
128
-              <view className='waterfall'>
129
-                {
130
-                  alllist.map((item) => <Card key={item.resourceNo} item={item} />)
131
-                }
132
-              </view>
133
-          } */}
134
-      </List>
135
-      {/* </View> */}
109
+      <view style={{ flex:'auto' }}>
110
+        <List
111
+          ref={listRef}
112
+          style={listStyle}
113
+          request={getResourceList}
114
+          params={queryParams}
115
+          onDataChange={handleDataChange}
116
+        >
117
+          <view style={{ padding: '30rpx 15rpx' }}>
118
+            <MasonryLayout
119
+              itemKey='resourceNo'
120
+              listData={listData}
121
+              render={(item, callback) => <Card item={item} onImageLoad={callback} />}
122
+            />
123
+          </view>
124
+        </List>
125
+      </view>
136 126
     </view>
137 127
   )
138 128
 }