张延森 4 年之前
父節點
當前提交
7b6b8386a3

+ 10
- 0
config/index.js 查看文件

@@ -1,3 +1,5 @@
1
+const path = require('path')
2
+
1 3
 const config = {
2 4
   projectName: 'shigongliserverh5',
3 5
   date: '2020-12-19',
@@ -59,6 +61,14 @@ const config = {
59 61
         }
60 62
       }
61 63
     }
64
+  },
65
+  alias: {
66
+    '@/assets': path.resolve(__dirname, '..', 'src/assets'),
67
+    '@/compents': path.resolve(__dirname, '..', 'src/compents'),
68
+    '@/layout': path.resolve(__dirname, '..', 'src/layout'),
69
+    '@/store': path.resolve(__dirname, '..', 'src/store'),
70
+    '@/reducers': path.resolve(__dirname, '..', 'src/reducers'),
71
+    '@/util': path.resolve(__dirname, '..', 'src/util')
62 72
   }
63 73
 }
64 74
 

+ 5
- 4
package.json 查看文件

@@ -45,6 +45,7 @@
45 45
     "lodash.groupby": "^4.6.0",
46 46
     "react": "^16.10.0",
47 47
     "react-dom": "^16.10.0",
48
+    "react-list": "^0.8.16",
48 49
     "react-redux": "^7.2.2",
49 50
     "redux": "^4.0.5",
50 51
     "taro-ui": "^3.0.0-alpha.7"
@@ -53,14 +54,14 @@
53 54
     "@babel/core": "^7.8.0",
54 55
     "@tarojs/mini-runner": "3.0.13",
55 56
     "@tarojs/webpack-runner": "3.0.13",
57
+    "@types/react": "^16.0.0",
56 58
     "@types/webpack-env": "^1.13.6",
57 59
     "babel-preset-taro": "3.0.13",
58 60
     "eslint": "^6.8.0",
59 61
     "eslint-config-taro": "3.0.13",
60
-    "stylelint": "9.3.0",
61
-    "@types/react": "^16.0.0",
62
-    "eslint-plugin-react": "^7.8.2",
63 62
     "eslint-plugin-import": "^2.12.0",
64
-    "eslint-plugin-react-hooks": "^1.6.1"
63
+    "eslint-plugin-react": "^7.8.2",
64
+    "eslint-plugin-react-hooks": "^1.6.1",
65
+    "stylelint": "9.3.0"
65 66
   }
66 67
 }

+ 39
- 0
src/compents/InifiniteList/index.jsx 查看文件

@@ -0,0 +1,39 @@
1
+import React, { useEffect, useRef, useState } from 'react'
2
+import ReactList from 'react-list'
3
+import './index.scss'
4
+
5
+export default props => {
6
+  const ref = useRef()
7
+
8
+  const handleScroll = () => {
9
+    const done = props.length >= props.total
10
+
11
+    if (!done) {
12
+      const [, last] = ref.current.getVisibleRange()
13
+      // 如果未展示的数据少于3条就请求数据
14
+      if (props.length - last < 3) {
15
+        props.loadMore()
16
+      }
17
+    }
18
+  }
19
+
20
+  const NoData = (
21
+    <div className="no-data">
22
+      {props.nodata || '暂无数据'}
23
+    </div>
24
+  )
25
+
26
+  return (
27
+    <div className="inifinite-list-wrapper" style={{maxHeight: props.height}} onScroll={handleScroll}>
28
+      {
29
+        !props.length ? NoData :
30
+        <ReactList
31
+          ref={ref}
32
+          type="uniform"
33
+          length={props.length}
34
+          itemRenderer={props.itemRenderer}
35
+        />
36
+      }
37
+    </div>
38
+  )
39
+}

+ 18
- 0
src/compents/InifiniteList/index.scss 查看文件

