张延森 4 yıl önce
ebeveyn
işleme
03a85b91d2

+ 3
- 0
config/index.js Dosyayı Görüntüle

@@ -63,7 +63,10 @@ const config = {
63 63
     }
64 64
   },  
65 65
   alias: {
66
+    '@/assets': path.resolve(__dirname, '..', 'src/assets'),
67
+    '@/components': path.resolve(__dirname, '..', 'src/components'),
66 68
     '@/store': path.resolve(__dirname, '..', 'src/store'),
69
+    '@/utils': path.resolve(__dirname, '..', 'src/utils')
67 70
   }
68 71
 }
69 72
 

+ 146
- 164
src/pages/ShouYe/index.jsx Dosyayı Görüntüle

@@ -1,55 +1,43 @@
1
-import React, { Component } from 'react'
2
-import NavHeader from '../../components/NavHeader/index'
1
+import React, { useState } from 'react'
2
+import NavHeader from '@/components/NavHeader/index'
3 3
 import { Swiper, SwiperItem, Text } from '@tarojs/components'
4 4
 import Taro from '@tarojs/taro'
5
-import '../../assets/css/reset.less'
6
-import '../../assets/css/iconfont.less'
5
+import '@/assets/css/reset.less'
6
+import '@/assets/css/iconfont.less'
7 7
 import './index.less'
8 8
 
