xcx 4 anni fa
parent
commit
b07ba13811

+ 4
- 6
src/components/ActivityListItem/index.jsx Vedi File

@@ -8,17 +8,15 @@ export default function ActivityListItem (props) {
8 8
 
9 9
   const { Data } = props
10 10
 
11
-  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')
12
-
13 11
   return (
14
-    <view className='ActivityListItem' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=` }) }}>
12
+    <view className='ActivityListItem' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=${Data.dynamicId}` }) }}>
15 13
       <view className='Img'>
16
-        <image mode='aspectFill' src={TestImg} className='centerLabel'></image>
14
+        <image mode='aspectFill' src={Data.imgUrl} className='centerLabel'></image>
17 15
       </view>
18 16
       <view className='Info flex-h'>
19 17
         <view className='flex-item'>
20
-          <text>核销拼团</text>
21
-          <text>参与截止时间:2019年10月20日 10:00:00</text>
18
+          <text>{Data.title}</text>
19
+          <text>参与截止时间:{Data.enlistEnd}</text>
22 20
         </view>
23 21
         <text className='active'>未开始</text>
24 22
       </view>

+ 5
- 6
src/components/NewsListItem/index.jsx Vedi File

@@ -6,21 +6,20 @@ import './index.less'
6 6
 
7 7
 export default function NewsListItem (props) {
8 8
 
9
-  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')
10
-  const { ShowTips } = props
9
+  const { ShowTips, Data } = props
11 10
 
12 11
   return (
13
-    <view className='NewsListItem flex-h' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/ZiXunDetail/index?id=` }) }}>
12
+    <view className='NewsListItem flex-h' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/ZiXunDetail/index?id=${Data.newsId}` }) }}>
14 13
       <view className='Img'>
15
-        <image mode='aspectFill' src={TestImg}></image>
14
+        <image mode='aspectFill' src={Data.newsImg}></image>
16 15
         {
17 16
           ShowTips &&
18 17
           <text>置顶</text>
19 18
         }
20 19
       </view>
21 20
       <view className='Info flex-item'>
22
-        <text>破晓·内容生态下半场的版权之道—2019企业版权</text>
23
-        <text>于2019-12-12 14:20:30发布</text>
21
+        <text>{Data.newsName}</text>
22
+        <text>于{Data.createDate}发布</text>
24 23
       </view>
25 24
     </view >
26 25
   )

+ 0
- 29
src/components/ScrollPage/index.css Vedi File

@@ -1,29 +0,0 @@
1
-.ScrollPage {
2
-  width: 100%;
3
-  height: 100%;
4
-  position: relative;
5
-  overflow: hidden;
6
-}
7
-.ScrollPage .ScrollPageContent {
8
-  width: 100%;
9
-  position: relative;
10
-  overflow: hidden;
11
-  min-height: 100%;
12
-  z-index: 2;
13
-}
14
-.ScrollPage .ScrollPageContent > .ScrollPageBottom {
15
-  width: 100%;
16
-  height: 80px;
17
-}
18
-.ScrollPage .LoadMoreText {
19
-  width: 100%;
20
-  display: block;
21
-  position: relative;
22
-  overflow: hidden;
23
-  text-align: center;
24
-  z-index: 1;
25
-  font-size: 28px;
26
-  color: #999;
27
-  line-height: 80px;
28
-  margin-top: -80px;
29
-}

+ 0
- 1
src/layouts/index.jsx Vedi File

@@ -4,7 +4,6 @@ import Spin from '@/components/Spin'
4 4
 