@@ -0,0 +1,18 @@
1
+.inifinite-list-wrapper {
2
+  &::-webkit-scrollbar {
3
+    display: none;
4
+  }
5
+
6
+  scrollbar-width: none; /* firefox */
7
+  -ms-overflow-style: none; /* IE 10+ */
8
+  overflow-x: hidden;
9
+  overflow-y: auto;
10
+
11
+  .no-data {
12
+    text-align: center;
13
+    font-size: 1.2em;
14
+    color: #aaa;
15
+    position: relative;
16
+    top: 20%;
17
+  }
18
+}

+ 12
- 0
src/compents/NoData/index.jsx 查看文件

@@ -0,0 +1,12 @@
1
+import React, { useEffect, useState } from 'react'
2
+import './index.scss'
3
+
4
+export default props => {
5
+  return (
6
+    <div className={`no-data-wrapper ${props.className}`} style={props.style}>
7
+      {
8
+        props.nodata ? <div className="no-data-view">{props.tips || '暂无数据'}</div> : props.children
9
+      }
10
+    </div>
11
+  )
12
+}

+ 17
- 0
src/compents/NoData/index.scss 查看文件

@@ -0,0 +1,17 @@
1
+.no-data-wrapper {
2
+  position: relative;
3
+  height: 100%;
4
+  min-height: 200px;
5
+
6
+  .no-data-view {
7
+    width: 100%;
8
+    text-align: center;
9
+    font-size: 0.8em;
10
+    color: #aaa;
11
+    position: absolute;
12
+    left: 0;
13
+    top: 50%;
14
+    transform: translateY(-50%);
15
+    line-height: 2em;
16
+  }
17
+}

+ 2
- 2
src/compents/tags/index.jsx 查看文件

@@ -34,8 +34,8 @@ console.log(newkeyList,keyList)
34 34
     return <View className='tags'>
35 35
         <View className='at-row at-row--wrap' style={{ marginTop: '10rpx' }}>