9
-export default class Index extends Component {
10
-
11
-  state = {
12
-    ShowAdvLayer: false,
13
-    IsPull: false,
14
-    NewsList: [
15
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' },
16
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' },
17
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' },
18
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' }
19
-    ],
20
-    OwnerList: [
21
-      { icon: 'iconjiaofei', name: '物业缴费', id: 1 },
22
-      { icon: 'icontongzhi', name: '物业通知', id: 2 },
23
-      { icon: 'iconbaoxiu', name: '物业报修', id: 3 },
24
-      { icon: 'iconrenzheng', name: '业主认证', id: 4 }
25
-    ],
26
-    NavList: [
27
-      { icon: 'iconhuodong1', name: '活动', id: 1, router: '/pages/ShouYe/HuoDong/index', isTab: false },
28
-      { icon: 'iconfuli', name: '福利', id: 2, router: '/pages/FuLi/index', isTab: true },
29
-      { icon: 'iconfuwu', name: '服务', id: 3, router: '/pages/WuYe/index', isTab: true },
30
-      { icon: 'iconxinwen', name: '资讯', id: 4, router: '/pages/ShouYe/ZiXun/index', isTab: false }
31
-    ],
32
-    TestImg: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg',
33
-    BannerList: [
34
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg' },
35
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=16024dc7edcdbb6c325d40cdff6373a1&imgtype=0&src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201408%2F07%2F213601f2xz7usscm2z1mjh.jpg' },
36
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=3f54f5330ec21728ecb02352fbb6af90&imgtype=0&src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201205%2F15%2F152011zser9o5oa9ee9xx6.jpg' },
37
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989359&di=46ae1d0f0d4f1f3740139191398f2a81&imgtype=0&src=http%3A%2F%2Fpic.baike.soso.com%2Fp%2F20131230%2F20131230165604-1960511167.jpg' },
38
-      { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989359&di=2ec3fe46fb98c01055601cece86f111f&imgtype=0&src=http%3A%2F%2Fbenyouhuifile.it168.com%2Fforum%2Fday_100429%2F1004291840008539c8ac02cd5c.jpg' }
39
-    ]
40
-  }
41
-
42
-  componentWillMount () { }
43
-
44
-  componentDidMount () { }
45
-
46
-  componentWillUnmount () { }
47
-
48
-  componentDidShow () { }
49
-
50
-  componentDidHide () { }
51
-
52
-  NavClick (item) {
9
+export default function Index(props) {
10
+
11
+  const [ShowAdvLayer, setShowAdvLayer] = useState(false)
12
+  const [IsPull, setIsPull] = useState(false)
13
+  const [NewsList, setNewsList] = useState([
14
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' },
15
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' },
16
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' },
17
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg', title: '标题', desc: '描述' }
18
+  ])
19
+  const [OwnerList, setOwnerList] = useState([
20
+    { icon: 'iconjiaofei', name: '物业缴费', id: 1 },
21
+    { icon: 'icontongzhi', name: '物业通知', id: 2 },
22
+    { icon: 'iconbaoxiu', name: '物业报修', id: 3 },
23
+    { icon: 'iconrenzheng', name: '业主认证', id: 4 }
24
+  ])
25
+  const [NavList, setNavList] = useState([
26
+    { icon: 'iconhuodong1', name: '活动', id: 1, router: '/pages/ShouYe/HuoDong/index', isTab: false },
27
+    { icon: 'iconfuli', name: '福利', id: 2, router: '/pages/FuLi/index', isTab: true },
28
+    { icon: 'iconfuwu', name: '服务', id: 3, router: '/pages/WuYe/index', isTab: true },
29
+    { icon: 'iconxinwen', name: '资讯', id: 4, router: '/pages/ShouYe/ZiXun/index', isTab: false }
30
+  ])
31
+  const [BannerList, setBannerList] = useState([
32
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg' },
33
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=16024dc7edcdbb6c325d40cdff6373a1&imgtype=0&src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201408%2F07%2F213601f2xz7usscm2z1mjh.jpg' },
34
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=3f54f5330ec21728ecb02352fbb6af90&imgtype=0&src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201205%2F15%2F152011zser9o5oa9ee9xx6.jpg' },
35
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989359&di=46ae1d0f0d4f1f3740139191398f2a81&imgtype=0&src=http%3A%2F%2Fpic.baike.soso.com%2Fp%2F20131230%2F20131230165604-1960511167.jpg' },
36
+    { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989359&di=2ec3fe46fb98c01055601cece86f111f&imgtype=0&src=http%3A%2F%2Fbenyouhuifile.it168.com%2Fforum%2Fday_100429%2F1004291840008539c8ac02cd5c.jpg' }
37
+  ])
38
+  const [TestImg, setTestImg] = useState('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606120989360&di=8610f1678b51e26de6d4c6af39d1cf63&imgtype=0&src=http%3A%2F%2Fattachments.gfan.com%2Fforum%2F201503%2F19%2F211608ztcq7higicydxhsy.jpg')
39
+
40
+  const NavClick = (item) => {
53 41
     return () => {
54 42
       if (item.isTab) {
55 43
         Taro.switchTab({ url: item.router })
@@ -59,149 +47,143 @@ export default class Index extends Component {
59 47
     }
60 48
   }
61 49
 
62
-  OnRefresh () { // 页面下拉刷新
63
-    this.setState({
64
-      IsPull: true
65
-    }, () => {
66
-      window.setTimeout(() => {
67
-        this.setState({
68
-          IsPull: false
69
-        })
70
-      }, 1000)
71
-    })
50
+  const OnRefresh = () => { // 页面下拉刷新
51
+    setIsPull(true)
52
+    
53
+    const t = setTimeout(() => {
54
+      setIsPull(false)
55
+      clearTimeout(t)
56
+    }, 1000)
72 57
   }
73 58
 
74
-  render () {
75
-    const { TestImg, ShowAdvLayer, IsPull, BannerList, NavList, OwnerList, NewsList } = this.state
76
-    return (
77
-      <view className='ShouYe flex-v'>
78
-        <NavHeader BgColor='#f35844' Title='首页'></NavHeader>
79
-        <view className='flex-item'>
80
-
81
-          {/* 广告 */}
82
-          <view className='AdvLayer' style={{ display: ShowAdvLayer ? 'block' : 'none' }}>
83
-            <view className='centerLabel'>
84
-              <image mode='aspectFit' src={TestImg}></image>
85
-              <Text className='iconfont iconguanbi'></Text>
86
-            </view>
59
+  return (
60
+    <view className='ShouYe flex-v'>
61
+      <NavHeader BgColor='#f35844' Title='首页'></NavHeader>
62
+      <view className='flex-item'>
63
+
64
+        {/* 广告 */}
65
+        <view className='AdvLayer' style={{ display: ShowAdvLayer ? 'block' : 'none' }}>
66
+          <view className='centerLabel'>
67
+            <image mode='aspectFit' src={TestImg}></image>
68
+            <Text className='iconfont iconguanbi'></Text>
87 69
           </view>
70
+        </view>
88 71
 
89
-          {/* 正文 */}
90
-          <view className='PageContainer'>
91
-            <scroll-view scroll-y='true' style='height: 100%;' refresher-enabled={true} onrefresherrefresh={this.OnRefresh.bind(this)} refresher-triggered={IsPull} refresher-background='#f35844'>
92
-              <view className='Content'>
72
+        {/* 正文 */}
73
+        <view className='PageContainer'>
74
+          <scroll-view scroll-y='true' style='height: 100%;' refresher-enabled={true} onrefresherrefresh={OnRefresh} refresher-triggered={IsPull} refresher-background='#f35844'>
75
+            <view className='Content'>
93 76
 
94
-                {/* 背景图 */}
95
-                <view className='TopBg'></view>
77
+              {/* 背景图 */}
78
+              <view className='TopBg'></view>
96 79
 
97
-                <view>
80
+              <view>
98 81
 
99
-                  {/* 欢迎词 */}
100
-                  <Text className='Welcome'>欢迎来到远道智慧社区!</Text>
82
+                {/* 欢迎词 */}
83
+                <Text className='Welcome'>欢迎来到远道智慧社区!</Text>
101 84
 
102
-                  {/* banner */}
103
-                  <view className='BannerContainer'>
85
+                {/* banner */}
86
+                <view className='BannerContainer'>
87
+                  <view>
104 88
                     <view>
105
-                      <view>
106
-                        <Swiper className='BannerSwiper' autoplay circular indicator-dots indicator-color='rgba(0,0,0,0.4)' indicator-active-color='rgba(255,255,255,0.8)'>
107
-                          {
108
-                            BannerList.map((item, index) => (
109
-                              <SwiperItem className='SwiperItem' key={`Banner-${index}`}>
110
-                                <view className='BannerItem'>
111
-                                  <image mode='aspectFill' src={item.img}></image>
112
-                                </view>
113
-                              </SwiperItem>
114
-                            ))
115
-                          }
116
-                        </Swiper>
117
-                      </view>
89
+                      <Swiper className='BannerSwiper' autoplay circular indicator-dots indicator-color='rgba(0,0,0,0.4)' indicator-active-color='rgba(255,255,255,0.8)'>
90
+                        {
91
+                          BannerList.map((item, index) => (
92
+                            <SwiperItem className='SwiperItem' key={`Banner-${index}`}>
93
+                              <view className='BannerItem'>
94
+                                <image mode='aspectFill' src={item.img}></image>
95
+                              </view>
96
+                            </SwiperItem>
97
+                          ))
98
+                        }
99
+                      </Swiper>
118 100
                     </view>
119 101
                   </view>
102
+                </view>
120 103
 
121
-                  {/* 导航 */}
122
-                  <view className='NavContainer flex-h'>
123
-                    {
124
-                      NavList.map((item, index) => (
125
-                        <view key={`Nav-${index}`} className='flex-item'>
126
-                          <view onClick={this.NavClick(item)}>
127
-                            <view className='centerLabel'>
128
-                              <Text className={`iconfont ${item.icon}`}></Text>
129
-                              <Text>{item.name}</Text>
130
-                            </view>
104
+                {/* 导航 */}
105
+                <view className='NavContainer flex-h'>
106
+                  {
107
+                    NavList.map((item, index) => (
108
+                      <view key={`Nav-${index}`} className='flex-item'>
109
+                        <view onClick={NavClick(item)}>
110
+                          <view className='centerLabel'>
111
+                            <Text className={`iconfont ${item.icon}`}></Text>
112
+                            <Text>{item.name}</Text>
131 113
                           </view>
132 114
                         </view>
133
-                      ))
134
-                    }
135
-                  </view>
136
-
137
-                  {/* 热门活动 */}
138
-                  <view className='HotActivityContainer'>
139
-                    <view>
140
-                      <view className='Title'>
141
-                        <Text onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/HuoDong/index' }) }}>热门活动</Text>
142
-                        <Text className='iconfont icongengduo' onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/HuoDong/index' }) }}></Text>
143
-                      </view>
144
-                      <view className='Activity'>
145
-                        <image className='centerLabel' mode='aspectFill' src={TestImg}></image>
146 115
                       </view>
116
+                    ))
117
+                  }
118
+                </view>
119
+
120
+                {/* 热门活动 */}
121
+                <view className='HotActivityContainer'>
122
+                  <view>
123
+                    <view className='Title'>
124
+                      <Text onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/HuoDong/index' }) }}>热门活动</Text>
125
+                      <Text className='iconfont icongengduo' onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/HuoDong/index' }) }}></Text>
126
+                    </view>
127
+                    <view className='Activity'>
128
+                      <image className='centerLabel' mode='aspectFill' src={TestImg}></image>
147 129
                     </view>
148 130
                   </view>
131
+                </view>
149 132
 
150
-                  {/* 业主专区 */}
151
-                  <view className='OwnerContainer'>
152
-                    <view>
153
-                      <view className='Title'>
154
-                        <Text>业主专区</Text>
155
-                      </view>
156
-                      <view className='OwnerList flex-h'>
157
-                        {
158
-                          OwnerList.map((item, index) => (
159
-                            <view className='flex-item' key={`Owners-${index}`}>
160
-                              <Text className={`iconfont ${item.icon}`}></Text>
161
-                              <Text>{item.name}</Text>
162
-                            </view>
163
-                          ))
164
-                        }
165
-                      </view>
133
+                {/* 业主专区 */}
134
+                <view className='OwnerContainer'>
135
+                  <view>
136
+                    <view className='Title'>
137
+                      <Text>业主专区</Text>
138
+                    </view>
139
+                    <view className='OwnerList flex-h'>
140
+                      {
141
+                        OwnerList.map((item, index) => (
142
+                          <view className='flex-item' key={`Owners-${index}`}>
143
+                            <Text className={`iconfont ${item.icon}`}></Text>
144
+                            <Text>{item.name}</Text>
145
+                          </view>
146
+                        ))
147
+                      }
166 148
                     </view>
167 149
                   </view>
150
+                </view>
168 151
 
169
-                  {/* 热门资讯 */}
170
-                  <view className='NewsContainer'>
171
-                    <view>
172
-                      <view className='Title flex-h'>
173
-                        <Text className='flex-item'>热门资讯</Text>
174
-                        <Text onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/ZiXun/index' }) }}>查看全部</Text>
175
-                        <Text className='iconfont iconjiantouright'></Text>
176
-                      </view>
177
-                      <view className='List'>
178
-                        {
179
-                          NewsList.map((item, index) => (
180
-                            <view key={`News-${index}`} className='flex-h'>
181
-                              <view className='Img'>
182
-                                <image mode='aspectFill' src={item.img} className='centerLabel'></image>
183
-                              </view>
184
-                              <view className='flex-item'>
185
-                                <Text>{item.title}</Text>
186
-                                <Text>{item.desc}</Text>
187
-                              </view>
152
+                {/* 热门资讯 */}
153
+                <view className='NewsContainer'>
154
+                  <view>
155
+                    <view className='Title flex-h'>
156
+                      <Text className='flex-item'>热门资讯</Text>
157
+                      <Text onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/ZiXun/index' }) }}>查看全部</Text>
158
+                      <Text className='iconfont iconjiantouright'></Text>
159
+                    </view>
160
+                    <view className='List'>
161
+                      {
162
+                        NewsList.map((item, index) => (
163
+                          <view key={`News-${index}`} className='flex-h'>
164
+                            <view className='Img'>
165
+                              <image mode='aspectFill' src={item.img} className='centerLabel'></image>
188 166
                             </view>
189
-                          ))
190
-                        }
191
-                      </view>
167
+                            <view className='flex-item'>
168
+                              <Text>{item.title}</Text>
169
+                              <Text>{item.desc}</Text>
170
+                            </view>
171
+                          </view>
172
+                        ))
173
+                      }
192 174
                     </view>
193 175
                   </view>
194
-
195
-                  <view className='PageBottom'></view>
196
-
197 176
                 </view>
198 177
 
178
+                <view className='PageBottom'></view>
179
+
199 180
               </view>
200
-            </scroll-view>
201
-          </view>
202 181
 
182
+            </view>
183
+          </scroll-view>
203 184
         </view>
204
-      </view >
205
-    )
206
-  }
185
+
186
+      </view>
187
+    </view >
188
+  )
207 189
 }

+ 0
- 3
src/pages/bar/index.config.js Dosyayı Görüntüle

@@ -1,3 +0,0 @@
1
-export default {
2
-  navigationBarTitleText: '首页'
3
-}

+ 0
- 26
src/pages/bar/index.jsx Dosyayı Görüntüle

@@ -1,26 +0,0 @@
1
-import React, { Component, useEffect } from 'react'
2
-import { View, Text, Navigator } from '@tarojs/components'
3
-import './index.less'
4
-
5
-import { useModel } from '@/store'
6
-
7
-export default (props) => {
8
-  const { foo, setFoo } = useModel('foo')
9
-  
10
-  console.log('-----bar-------')
11
-
12
-  useEffect(() => {
13
-    let i = 1;
14
-    console.log('-----bar-------')
15
-
16
-    const t = setInterval(() => setFoo(i++), 1000)
17
-    return () => clearInterval(t)
18
-  }, [])
19
-
20
-  return (
21
-    <View className='foo'>
22
-      <Text>{foo}</Text>
23
-      <Navigator url="/pages/foo/index">foo</Navigator>
24
-    </View>
25
-  )
26
-}

+ 0
- 0
src/pages/bar/index.less Dosyayı Görüntüle


+ 0
- 3
src/pages/foo/index.config.js Dosyayı Görüntüle

@@ -1,3 +0,0 @@
1
-export default {
2
-  navigationBarTitleText: '首页'
3
-}

+ 0
- 27
src/pages/foo/index.jsx Dosyayı Görüntüle

@@ -1,27 +0,0 @@
1
-import React, { Component, useEffect } from 'react'
2
-import { View, Text, Navigator } from '@tarojs/components'
3
-import './index.less'
4
-
5
-import { useModel } from '@/store'
6
-
7
-export default (props) => {
8
-  // const { foo, setFoo } = useModel('foo')
9
-  const { foo } = useModel('foo')
10
-  
11
-  console.log('-----foo-------')
12
-
13
-  // useEffect(() => {
14
-  //   let i = 1;
15
-  //   console.log('-----setfoo-------')
16
-
17
-  //   const t = setInterval(() => setFoo(i++), 1000)
18
-  //   return () => console.log('descard foo') || clearInterval(t) 
19
-  // }, [])
20
-
21
-  return (
22
-    <View className='foo'>
23
-      <Text>{foo}</Text>
24
-      <Navigator url="/pages/bar/index">bar</Navigator>
25
-    </View>
26
-  )
27
-}

+ 0
- 0
src/pages/foo/index.less Dosyayı Görüntüle