5 5
 export default function(props) {
6 6
   const { user } = useModel('user')
7
-  console.log(user, `layout`)
8 7
 
9 8
   const loading = !user || !user.personId
10 9
 

+ 107
- 0
src/pages/HuoDong/HuoDongDetail/index.css Vedi File

@@ -0,0 +1,107 @@
1
+.HuoDongDetail {
2
+  width: 100%;
3
+  min-height: 100vh;
4
+  position: relative;
5
+}
6
+.HuoDongDetail > .BannerLayer {
7
+  width: 100%;
8
+  padding-bottom: 75.2%;
9
+  position: relative;
10
+  z-index: 2;
11
+}
12
+.HuoDongDetail > .Banner {
13
+  width: 100%;
14
+  padding-bottom: 75.2%;
15
+  background: #ccc;
16
+  position: fixed;
17
+  z-index: 1;
18
+  left: 0;
19
+  top: 0;
20
+  overflow: hidden;
21
+}
22
+.HuoDongDetail > .Banner > image {
23
+  width: 100%;
24
+  height: 100%;
25
+}
26
+.HuoDongDetail > .Info {
27
+  padding: 30px;
28
+  position: relative;
29
+  overflow: hidden;
30
+  z-index: 3;
31
+  border-radius: 40px 40px 0 0;
32
+  margin-top: -30px;
33
+  background: #fff;
34
+}
35
+.HuoDongDetail > .Info > .MainInfo {
36
+  position: relative;
37
+  overflow: visible;
38
+  padding-bottom: 40px;
39
+  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
40
+}
41
+.HuoDongDetail > .Info > .MainInfo > .Name {
42
+  font-size: 30px;
43
+  font-weight: bold;
44
+  color: #333;
45
+  line-height: 40px;
46
+  width: 100%;
47
+  display: block;
48
+  margin-top: 10px;
49
+  position: relative;
50
+  z-index: 1;
51
+}
52
+.HuoDongDetail > .Info > .MainInfo > .Tips {
53
+  display: inline-block;
54
+  font-size: 28px;
55
+  color: #F35844;
56
+  position: absolute;
57
+  z-index: 2;
58
+  right: -30px;
59
+  top: -40px;
60
+  background: rgba(243, 88, 68, 0.2);
61
+  padding: 0 20px;
62
+  line-height: 58px;
63
+  border-radius: 0 0 0 40px;
64
+}
65
+.HuoDongDetail > .Info > .MainInfo > .flex-h {
66
+  align-items: center;
67
+  margin-top: 20px;
68
+}
69
+.HuoDongDetail > .Info > .MainInfo > .flex-h > text {
70
+  font-size: 28px;
71
+  color: #333;
72
+  line-height: 40px;
73
+  margin-right: 10px;
74
+}
75
+.HuoDongDetail > .Info > .MainInfo > .flex-h > view {
76
+  font-size: 28px;
77
+  color: #333;
78
+  line-height: 40px;
79
+}
80
+.HuoDongDetail > .Info > .MainInfo > .flex-h > view > text {
81
+  font-size: 28px;
82
+  color: #F35844;
83
+  line-height: 40px;
84
+}
85
+.HuoDongDetail > .Info > .Desc {
86
+  position: relative;
87
+  overflow: hidden;
88
+  margin-top: 140px;
89
+}
90
+.HuoDongDetail > .Info > .Desc > text {
91
+  font-size: 34px;
92
+  width: 100%;
93
+  display: block;
94
+  text-align: center;
95
+  color: #333;
96
+  line-height: 40px;
97
+}
98
+.HuoDongDetail > .Info > .BottomBtn {
99
+  width: 100%;
100
+  display: block;
101
+  text-align: center;
102
+  color: #fff;
103
+  line-height: 98px;
104
+  border-radius: 98px;
105
+  background: #F35844;
106
+  margin-top: 60px;
107
+}

+ 45
- 27
src/pages/HuoDong/HuoDongDetail/index.jsx Vedi File

@@ -1,46 +1,64 @@
1
-import React, { useState } from 'react'
1
+import React, { useState, useEffect } from 'react'
2 2
 import Taro, { Current } from '@tarojs/taro'
3 3
 import { RichText } from '@tarojs/components'
4
+import request, { apis } from '@/utils/request'
4 5
 import '@/assets/css/reset.less'
5 6
 import '@/assets/css/iconfont.less'
6 7
 import './index.less'
7 8
 
8 9
 export default function HuoDongDetail (props) {
9 10
 
10
-  const CurrnetHuoDongId = Current.router.params.id
11
+  const [CurrnetHuoDongId] = useState(Current.router.params.id) // 当前活动id
12
+  const [ActivityDetail, setActivityDetail] = useState(null) // 活动详情
13
+
14
+  useEffect(() => {
15
+    GetActivityDetail()
16
+  }, [CurrnetHuoDongId])
17
+
18
+  const GetActivityDetail = () => { // 获取活动详情
19
+    request({ ...apis.getActivityDetail, args: { id: CurrnetHuoDongId } }).then((res) => {
20
+      setActivityDetail(res)
21
+    })
22
+  }
11 23
 
12 24
   return (
13 25
     <view className='HuoDongDetail'>
14 26
       <view className='BannerLayer'></view>
15
-      <view className='Banner'>
16
-        <image mode='aspectFill' src={null} className='centerLabel'></image>
17
-      </view>
18
-      <view className='Info'>
19
-        <view className='MainInfo'>
20
-          <text className='Name'>业主拔河比赛正式开始了~</text>
21
-          <text className='Tips'>17人已报名</text>
22
-          <view className='flex-h'>
23
-            <text>活动时间:</text>
24
-            <view className='flex-item'>2019-08 08 12:00:00 <text>限100人</text></view>
25
-          </view>
26
-          <view className='flex-h'>
27
-            <text>活动地址:</text>
28
-            <view className='flex-item'>江苏省南京市秦淮区</view>
29
-          </view>
30
-          <view className='flex-h'>
31
-            <text>报名截止:</text>
32
-            <view className='flex-item'>2020-09-09 08:00:00</view>
33
-          </view>
27
+      {
28
+        ActivityDetail !== null &&
29
+        <view className='Banner'>
30
+          <image mode='aspectFill' src={ActivityDetail.bannerListImg} className='centerLabel'></image>
34 31
         </view>
32
+      }
33
+      {
34
+        ActivityDetail !== null &&
35
+        <view className='Info'>
36
+          <view className='MainInfo'>
37
+            <text className='Name'>{ActivityDetail.title}</text>
38
+            <text className='Tips'>{ActivityDetail.enlistNum}人已报名</text>
39
+            <view className='flex-h'>
40
+              <text>活动时间:</text>
41
+              <view className='flex-item'>{ActivityDetail.startDate}<text>限{ActivityDetail.enlistNum}人</text></view>
42
+            </view>
43
+            <view className='flex-h'>
44
+              <text>活动地址:</text>
45
+              <view className='flex-item'>{ActivityDetail.address}</view>
46
+            </view>
47
+            <view className='flex-h'>
48
+              <text>报名截止:</text>
49
+              <view className='flex-item'>{ActivityDetail.enlistEnd}</view>
50
+            </view>
51
+          </view>
35 52
 
36
-        <view className='Desc'>
37
-          <text>活动介绍</text>
38
-          <RichText nodes={null}></RichText>
39
-        </view>
53
+          <view className='Desc'>
54
+            <text>活动介绍</text>
55
+            <RichText nodes={null}></RichText>
56
+          </view>
40 57
 
41
-        <text className='BottomBtn'>立即参加</text>
58
+          <text className='BottomBtn'>立即参加</text>
42 59
 
43
-      </view>
60
+        </view>
61
+      }
44 62
     </view>
45 63
   )
46 64
 }

+ 0
- 1
src/pages/HuoDong/HuoDongDetail/index.less Vedi File

@@ -6,7 +6,6 @@
6 6
   >.BannerLayer {
7 7
     width: 100%;
8 8
     padding-bottom: 75.2%;
9
-    background: #ccc;
10 9
     position: relative;
11 10
     z-index: 2;
12 11
   }

+ 40
- 0
src/pages/HuoDong/ZiXunDetail/index.css Vedi File

@@ -0,0 +1,40 @@
1
+.ZiXunDetail {
2
+  width: 100%;
3
+  min-height: 100vh;
4
+  position: relative;
5
+}
6
+.ZiXunDetail > view {
7
+  position: relative;
8
+  overflow: hidden;
9
+  padding: 0 30px;
10
+}
11
+.ZiXunDetail > view > .Title {
12
+  position: relative;
13
+  overflow: hidden;
14
+}
15
+.ZiXunDetail > view > .Title > text {
16
+  width: 100%;
17
+  display: block;
18
+  font-size: 34px;
19
+  color: #333;
20
+  line-height: 40px;
21
+  text-align: center;
22
+  margin-top: 40px;
23
+}
24
+.ZiXunDetail > view > .flex-h {
25
+  align-items: center;
26
+  margin-top: 20px;
27
+}
28
+.ZiXunDetail > view > .flex-h > text {
29
+  font-size: 24px;
30
+  color: #999;
31
+  line-height: 48px;
32
+  margin-left: 10px;
33
+}
34
+.ZiXunDetail > view > .flex-h > text:first-child {
35
+  margin-left: 0;
36
+}
37
+.ZiXunDetail > view > .flex-h > text.iconfont {
38
+  color: #F35844;
39
+  font-size: 40px;
40
+}

+ 34
- 3
src/pages/HuoDong/ZiXunDetail/index.jsx Vedi File

@@ -1,16 +1,47 @@
1
-import React, { useState } from 'react'
1
+import React, { useState, useEffect } from 'react'
2 2
 import Taro, { Current } from '@tarojs/taro'
3
+import request, { apis } from '@/utils/request'
4
+import { RichText } from '@tarojs/components'
3 5
 import '@/assets/css/reset.less'
4 6
 import '@/assets/css/iconfont.less'
5 7
 import './index.less'
6 8
 
7 9
 export default function ZiXunDetail (props) {
8 10
 
9
-  const CurrnetZiXunId = Current.router.params.id
11
+  const [CurrnetZiXunId] = useState(Current.router.params.id) // 当前查询资讯id
12
+  const [NewsDetail, setNewsDetail] = useState(null) // 资讯详情
13
+
14
+  useEffect(() => {
15
+    GetNewsDetail()
16
+  }, [CurrnetZiXunId])
17
+
18
+  const GetNewsDetail = () => { // 获取资讯详情
19
+    request({ ...apis.getNewsDetail, args: { id: CurrnetZiXunId } }).then((res) => {
20
+      setNewsDetail(res)
21
+      AddNewsViews()
22
+    })
23
+  }
24
+
25
+  const AddNewsViews = () => { // 资讯阅读量+1
26
+    request({ ...apis.addNewsViews, args: { id: CurrnetZiXunId } })
27
+  }
10 28
 
11 29
   return (
12 30
     <view className='ZiXunDetail'>
13
-      
31
+      {
32
+        NewsDetail !== null &&
33
+        <view>
34
+          <view className='Title'>
35
+            <text>{NewsDetail.newsName}</text>
36
+          </view>
37
+          <view className='flex-h'>
38
+            <text className='flex-item'>{NewsDetail.createDate}</text>
39
+            <text className='iconfont iconguankan'></text>
40
+            <text>{NewsDetail.pvNum || 0}</text>
41
+          </view>
42
+          <RichText nodes={NewsDetail.newsDetail}></RichText>
43
+        </view>
44
+      }
14 45
     </view>
15 46
   )
16 47
 }

+ 41
- 0
src/pages/HuoDong/ZiXunDetail/index.less Vedi File

@@ -2,4 +2,45 @@
2 2
   width: 100%;
3 3
   min-height: 100vh;
4 4
   position: relative;
5
+
6
+  >view {
7
+    position: relative;
8
+    overflow: hidden;
9
+    padding: 0 30px;
10
+    >.Title {
11
+      position: relative;
12
+      overflow: hidden;
13
+  
14
+      >text {
15
+        width: 100%;
16
+        display: block;
17
+        font-size: 34px;
18
+        color: #333;
19
+        line-height: 40px;
20
+        text-align: center;
21
+        margin-top: 40px;
22
+      }
23
+    }
24
+  
25
+    >.flex-h {
26
+      align-items: center;
27
+      margin-top: 20px;
28
+  
29
+      >text {
30
+        font-size: 24px;
31
+        color: #999;
32
+        line-height: 48px;
33
+        margin-left: 10px;
34
+  
35
+        &:first-child {
36
+          margin-left: 0;
37
+        }
38
+  
39
+        &.iconfont {
40
+          color: #F35844;
41
+          font-size: 40px;
42
+        }
43
+      }
44
+    }
45
+  }
5 46
 }

