1002884655 4 anni fa
parent
commit
12a0e46fea
2 ha cambiato i file con 26 aggiunte e 15 eliminazioni
  1. 1
    1
      project.config.json
  2. 25
    14
      src/pages/HuoDong/HuoDongSign/index.jsx

+ 1
- 1
project.config.json Vedi File

@@ -28,7 +28,7 @@
28 28
 		},
29 29
 		"bundle": false,
30 30
 		"useIsolateContext": true,
31
-		"useCompilerModule": false,
31
+		"useCompilerModule": true,
32 32
 		"userConfirmedUseCompilerModuleSwitch": false,
33 33
 		"useMultiFrameRuntime": false,
34 34
 		"useApiHook": true,

+ 25
- 14
src/pages/HuoDong/HuoDongSign/index.jsx Vedi File

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react'
2
-import Taro, { useRouter } from '@tarojs/taro'
2
+import Taro, { Current, useRouter } from '@tarojs/taro'
3 3
 import request, { apis } from '@/utils/request'
4 4
 import Page from '@/layouts'
5 5
 import { useModel } from '@/store'
@@ -53,18 +53,22 @@ export default function HuoDongDetail () {
53 53
   }
54 54
 
55 55
   const ToSign = () => {
56
-    if (!DataLock && JoinInfo.enlist !== null) {
57
-      setDataLock(true)
58
-      request({ ...apis.activitySign, args: { id: JoinInfo.enlist.enlistId } }).then(() => {
59
-        Taro.showToast({ title: '签到成功,积分+1', icon: 'none' })
60
-        setUser({ ...user, points: user.points - 0 > 0 ? user.points - 0 + 1 : 1 })
61
-        GetActivityDetail()
62
-        setDataLock(false)
63
-        setHasSign(true)
64
-      }).catch((res) => {
65
-        Taro.showToast({ title: res, icon: 'none' })
66
-        setDataLock(false)
67
-      })
56
+    if (JoinInfo.enlist !== null) {
57
+      if (!DataLock) {
58
+        setDataLock(true)
59
+        request({ ...apis.activitySign, args: { id: JoinInfo.enlist.enlistId } }).then(() => {
60
+          Taro.showToast({ title: '签到成功,积分+1', icon: 'none' })
61
+          setUser({ ...user, points: user.points - 0 > 0 ? user.points - 0 + 1 : 1 })
62
+          GetActivityDetail()
63
+          setDataLock(false)
64
+          setHasSign(true)
65
+        }).catch((res) => {
66
+          Taro.showToast({ title: res, icon: 'none' })
67
+          setDataLock(false)
68
+        })
69
+      }
70
+    } else {
71
+      Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=${CurrnetId}` })
68 72
     }
69 73
   }
70 74
 
@@ -74,7 +78,14 @@ export default function HuoDongDetail () {
74 78
         <image mode='aspectFill' src='https://zhiyun-image.oss-cn-shanghai.aliyuncs.com/xiangsong/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20201218165430-min.jpg' className='centerLabel'></image>
75 79
         <view className={HasSign ? 'SignBtn' : 'SignBtn active'}>
76 80
           <view>
77
-            <text className='centerLabel' onClick={ToSign}>{HasSign ? '已签到' : '签到'}</text>
81
+            {
82
+              JoinInfo !== null && JoinInfo.enlist !== null &&
83
+              <text className='centerLabel' onClick={ToSign}>{HasSign ? '已签到' : '签到'}</text>
84
+            }
85
+            {
86
+              JoinInfo !== null && JoinInfo.enlist === null &&
87
+              <text className='centerLabel' onClick={() => { Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=${CurrnetId}` }) }}>去报名</text>
88
+            }
78 89
           </view>
79 90
         </view>
80 91
       </view>