36 36
             {
37
-                list.map((item) => {
38
-                    return <View className='at-col at-col-4 ' >
37
+                list.map((item, index) => {
38
+                    return <View className='at-col at-col-4 ' key={index}>
39 39
                         <View className={`tags-btn tags-btn${keyList.find(x => x.tagId === item.tagId) ? '-on' : ''}`} onClick={() => onClick(item)} >{item.name}</View>
40 40
                     </View>
41 41
                 })

+ 1
- 1
src/compents/tags/index.scss 查看文件

@@ -4,7 +4,7 @@
4 4
 
5 5
   &-btn {
6 6
     background-color: #ffffff;
7
-    color: #acacac;
7
+    color: #666;
8 8
     margin: 10px;
9 9
     font-size: 22px;
10 10
     height: 50px;

+ 20
- 19
src/pages/account/index.jsx 查看文件

@@ -7,6 +7,7 @@ import Tab from '../../compents/tab/index'
7 7
 import Layout from '../../layout/index'
8 8
 import request from '../../util/request'
9 9
 import getQueryValue from '../../util/getQueryValue'
10
+import NoData from '@/compents/NoData'
10 11
 
11 12
 
12 13
 const account = (props) => {
@@ -52,25 +53,25 @@ const account = (props) => {
52 53
 
53 54
   return <View className='account'>
54 55
     <Layout>
55
-      {list.map((item, index) => {
56
-        return <View className='account-view'>
57
-          {/* <Text className='account-view-title'>房源编号:<Text style={{fontSize:"1rem"}}>{item.keeperId}</Text></Text> */}
58
-          <ContainerLayout className='account-view-card'>
59
-            <View className='top' >
60
-              <View>姓名:{item.name}</View>
61
-              <View>电话:{item.phone}</View>
62
-              {/* <View>微信号:{x.user.name}</View>
63
-              <View>房源数:{x.user.name}</View> */}
64
-            </View>
65
-            <View className='bottom'>
66
-              <Text onClick={() => { Taro.navigateTo({ url: `/pages/account/edit/index?keeperId=${item.keeperId}` }) }}>编辑</Text>
67
-              <Text onClick={()=>onDelete(item.keeperId)}>删除</Text>
68
-            </View>
69
-          </ContainerLayout>
70
-
71
-        </View>
72
-
73
-      })}
56
+      <NoData nodata={!list.length} tips="暂无老板" style={{minHeight: '200px'}}>
57
+        {list.map((item, index) => {
58
+          return <View className='account-view' key={index}>
59
+            {/* <Text className='account-view-title'>房源编号:<Text style={{fontSize:"1rem"}}>{item.keeperId}</Text></Text> */}
60
+            <ContainerLayout className='account-view-card'>
61
+              <View className='top' >
62
+                <View>姓名:{item.name}</View>
63
+                <View>电话:{item.phone}</View>
64
+                {/* <View>微信号:{x.user.name}</View>
65
+                <View>房源数:{x.user.name}</View> */}
66
+              </View>
67
+              <View className='bottom'>
68
+                <Text onClick={() => { Taro.navigateTo({ url: `/pages/account/edit/index?keeperId=${item.keeperId}` }) }}>编辑</Text>
69
+                <Text onClick={()=>onDelete(item.keeperId)}>删除</Text>
70
+              </View>
71
+            </ContainerLayout>
72
+          </View>
73
+        })}
74
+      </NoData>
74 75
     </Layout>
75 76
     {/* onClick={(e)=>(e) */}
76 77
     <Tab value={['+新增名宿老板账号']} color='#ffffff' onClick={() => { Taro.navigateTo({ url: `/pages/account/edit/index?id=${id}` }) }} ></Tab>

+ 1
- 1
src/pages/adminUser/index.jsx 查看文件

@@ -79,7 +79,7 @@ const index = (props) => {
79 79
 
80 80
     <View className='page-container'>
81 81
       {menuList.map((row) => {
82
-        return <ContainerLayout className='adminuser-menu' onClick={() => onClick(row)}>
82
+        return <ContainerLayout key={row.url} className='adminuser-menu' onClick={() => onClick(row)}>
83 83
           <Text>{row.title}</Text>
84 84
           <View className='adminuser-menu-img' >
85 85
             <Image className='image' src={row.icon}></Image>

+ 5
- 1
src/pages/imglist/index.jsx 查看文件

@@ -13,6 +13,7 @@ import { AtFloatLayout } from "taro-ui"
13 13
 import getQueryValue from '../../util/getQueryValue';
14 14
 import request, { uploadFiles } from '../../util/request';
15 15
 import groupby from 'lodash.groupby';
16
+import NoData from '@/compents/NoData'
16 17
 
17 18
 // Page({
18 19
 //     data: {
@@ -164,7 +165,8 @@ const index = (props) => {
164 165
 
165 166
     return <View className='imglist'>
166 167
 
167
-
168
+        
169
+        <NoData nodata={!list.length}>
168 170
 
169 171
 
170 172
         {!labelState&&<View style={{ padding: '0 30px' }}>
@@ -204,6 +206,8 @@ const index = (props) => {
204 206
         </View>
205 207
         }
206 208
 
209
+        </NoData>
210
+
207 211
         <AtFloatLayout isOpened={isOpened} onClose={() => handleClose()} style={{ zIndex: '1000' }}>
208 212
             <View className='floatmodel' >
209 213
                 <View onClick={() => updateLabel()}>更改标签</View>

+ 1
- 41
src/pages/index/index.jsx 查看文件

@@ -6,48 +6,8 @@ import AdminUser from '../adminUser/index'
6 6
 import './index.scss'
7 7
 
8 8
 const index = (props) => {
9
-
10
-
11
-
12
-  const [userRole, setUserRole] = useState('1')
13
-  const [pageState, SetPageState] = useState('1')
14
-  const [list, setList] = useState([])
15
-  useEffect(() => {
16
-
17
-    
18
-    setList([
19
-      {
20
-        name: 'zhou',
21
-        phone: '177'
22
-      },
23
-      {
24
-        name: 'zhou',
25
-        phone: '177'
26
-      },
27
-      {
28
-        name: 'zhou',
29
-        phone: '177'
30
-      }
31
-    ])
32
-  }, [])
33
-
34
-
35
-  const onTabClick = (e) => {
36
-    console.log(e, '111')
37
-    setUserRole(e)
38
-  }
39
-
40
-  const onRegisterChange = (e) => {
41
-    console.log(e, '111')
42
-  }
43
-
44
-
45
-
46
- 
47 9
   return <View className='index'>
48
-{/* 432 */}
49
-      <AdminUser></AdminUser>  
50
-     
10
+      <AdminUser></AdminUser>
51 11
   </View>
52 12
 }
53 13
 

+ 4
- 1
src/pages/mateTag/index.jsx 查看文件

@@ -7,6 +7,7 @@ import Tab from '../../compents/tab/index'
7 7
 import Layout from '../../layout/index'
8 8
 import request from '../../util/request'
9 9
 import getQueryValue from '../../util/getQueryValue'
10
+import NoData from '@/compents/NoData'
10 11
 
11 12
 const house = (props) => {
12 13
 
@@ -25,7 +26,7 @@ const house = (props) => {
25 26
   // })
26 27
   const getMateTagList = () => {
27 28
     console.log(id,'getMateTagList')
28
-    request({ url: '/api/mp/taMateTag',params:{groupId:id},method: 'get', }).then((res) => {
29
+    request({ url: '/taMateTag',params:{groupId:id},method: 'get', }).then((res) => {
29 30
       const { records, ...page} = res.data.data
30 31
       setList(records)
31 32
     })
@@ -73,6 +74,7 @@ const house = (props) => {
73 74
 
74 75
   return <View className='account'>
75 76
     <Layout>
77
+      <NoData nodata={!list.length} tips="暂无标签">
76 78
       {list.map((x, index) => {
77 79
         return <View className='account-view'>
78 80
   
@@ -90,6 +92,7 @@ const house = (props) => {
90 92
         </View>
91 93
 
92 94
       })}
95
+      </NoData>
93 96
     </Layout>
94 97
     {/* onClick={(e)=>(e) */}
95 98
     <Tab value={['+新增标签']} color='#ffffff' onClick={() => { Taro.navigateTo({ url: `/pages/mateTag/edit/index?id=${id}` }) }} ></Tab>

+ 4
- 1
src/pages/material/index.jsx 查看文件

@@ -9,6 +9,7 @@ import Container from '../../compents/container/index'
9 9
 import locationicon from '../../assets/locationicon.png'
10 10
 import Tags from '../../compents/tags/index'
11 11
 import request from '../../util/request'
12
+import NoData from '@/compents/NoData'
12 13
 import './index.scss'
13 14
 
14 15
 // Page({
@@ -90,14 +91,16 @@ const index = (props) => {
90 91
 
91 92
 
92 93
         <Layout>
94
+            <NoData nodata={!list.length}>
93 95
             {
94 96
                 list.map((item,index) => {
95
-                    return <View className='material-card'>
97
+                    return <View className='material-card' key={index}>
96 98
                         <Text>{item.name}</Text>
97 99
                         <Tags list={item.taMateTagList} onChange={(e) => onLabelChange(e, index)} > </Tags>
98 100
                     </View>
99 101
                 })
100 102
             }
103
+            </NoData>
101 104
 
102 105
             {/* <View className='inputstyle-view'>
103 106
                 <Text className='title'>入住人数</Text>

+ 3
- 2
src/pages/material/index.scss 查看文件

@@ -2,8 +2,9 @@
2 2
   padding-top: 30rpx;
3 3
   &-card {
4 4
     text-align: center;
5
-color: #7b7b7b;
6
-margin-top: 30px;
5
+    // color: #7b7b7b;
6
+    color: '#666';
7
+    margin-top: 30px;
7 8
 
8 9
   }
9 10
 

+ 29
- 47
src/pages/shop/index.jsx 查看文件

@@ -2,34 +2,11 @@ import React, { useEffect, useMemo, useState, useRef } from 'react'
2 2
 import Taro, { useDidShow } from '@tarojs/taro'
3 3
 import './index.scss'
4 4
 import { View, Text, Input, Image } from '@tarojs/components'
5
-import VirtualList from '@tarojs/components/virtual-list'
6 5
 import ContainerLayout from '../../compents/container/index'
7 6
 import Tab from '../../compents/tab/index'
8 7
 import Layout from '../../layout/index'
9 8
 import request from '../../util/request'
10
-
11
-
12
-// const Row = React.memo(({ id, index, style, data }) => {
13
-//   console.log({ id, index, style, data },'444')
14
-//   return (
15
-//     <View className='account-view' id={index}>
16
-//       {/* <Text className='account-view-title'>店铺编号:{index}</Text> */}
17
-//       <ContainerLayout className='account-view-card'>
18
-//         <View className='top' >
19
-//           <View>店铺名称:{data[index]?.name||''}</View>
20
-//           {/* <View>电话:{x.user.name}</View>
21
-//         <View>微信号:{x.user.name}</View>
22
-//         <View>房源数:{x.user.name}</View> */}
23
-//         </View>
24
-//         <View className='bottom'>
25
-//           <Text onClick={() => { Taro.navigateTo({ url: `/pages/account/edit/index?=${data.shopId}` }) }}>编辑</Text>
26
-//           <Text >删除</Text>
27
-//         </View>
28
-//       </ContainerLayout>
29
-
30
-//     </View>
31
-//   );
32
-// })
9
+import InifiniteList from '@/compents/InifiniteList'
33 10
 
34 11
 const account = (props) => {
35 12
 
@@ -88,9 +65,27 @@ const account = (props) => {
88 65
     })
89 66
   }
90 67
 
91
-  // const listReachBottom = () => {
92
-  //   getShopList({ pageNum: page.pageNum + 1 })
93
-  // }
68
+  const loadMore = () => {
69
+    getShopList({ pageNum: page.pageNum + 1 })
70
+  }
71
+
72
+  const renderItem = (index, key) => (
73
+    <View className='account-view' key={key}>
74
+      {/* <Text className='account-view-title'>店铺编号:{index}</Text> */}
75
+      <ContainerLayout className='account-view-card'>
76
+        <View className='top' >
77
+          <View>店铺名称:{list[index].name||''}</View>
78
+          {/* <View>电话:{x.user.name}</View>
79
+        <View>微信号:{x.user.name}</View>
80
+        <View>房源数:{x.user.name}</View> */}
81
+        </View>
82
+        <View className='bottom'>
83
+          <Text onClick={() => { Taro.navigateTo({ url: `/pages/account/index?id=${list[index].shopId}` }) }}>店主</Text>
84
+          <Text onClick={()=>onDelete(list[index].shopId)}>删除</Text>
85
+        </View>
86
+      </ContainerLayout>  
87
+    </View>
88
+  )
94 89
   
95 90
 
96 91
   return <View className='account'>
@@ -120,26 +115,13 @@ const account = (props) => {
120 115
         {Row}
121 116
       </VirtualList> */}
122 117
 
123
-      {
124
-        list.map((item)=>{
125
-        return  <View className='account-view' >
126
-          {/* <Text className='account-view-title'>店铺编号:{index}</Text> */}
127
-          <ContainerLayout className='account-view-card'>
128
-            <View className='top' >
129
-              <View>店铺名称:{item.name||''}</View>
130
-              {/* <View>电话:{x.user.name}</View>
131
-            <View>微信号:{x.user.name}</View>
132
-            <View>房源数:{x.user.name}</View> */}
133
-            </View>
134
-            <View className='bottom'>
135
-              <Text onClick={() => { Taro.navigateTo({ url: `/pages/account/index?id=${item.shopId}` }) }}>详情</Text>
136
-              <Text onClick={()=>onDelete(item.shopId)}>删除</Text>
137
-            </View>
138
-          </ContainerLayout>
139
-    
140
-        </View>
141
-        })
142
-      }
118
+      <InifiniteList
119
+        length={list.length}
120
+        total={page.total}
121
+        height={500}
122
+        itemRenderer={renderItem}
123
+        loadMore={loadMore}
124
+      />
143 125
 
144 126
     </Layout>
145 127
     {/* onClick={(e)=>(e) */}

+ 13993
- 0
yarn.lock
文件差異過大導致無法顯示
查看文件