+ 90
- 17
src/pages/HuoDong/index.jsx Vedi File

@@ -1,32 +1,107 @@
1
-import React, { useState } from 'react'
1
+import React, { useState, useEffect } from 'react'
2 2
 import TabPageCutNav from '@/components/TabPageCutNav/index'
3 3
 import NavHeader from '@/components/NavHeader/index'
4 4
 import ActivityListItem from '@/components/ActivityListItem/index'
5 5
 import NewsListItem from '@/components/NewsListItem/index'
6
+import ScrollPage from '@/components/ScrollPage/index'
7
+import request, { apis } from '@/utils/request'
6 8
 import '@/assets/css/reset.less'
7 9
 import '@/assets/css/iconfont.less'
8 10
 import './index.less'
9 11
 
10 12
 export default function HuoDong (props) {
11 13
 
14
+  const [NavList] = useState([{ name: '活动', id: 1 }, { name: '资讯', id: 2 }])
12 15
   const [CurrentNavId, setCurrentNavId] = useState(1)
13
-  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')
14
-  const [NavList, setNavList] = useState([{ name: '活动', id: 1 }, { name: '资讯', id: 2 }])
15
-  const [IsPull, setIsPull] = useState(false)
16
-  const [ActivityList, setActivityList] = useState(['', '', '', '', '', '', '', ''])
17
-  const [NewsList, setNewsList] = useState(['', '', '', '', '', '', '', ''])
16
+  const [IsPullDown, setIsPullDown] = useState(false)
17
+  const [IsPullUp, setIsPullUp] = useState(false)
18
+  const [HasNextPage, setHasNextPage] = useState(true)
19
+  const [PageNum, setPageNum] = useState(1)
20
+  const [ActivityList, setActivityList] = useState([])
21
+  const [ActivityTotal, setActivityTotal] = useState(1)
22
+  const [NewsList, setNewsList] = useState([])
18 23
 
19
-  const NavChange = (e) => {
24
+  useEffect(() => {
25
+    if (CurrentNavId === 1) { // 活动
26
+      GetActivityList(() => {
27
+        setIsPullUp(false)
28
+      })
29
+    } else if (CurrentNavId === 2) { // 资讯
30
+      GetNewsList(() => {
31
+        setIsPullUp(false)
32
+      })
33
+    }
34
+  }, [PageNum])
35
+
36
+  useEffect(() => {
37
+    setHasNextPage(ActivityTotal > ActivityList.length)
38
+  }, [ActivityList])
39
+
40
+  useEffect(() => {
41
+    OnRefresh()
42
+  }, [CurrentNavId])
43
+
44
+  const GetActivityList = (done = () => { }) => { // 获取活动列表
45
+    request({ ...apis.getActivityList, params: { pageNum: PageNum, pageSize: 6 } }).then((res) => {
46
+      setActivityTotal(res.total)
47
+      if (PageNum === 1) {
48
+        setActivityList([...res.list])
49
+      } else {
50
+        setActivityList(NewsList.concat([...res.list]))
51
+      }
52
+      done()
53
+    }).catch(() => {
54
+      done()
55
+    })
56
+  }
57
+
58
+  const GetNewsList = (done = () => { }) => { // 获取资讯列表
59
+    request({ ...apis.getNewsList, params: { pageNum: PageNum, pageSize: 6 } }).then((res) => {
60
+      if (PageNum === 1) {
61
+        setNewsList([...res.records])
62
+      } else {
63
+        setNewsList(NewsList.concat([...res.records]))
64
+      }
65
+      setHasNextPage(res.current - 0 < res.pages - 0)
66
+      done()
67
+    }).catch(() => {
68
+      done()
69
+    })
70
+  }
71
+
72
+  const NavChange = (e) => { // nav切换
20 73
     return () => {
21 74
       setCurrentNavId(e.id)
75
+      setHasNextPage(true)
76
+      setIsPullDown(false)
77
+      setIsPullUp(false)
78
+      setPageNum(1)
22 79
     }
23 80
   }
24 81
 
25
-  const OnRefresh = () => {
26
-    setIsPull(true)
27
-    window.setTimeout(() => {
28
-      setIsPull(false)
29
-    }, 1000)
82
+  const OnRefresh = () => { // 下拉刷新
83
+    setIsPullDown(true)
84
+    setHasNextPage(true)
85
+    if (PageNum === 1) {
86
+      if (CurrentNavId === 1) {
87
+        GetActivityList(() => {
88
+          setIsPullDown(false)
89
+        })
90
+      } else if (CurrentNavId === 2) {
91
+        GetNewsList(() => {
92
+          setIsPullDown(false)
93
+        })
94
+      }
95
+    } else {
96
+      setPageNum(1)
97
+    }
98
+  }
99
+
100
+  const OnPullUp = () => { // 上拉加载
101
+    if (HasNextPage) {
102
+      setIsPullUp(true)
103
+      setPageNum(PageNum + 1)
104
+    }
30 105
   }
31 106
 
32 107
   return (
@@ -35,8 +110,7 @@ export default function HuoDong (props) {
35 110
       <TabPageCutNav List={NavList} CurrentNavId={CurrentNavId} NavChange={NavChange}></TabPageCutNav>
36 111
       <view className='flex-item'>
37 112
         <view>
38
-          <scroll-view scroll-y='true' style='height: 100%;' refresher-enabled={true} onrefresherrefresh={OnRefresh} refresher-triggered={IsPull} refresher-background='none'>
39
-
113
+          <ScrollPage OnRefresh={OnRefresh} IsPullDown={IsPullDown} OnPullUp={OnPullUp} IsPullUp={IsPullUp} HasMore={HasNextPage}>
40 114
             {/* 活动 */}
41 115
             {
42 116
               CurrentNavId - 0 === 1 &&
@@ -56,7 +130,7 @@ export default function HuoDong (props) {
56 130
               CurrentNavId - 0 === 2 &&
57 131
               <view className='Content News'>
58 132
                 <view className='BigImg'>
59
-                  <image mode='aspectFill' src={TestImg} class='centerLabel'></image>
133
+                  <image mode='aspectFill' src={null} class='centerLabel'></image>
60 134
                 </view>
61 135
                 <view className='List'>
62 136
                   {
@@ -69,8 +143,7 @@ export default function HuoDong (props) {
69 143
                 </view>
70 144
               </view>
71 145
             }
72
-
73
-          </scroll-view>
146
+          </ScrollPage>
74 147
         </view>
75 148
       </view>
76 149
     </view>

+ 0
- 20
src/pages/ShouYe/ZiXun/index.css Vedi File

@@ -1,20 +0,0 @@
1
-.ShouYeZiXun {
2
-  width: 100%;
3
-  height: 100%;
4
-  overflow: hidden;
5
-  background: #f8f8f8;
6
-}
7
-.ShouYeZiXun .ShouYeHuoDongContent {
8
-  position: relative;
9
-  overflow: hidden;
10
-  padding: 0 30px;
11
-}
12
-.ShouYeZiXun .ShouYeHuoDongContent > .ListItem {
13
-  width: 100%;
14
-  position: relative;
15
-  overflow: hidden;
16
-  margin-bottom: 30px;
17
-}
18
-.ShouYeZiXun .ShouYeHuoDongContent > .ListItem:first-child {
19
-  margin-top: 30px;
20
-}

+ 62
- 44
src/pages/ShouYe/ZiXun/index.jsx Vedi File

@@ -1,54 +1,72 @@
1
-import React, { Component } from 'react'
2
-import NewsListItem from '../../../components/NewsListItem/index'
3
-import '../../../assets/css/reset.less'
4
-import '../../../assets/css/iconfont.less'
1
+import React, { useState, useEffect } from 'react'
2
+import request, { apis } from '@/utils/request'
3
+import NewsListItem from '@/components/NewsListItem/index'
4
+import ScrollPage from '@/components/ScrollPage/index'
5
+import '@/assets/css/reset.less'
6
+import '@/assets/css/iconfont.less'
5 7
 import './index.less'
6 8
 
7
-export default class ShouYeZiXun extends Component {
9
+export default function ShouYeZiXun (props) {
8 10
 
9
-  state = {
10
-    ActivityList: ['', '', '', '', '', '', '', ''],
11
-    IsPull: false
12
-  }
13
-
14
-  componentWillMount () { }
15
-
16
-  componentDidMount () { }
17
-
18
-  componentWillUnmount () { }
19
-
20
-  componentDidShow () { }
11
+  const [IsPullUp, setIsPullUp] = useState(false)
12
+  const [IsPullDown, setIsPullDown] = useState(false)
13
+  const [HasNextPage, setHasNextPage] = useState(true)
14
+  const [PageNum, setPageNum] = useState(1)
15
+  const [NewsList, setNewsList] = useState([])
21 16
 
22
-  componentDidHide () { }
17
+  useEffect(() => {
18
+    GetNewsList(() => {
19
+      setIsPullUp(false)
20
+    })
21
+  }, [PageNum])
23 22
 
24
-  OnRefresh () { // 页面下拉刷新
25
-    this.setState({
26
-      IsPull: true
27
-    }, () => {
28
-      window.setTimeout(() => {
29
-        this.setState({
30
-          IsPull: false
31
-        })
32
-      }, 1000)
23
+  const GetNewsList = (done = () => { }) => { // 获取资讯列表
24
+    request({ ...apis.getNewsList, params: { pageNum: PageNum, pageSize: 6 } }).then((res) => {
25
+      if (PageNum === 1) {
26
+        setNewsList([...res.records])
27
+      } else {
28
+        setNewsList(NewsList.concat([...res.records]))
29
+      }
30
+      setHasNextPage(res.current - 0 < res.pages - 0)
31
+      done()
32
+    }).catch(() => {
33
+      done()
33 34
     })
34 35
   }
35 36
 
36
-  render () {
37
-    const { IsPull, ActivityList } = this.state
38
-    return (
39
-      <view className='ShouYeZiXun'>
40
-        <scroll-view scroll-y='true' style='height: 100%;' refresher-enabled={true} onrefresherrefresh={this.OnRefresh.bind(this)} refresher-triggered={IsPull} refresher-background='none'>
41
-          <view className='ShouYeHuoDongContent'>
42
-            {
43
-              ActivityList.map((item, index) => (
44
-                <view className='ListItem' key={`ActivityItem-${index}`}>
45
-                  <NewsListItem Data={item} ShowTips={index === 0}></NewsListItem>
46
-                </view>
47
-              ))
48
-            }
49
-          </view>
50
-        </scroll-view>
51
-      </view >
52
-    )
37
+  const OnRefresh = () => { // 页面下拉刷新
38
+    setIsPullDown(true)
39
+    setHasNextPage(true)
40
+    setPageNum(1)
41
+    if (PageNum === 1) {
42
+      GetNewsList(() => {
43
+        setIsPullDown(false)
44
+      })
45
+    } else {
46
+      setPageNum(1)
47
+    }
48
+  }
49
+
50
+  const OnPullUp = () => {
51
+    if (HasNextPage) {
52
+      setIsPullUp(true)
53
+      setPageNum(PageNum + 1)
54
+    }
53 55
   }
56
+
57
+  return (
58
+    <view className='ShouYeZiXun'>
59
+      <ScrollPage OnRefresh={OnRefresh} IsPullUp={IsPullUp} IsPullDown={IsPullDown} OnPullUp={OnPullUp} HasMore={HasNextPage}>
60
+        <view className='ShouYeHuoDongContent'>
61
+          {
62
+            NewsList.map((item, index) => (
63
+              <view className='ListItem' key={`ActivityItem-${index}`}>
64
+                <NewsListItem Data={item} ShowTips={index === 0}></NewsListItem>
65
+              </view>
66
+            ))
67
+          }
68
+        </view>
69
+      </ScrollPage>
70
+    </view >
71
+  )
54 72
 }

+ 13
- 13
src/pages/ShouYe/index.jsx Vedi File

@@ -31,17 +31,17 @@ export default function Index (props) {
31 31
   const [ActivityList, setActivityList] = useState([])
32 32
   const [NewsList, setNewsList] = useState([])
33 33
 
34
-  // useEffect(() => {
35
-  //   if (user) {
36
-  //     console.log(user, `user`)
37
-  //     OnRefresh()
38
-  //   }
39
-  // }, [user])
34
+  useEffect(() => {
35
+    if (user) {
36
+      console.log(user, `user`)
37
+      OnRefresh()
38
+    }
39
+  }, [user])
40 40
 
41
-  useUserMounted(() => {
42
-    console.log(user, `user`)
43
-    OnRefresh()
44
-  })
41
+  // useUserMounted(() => {
42
+  //   console.log(user, `user`)
43
+  //   OnRefresh()
44
+  // })
45 45
 
46 46
   const Init = (done = () => { }) => { // 初始化
47 47
     let DownCount = 0
@@ -116,7 +116,7 @@ export default function Index (props) {
116 116
     })
117 117
   }
118 118
 
119
-  const OnPullUp = () => {
119
+  const OnPullUp = () => { // 上拉加载
120 120
     // console.log(111)
121 121
   }
122 122
 
@@ -191,7 +191,7 @@ export default function Index (props) {
191 191
                           <Text onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/HuoDong/index' }) }}>热门活动</Text>
192 192
                           <Text className='iconfont icongengduo' onClick={() => { Taro.navigateTo({ url: '/pages/ShouYe/HuoDong/index' }) }}></Text>
193 193
                         </view>
194
-                        <view className='Activity'>
194
+                        <view className='Activity' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=${ActivityList[0].dynamicId}` }) }}>
195 195
                           <image className='centerLabel' mode='aspectFill' src={ActivityList[0].imgUrl}></image>
196 196
                         </view>
197 197
                       </view>
@@ -228,7 +228,7 @@ export default function Index (props) {
228 228
                       <view className='List'>
229 229
                         {
230 230
                           NewsList.map((item, index) => (
231
-                            <view key={`News-${index}`} className='flex-h'>
231
+                            <view key={`News-${index}`} className='flex-h' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/ZiXunDetail/index?id=${item.newsId}` }) }}>
232 232
                               <view className='Img'>
233 233
                                 <image mode='aspectFill' src={item.newsImg} className='centerLabel'></image>
234 234
                               </view>

+ 50
- 78
src/pages/WuYe/index.jsx Vedi File

@@ -1,4 +1,4 @@
1
-import React, { Component } from 'react'
1
+import React, { useState } from 'react'
2 2
 import TabPageCutNav from '@/components/TabPageCutNav/index'
3 3
 import NavHeader from '@/components/NavHeader/index'
4 4
 import WuYeGongGao from '@/components/WuYeGongGao/index'
@@ -9,96 +9,68 @@ import '@/assets/css/reset.less'
9 9
 import '@/assets/css/iconfont.less'
10 10
 import './index.less'
11 11
 
12
-export default class WuYe extends Component {
12
+export default function WuYe (props) {
13 13
 
14
-  state = {
15
-    NavList: [
16
-      { name: '公告', id: 1 },
17
-      { name: '服务', id: 2 },
18
-      { name: '报修', id: 3 },
19
-      { name: '缴费', id: 4 }
20
-    ],
21
-    CurrentNavId: 1,
22
-    IsPull: false
23
-  }
24
-
25
-  componentWillMount () {
26
-  }
27
-
28
-  componentDidMount () { }
14
+  const [NavList] = useState([{ name: '公告', id: 1 }, { name: '服务', id: 2 }, { name: '报修', id: 3 }, { name: '缴费', id: 4 }])
15
+  const [CurrentNavId, setCurrentNavId] = useState(1)
16
+  const [IsPull, setIsPull] = useState(false)
29 17
 
30
-  componentWillUnmount () { }
31
-
32
-  componentDidShow () { }
33
-
34
-  componentDidHide () { }
35
-
36
-  NavChange (e) {
18
+  const NavChange = (e) => {
37 19
     return () => {
38
-      this.setState({
39
-        CurrentNavId: e.id
40
-      })
20
+      setCurrentNavId(e.id)
41 21
     }
42 22
   }
43 23
 
44
-  OnRefresh () {
45
-    this.setState({
46
-      IsPull: true
47
-    }, () => {
48
-      window.setTimeout(() => {
49
-        this.setState({
50
-          IsPull: false
51
-        })
52
-      }, 1000)
53
-    })
24
+  const OnRefresh = () => {
25
+    setIsPull(true)
26
+    window.setTimeout(() => {
27
+      setIsPull(false)
28
+    }, 1000)
54 29
   }
55 30
 
56
-  render () {
57
-    const { NavList, CurrentNavId, IsPull } = this.state
58
-    return (
59
-      <view className='WuYe flex-v'>
60
-        <NavHeader Title='物业' BgColor='none' IsFixed={true}></NavHeader>
61
-        <TabPageCutNav List={NavList} CurrentNavId={CurrentNavId} NavChange={this.NavChange.bind(this)}></TabPageCutNav>
62
-        <view className='flex-item'>
63
-          <view>
64
-            <scroll-view scroll-y='true' style='height: 100%;' refresher-enabled={true} onrefresherrefresh={this.OnRefresh.bind(this)} refresher-triggered={IsPull} refresher-background='none'>
31
+  return (
32
+    <view className='WuYe flex-v'>
33
+      <NavHeader Title='物业' BgColor='none' IsFixed={true}></NavHeader>
34
+      <TabPageCutNav List={NavList} CurrentNavId={CurrentNavId} NavChange={NavChange}></TabPageCutNav>
35
+      <view className='flex-item'>
36
+        <view>
37
+          <scroll-view scroll-y='true' style='height: 100%;' refresher-enabled={true} onrefresherrefresh={OnRefresh} refresher-triggered={IsPull} refresher-background='none'>
65 38
 
66
-              {/* 公告 */}
67
-              {
68
-                CurrentNavId - 0 === 1 &&
69
-                <view className='Content GongGao'>
70
-                  <WuYeGongGao></WuYeGongGao>
71
-                </view>
72
-              }
39
+            {/* 公告 */}
40
+            {
41
+              CurrentNavId - 0 === 1 &&
42
+              <view className='Content GongGao'>
43
+                <WuYeGongGao></WuYeGongGao>
44
+              </view>
45
+            }
73 46
 
74
-              {/* 服务 */}
75
-              {
76
-                CurrentNavId - 0 === 2 &&
77
-                <view className='Content FuWu'>
78
-                  <WuYeFuWu></WuYeFuWu>
79
-                </view>
80
-              }
47
+            {/* 服务 */}
48
+            {
49
+              CurrentNavId - 0 === 2 &&
50
+              <view className='Content FuWu'>
51
+                <WuYeFuWu></WuYeFuWu>
52
+              </view>
53
+            }
81 54
 
82
-              {/* 报修 */}
83
-              {
84
-                CurrentNavId - 0 === 3 &&
85
-                <view className='Content BaoXiu'>
86
-                  <WuYeBaoXiu></WuYeBaoXiu>
87
-                </view>
88
-              }
55
+            {/* 报修 */}
56
+            {
57
+              CurrentNavId - 0 === 3 &&
58
+              <view className='Content BaoXiu'>
59
+                <WuYeBaoXiu></WuYeBaoXiu>
60
+              </view>
61
+            }
89 62
 
90
-              {/* 缴费 */}
91
-              {
92
-                CurrentNavId - 0 === 4 &&
93
-                <view className='Content JiaoFei'>
94
-                  <WuYeJiaoFei></WuYeJiaoFei>
95
-                </view>
96
-              }
63
+            {/* 缴费 */}
64
+            {
65
+              CurrentNavId - 0 === 4 &&
66
+              <view className='Content JiaoFei'>
67
+                <WuYeJiaoFei></WuYeJiaoFei>
68
+              </view>
69
+            }
97 70
 
98
-            </scroll-view>
99
-          </view>
71
+          </scroll-view>
100 72
         </view>
101 73
       </view>
102
-    )
103
-  }
74
+    </view>
75
+  )
104 76
 }

+ 12
- 0
src/utils/api.js Vedi File

@@ -5,10 +5,22 @@ const $api = {
5 5
     method: 'get',
6 6
     url: `${prefix}/buildingDynamiceList`
7 7
   },
8
+  getActivityDetail: { // 获取活动详情
9
+    method: 'get',
10
+    url: `${prefix}/buildingDynamiceInfo/:id`
11
+  },
8 12
   getNewsList: { // 获取资讯列表
9 13
     method: 'get',
10 14
     url: `${prefix}/taNews`
11 15
   },
16
+  getNewsDetail: { // 获取资讯详情
17
+    method: 'get',
18
+    url: `${prefix}/taNews/:id`
19
+  },
20
+  addNewsViews: { // 资讯阅读量+1
21
+    method: 'put',
22
+    url: `${prefix}/taNews/pvNum/:id`
23
+  },
12 24
   getBanner: { // 获取轮播图
13 25
     method: 'get',
14 26
     url: `${prefix}/extendContent/banner`