|
@@ -1,9 +1,17 @@
|
1
|
1
|
import { useState, useEffect } from "react";
|
2
|
2
|
import Taro from "@tarojs/taro";
|
3
|
3
|
import withLayout from "@/layout";
|
4
|
|
-import { ScrollView, Image, RichText } from "@tarojs/components";
|
|
4
|
+import {
|
|
5
|
+ ScrollView,
|
|
6
|
+ Image,
|
|
7
|
+ RichText,
|
|
8
|
+ View,
|
|
9
|
+ Text,
|
|
10
|
+ Input,
|
|
11
|
+ Picker,
|
|
12
|
+} from "@tarojs/components";
|
5
|
13
|
import Disclaimer from "@/components/Disclaimer";
|
6
|
|
-
|
|
14
|
+import { useSelector } from "react-redux";
|
7
|
15
|
import {
|
8
|
16
|
// addActivityShareNum,
|
9
|
17
|
signupActivity,
|
|
@@ -14,7 +22,7 @@ import getDateFormat from "@/utils/chatDate";
|
14
|
22
|
import useParams from "@/utils/hooks/useParams";
|
15
|
23
|
import useShare from "@/utils/hooks/useShare";
|
16
|
24
|
import useFavor from "@/utils/hooks/useFavor";
|
17
|
|
-
|
|
25
|
+import { getDownloadURL, times, transferImage } from "@/utils/tools";
|
18
|
26
|
import "./index.scss";
|
19
|
27
|
|
20
|
28
|
const activityStatusDict = {
|
|
@@ -43,16 +51,27 @@ const activityStatusDict = {
|
43
|
51
|
export default withLayout((props) => {
|
44
|
52
|
const { router, shareContent, trackData, person, page } = props;
|
45
|
53
|
const { id } = router.params;
|
|
54
|
+
|
|
55
|
+ const user = useSelector((state) => state.user);
|
|
56
|
+
|
46
|
57
|
const [detail, setDetail] = useState();
|
|
58
|
+ const [canChoose, setCanChoose] = useState("none");
|
|
59
|
+ const [inputName, setInputName] = useState("");
|
|
60
|
+ const [selectorChecked, setSelectorChecked] = useState("1");
|
|
61
|
+ const [selector, setSelector] = useState("");
|
|
62
|
+
|
47
|
63
|
const buildingId = detail?.buildingId;
|
48
|
64
|
|
49
|
65
|
const getDetail = (params) => {
|
50
|
66
|
Taro.showLoading();
|
51
|
67
|
|
52
|
68
|
queryActivityDetail(params).then((res) => {
|
53
|
|
- console.log(res, "queryActivityDetail");
|
54
|
|
- setDetail(res);
|
|
69
|
+ const maxperson =
|
|
70
|
+ res.maxEnlistByPerson < 100 ? res.maxEnlistByPerson : 100;
|
|
71
|
+
|
|
72
|
+ setSelector(times(maxperson || 1).map((_, i) => `${i + 1}`));
|
55
|
73
|
|
|
74
|
+ setDetail(res);
|
56
|
75
|
Taro.hideLoading();
|
57
|
76
|
});
|
58
|
77
|
};
|
|
@@ -89,14 +108,7 @@ export default withLayout((props) => {
|
89
|
108
|
}, [id]);
|
90
|
109
|
|
91
|
110
|
const handleSignup = () => {
|
92
|
|
- const {
|
93
|
|
- detail: { buildingId, dynamicId, isSign },
|
94
|
|
- } = this.state;
|
95
|
|
- const {
|
96
|
|
- userInfo: {
|
97
|
|
- person: { phone, name, nickname },
|
98
|
|
- },
|
99
|
|
- } = this.props;
|
|
111
|
+ const { buildingId, dynamicId, isSign } = detail;
|
100
|
112
|
|
101
|
113
|
if (isSign) {
|
102
|
114
|
Taro.showToast({
|
|
@@ -105,12 +117,52 @@ export default withLayout((props) => {
|
105
|
117
|
});
|
106
|
118
|
return;
|
107
|
119
|
}
|
|
120
|
+ setCanChoose("block");
|
|
121
|
+ };
|
108
|
122
|
|
109
|
|
- this.setState({
|
110
|
|
- canChoose: "block",
|
|
123
|
+ const comfire = (e) => {
|
|
124
|
+ const { dynamicId } =detail;
|
|
125
|
+ // console.log(user, "user");
|
|
126
|
+ const { userInfo: { person: { phone, tel } } } = user
|
|
127
|
+ if (inputName == "") {
|
|
128
|
+ Taro.showToast({
|
|
129
|
+ title: "请输入姓名",
|
|
130
|
+ icon: "none",
|
|
131
|
+ });
|
|
132
|
+ return;
|
|
133
|
+ }
|
|
134
|
+
|
|
135
|
+ const payload = {
|
|
136
|
+ buildingId,
|
|
137
|
+ dynamicId,
|
|
138
|
+ name: inputName,
|
|
139
|
+ phone: phone ? phone : tel,
|
|
140
|
+ attendNum: selectorChecked,
|
|
141
|
+ };
|
|
142
|
+
|
|
143
|
+ signupActivity(payload).then((res) => {
|
|
144
|
+ Taro.showToast({
|
|
145
|
+ title: "报名成功",
|
|
146
|
+ });
|
|
147
|
+ setSelector('none')
|
|
148
|
+ // this.setState({
|
|
149
|
+ // isSign: true,
|
|
150
|
+ // canChoose: "none",
|
|
151
|
+ // });
|
|
152
|
+ setTimeout(() => {
|
|
153
|
+ getDetail(id);
|
|
154
|
+ }, 500);
|
111
|
155
|
});
|
112
|
156
|
};
|
113
|
157
|
|
|
158
|
+ function hideModal() {
|
|
159
|
+ setCanChoose("none");
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ const onInputText = (e) => {
|
|
163
|
+ setInputName(e.detail.value);
|
|
164
|
+ };
|
|
165
|
+
|
114
|
166
|
const dymic = () => (
|
115
|
167
|
<view className="Info">
|
116
|
168
|
<view>
|
|
@@ -196,7 +248,7 @@ export default withLayout((props) => {
|
196
|
248
|
</view>
|
197
|
249
|
<view className="right">
|
198
|
250
|
<view>
|
199
|
|
- <button open-type="share">
|
|
251
|
+ <button open-type="share">
|
200
|
252
|
<text className="iconfont icon-fenxiang"></text>
|
201
|
253
|
<text>分享</text>
|
202
|
254
|
</button>
|
|
@@ -297,6 +349,35 @@ export default withLayout((props) => {
|
297
|
349
|
)}
|
298
|
350
|
</view>
|
299
|
351
|
)}
|
|
352
|
+
|
|
353
|
+ <View className="page-body" style={{ display: canChoose }}>
|
|
354
|
+ <View className="mask" onClick={() => hideModal()}></View>
|
|
355
|
+ <View className="page-section">
|
|
356
|
+ <Text className="page-section__title">报名信息</Text>
|
|
357
|
+ <View className="page-content">
|
|
358
|
+ <Input
|
|
359
|
+ className="inputName"
|
|
360
|
+ onInput={onInputText}
|
|
361
|
+ type="text"
|
|
362
|
+ placeholder="请输入姓名"
|
|
363
|
+ />
|
|
364
|
+ <Picker
|
|
365
|
+ mode="selector"
|
|
366
|
+ range={selector}
|
|
367
|
+ onChange={(e) => setSelectorChecked(selector[e.detail.value])}
|
|
368
|
+ >
|
|
369
|
+ <View className="picker">
|
|
370
|
+ <Text>参加人数</Text>
|
|
371
|
+ <Text className="content">{selectorChecked}</Text>
|
|
372
|
+ <Text>人</Text>
|
|
373
|
+ </View>
|
|
374
|
+ </Picker>
|
|
375
|
+ <View onClick={comfire} className="comfire">
|
|
376
|
+ 确认
|
|
377
|
+ </View>
|
|
378
|
+ </View>
|
|
379
|
+ </View>
|
|
380
|
+ </View>
|
300
|
381
|
</>
|
301
|
382
|
);
|
302
|
383
|
});
|