Kaynağa Gözat

静态页面

xcx 4 yıl önce
ebeveyn
işleme
5cf7e77db9

+ 23
- 2
src/components/ActivityListItem/index.jsx Dosyayı Görüntüle

@@ -1,5 +1,6 @@
1 1
 import React, { useState } from 'react'
2 2
 import Taro from '@tarojs/taro'
3
+import toolclass from '@/utils/toolclass.js'
3 4
 import '@/assets/css/reset.less'
4 5
 import '@/assets/css/iconfont.less'
5 6
 import './index.less'
@@ -8,6 +9,26 @@ export default function ActivityListItem (props) {
8 9
 
9 10
   const { Data } = props
10 11
 
12
+  const BtnStatus = () => { // 按钮状态
13
+    let StartTime = new Date(Data.enlistStart).getTime()
14
+    let EndTime = new Date(Data.enlistEnd).getTime()
15
+    let StopTime = new Date(Data.endDate).getTime()
16
+    let Now = Date.now()
17
+    if (StartTime > Now) {
18
+      return `未开始`
19
+    }
20
+    if (StartTime <= Now && EndTime > Now) {
21
+      return !!Data.isSign ? `已报名` : `去报名`
22
+    }
23
+    if (EndTime <= Now && StopTime > Now) {
24
+      return `进行中`
25
+    }
26
+    if (StopTime <= Now) {
27
+      return `已结束`
28
+    }
29
+    return ``
30
+  }
31
+
11 32
   return (
12 33
     <view className='ActivityListItem' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=${Data.dynamicId}` }) }}>
13 34
       <view className='Img'>
@@ -16,9 +37,9 @@ export default function ActivityListItem (props) {
16 37
       <view className='Info flex-h'>
17 38
         <view className='flex-item'>
18 39
           <text>{Data.title}</text>
19
-          <text>参与截止时间:{Data.enlistEnd}</text>
40
+          <text>参与截止时间:{toolclass.FormatDate(Data.enlistEnd)}</text>
20 41
         </view>
21
-        <text className='active'>未开始</text>
42
+        <text className={BtnStatus() === '未开始' || BtnStatus() === '去报名' ? 'active' : ''}>{BtnStatus()}</text>
22 43
       </view>
23 44
     </view >
24 45
   )

+ 1
- 0
src/pages/HuoDong/HuoDongDetail/index.css Dosyayı Görüntüle

@@ -81,6 +81,7 @@
81 81
   font-size: 28px;
82 82
   color: #F35844;
83 83
   line-height: 40px;
84
+  margin-left: 10px;
84 85
 }
85 86
 .HuoDongDetail > .Info > .Desc {
86 87
   position: relative;

+ 3
- 2
src/pages/HuoDong/HuoDongDetail/index.jsx Dosyayı Görüntüle

@@ -4,6 +4,7 @@ import { RichText, Button } from '@tarojs/components'
4 4
 import request, { apis } from '@/utils/request'
5 5
 import { useModel } from '@/store'
6 6
 import GetUserPhone from '@/components/GetUserPhone/index'
7
+import toolclass from '@/utils/toolclass.js'
7 8
 import '@/assets/css/reset.less'
8 9
 import '@/assets/css/iconfont.less'
9 10
 import './index.less'
@@ -85,7 +86,7 @@ export default function HuoDongDetail (props) {
85 86
             <text className='Tips'>{ActivityDetail.enlisted}人已报名</text>
86 87
             <view className='flex-h'>
87 88
               <text>活动时间:</text>
88
-              <view className='flex-item'>{ActivityDetail.startDate}<text>限{ActivityDetail.enlistNum}人</text></view>
89
+              <view className='flex-item'>{toolclass.FormatDate(ActivityDetail.startDate)}<text>限{ActivityDetail.enlistNum}人</text></view>
89 90
             </view>
90 91
             <view className='flex-h'>
91 92
               <text>活动地址:</text>
@@ -93,7 +94,7 @@ export default function HuoDongDetail (props) {
93 94
             </view>
94 95
             <view className='flex-h'>
95 96
               <text>报名截止:</text>
96
-              <view className='flex-item'>{ActivityDetail.enlistEnd}</view>
97
+              <view className='flex-item'>{toolclass.FormatDate(ActivityDetail.enlistEnd)}</view>
97 98
             </view>
98 99
           </view>
99 100
 

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

@@ -87,6 +87,7 @@
87 87
             font-size: 28px;
88 88
             color: #F35844;
89 89
             line-height: 40px;
90
+            margin-left: 10px;
90 91
           }
91 92
         }
92 93
       }

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

@@ -6,7 +6,7 @@ import '@/assets/css/reset.less'
6 6
 import '@/assets/css/iconfont.less'
7 7
 import './index.less'
8 8
 
9
-export default function ShouYeHuoDong (props) {
9
+export default function ShouYeHuoDong () {
10 10
 
11 11
   const [IsPullUp, setIsPullUp] = useState(false)
12 12
   const [IsPullDown, setIsPullDown] = useState(false)

+ 17
- 0
src/utils/toolclass.js Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+const toolclass = {
2
+  FormatDate: (date = null) => { // 格式化时间
3
+    if (date !== null) {
4
+      date = new Date(date)
5
+      let YY = date.getFullYear()
6
+      let MM = date.getMonth() + 1
7
+      let DD = date.getDate()
8
+      let hh = date.getHours()
9
+      let mm = date.getMinutes()
10
+      let ss = date.getSeconds()
11
+      return `${YY}-${MM > 9 ? MM : `0${MM}`}-${DD > 9 ? DD : `0${DD}`} ${hh > 9 ? hh : `0${hh}`}:${mm > 9 ? mm : `0${mm}`}:${ss > 9 ? ss : `0${ss}`}`
12
+    } else {
13
+      return ''
14
+    }
15
+  }
16
+}
17
+export default toolclass