|
@@ -1,101 +1,276 @@
|
1
|
|
-import { useState, useEffect } from 'react'
|
2
|
|
-import withLayout from '@/layout'
|
3
|
|
-import { ScrollView, Image } from '@tarojs/components'
|
4
|
|
-import '@/assets/css/iconfont.css'
|
5
|
|
-import './index.scss'
|
|
1
|
+import { useState, useEffect } from "react";
|
|
2
|
+import Taro, { useDidShow, useReady } from "@tarojs/taro";
|
|
3
|
+import withLayout from "@/layout";
|
|
4
|
+import {
|
|
5
|
+ Text,
|
|
6
|
+ View,
|
|
7
|
+ Picker,
|
|
8
|
+ Input,
|
|
9
|
+ ScrollView,
|
|
10
|
+ Image,
|
|
11
|
+ RichText,
|
|
12
|
+} from "@tarojs/components";
|
|
13
|
+import "@/assets/css/iconfont.css";
|
|
14
|
+import "./index.scss";
|
|
15
|
+import {
|
|
16
|
+ // addActivityShareNum,
|
|
17
|
+ signupActivity,
|
|
18
|
+ favorActivity,
|
|
19
|
+ cancelFavorActivity,
|
|
20
|
+ queryActivityDetail,
|
|
21
|
+} from "@/services/activity";
|
|
22
|
+import { getImgURL } from "@/utils/image";
|
|
23
|
+import getDateFormat from "@/utils/chatDate";
|
6
|
24
|
|
7
|
|
-export default withLayout(() => {
|
|
25
|
+const activityStatusDict = {
|
|
26
|
+ 0: {
|
|
27
|
+ text: "立即参与",
|
|
28
|
+ className: "yellow",
|
|
29
|
+ },
|
|
30
|
+ 1: {
|
|
31
|
+ text: "未开始",
|
|
32
|
+ className: "blue",
|
|
33
|
+ },
|
|
34
|
+ 2: {
|
|
35
|
+ text: "已结束",
|
|
36
|
+ className: "grey",
|
|
37
|
+ },
|
|
38
|
+ 3: {
|
|
39
|
+ text: "已参与",
|
|
40
|
+ className: "yellow",
|
|
41
|
+ },
|
|
42
|
+};
|
8
|
43
|
|
9
|
|
- const [IsPull, setPull] = useState(false)
|
10
|
|
- const [PullTimer, setPullTimer] = useState(null)
|
|
44
|
+export default withLayout((props) => {
|
|
45
|
+ console.log(props, "props");
|
|
46
|
+ const { id } = props.router.params;
|
|
47
|
+ const [detail, setDetail] = useState({});
|
|
48
|
+ const [canChoose, setCanChoose] = useState("none");
|
11
|
49
|
|
12
|
|
- const PageRefresh = () => { // 页面下拉刷新回调
|
13
|
|
- setPull(true)
|
14
|
|
- }
|
|
50
|
+ const [IsPull, setPull] = useState(false);
|
|
51
|
+ const [PullTimer, setPullTimer] = useState(null);
|
15
|
52
|
|
16
|
|
- useEffect(() => { // 下拉刷新触发
|
|
53
|
+ const PageRefresh = () => {
|
|
54
|
+ // 页面下拉刷新回调
|
|
55
|
+ setPull(true);
|
|
56
|
+ };
|
|
57
|
+
|
|
58
|
+ useEffect(() => {
|
|
59
|
+ // 下拉刷新触发
|
17
|
60
|
if (IsPull) {
|
18
|
|
- clearTimeout(PullTimer)
|
19
|
|
- setPullTimer(setTimeout(() => {
|
20
|
|
- setPull(false)
|
21
|
|
- }, 2000))
|
|
61
|
+ clearTimeout(PullTimer);
|
|
62
|
+ setPullTimer(
|
|
63
|
+ setTimeout(() => {
|
|
64
|
+ setPull(false);
|
|
65
|
+ }, 2000)
|
|
66
|
+ );
|
|
67
|
+ }
|
|
68
|
+ }, [IsPull]);
|
|
69
|
+
|
|
70
|
+ const getDetail = (params) => {
|
|
71
|
+ Taro.showLoading();
|
|
72
|
+
|
|
73
|
+ queryActivityDetail(params).then((res) => {
|
|
74
|
+ console.log(res, "queryActivityDetail");
|
|
75
|
+ setDetail(res);
|
|
76
|
+
|
|
77
|
+ Taro.hideLoading();
|
|
78
|
+ });
|
|
79
|
+ };
|
|
80
|
+
|
|
81
|
+ useEffect(() => {
|
|
82
|
+ if (id) {
|
|
83
|
+ getDetail(id);
|
|
84
|
+ }
|
|
85
|
+ }, [id]);
|
|
86
|
+
|
|
87
|
+ useReady(() => {
|
|
88
|
+ console.log("Taro.showLoading()");
|
|
89
|
+ });
|
|
90
|
+
|
|
91
|
+ useDidShow(() => {
|
|
92
|
+ // Taro.getCurrentPages()
|
|
93
|
+ console.log("Taro.showLoading()");
|
|
94
|
+
|
|
95
|
+ // console.log(Taro.getCurrentPages(),'Taro.showLoading()')
|
|
96
|
+ // getDetail()
|
|
97
|
+ });
|
|
98
|
+
|
|
99
|
+ //收藏
|
|
100
|
+ const handleFavo = () => {
|
|
101
|
+ const { dynamicId, isSaved } = detail;
|
|
102
|
+ if (isSaved) {
|
|
103
|
+ cancelFavorActivity(dynamicId).then((res) => {
|
|
104
|
+ Taro.showToast({
|
|
105
|
+ title: "已取消收藏",
|
|
106
|
+ });
|
|
107
|
+ setDetail({
|
|
108
|
+ ...detail,
|
|
109
|
+ isSaved: 0,
|
|
110
|
+ });
|
|
111
|
+ });
|
|
112
|
+ } else {
|
|
113
|
+ favorActivity(dynamicId).then((res) => {
|
|
114
|
+ Taro.showToast({
|
|
115
|
+ title: "收藏成功",
|
|
116
|
+ });
|
|
117
|
+ setDetail({
|
|
118
|
+ ...detail,
|
|
119
|
+ isSaved: 1,
|
|
120
|
+ });
|
|
121
|
+ });
|
|
122
|
+ }
|
|
123
|
+ // savePoint({
|
|
124
|
+ // event: 'save',
|
|
125
|
+ // eventType: 'activity',
|
|
126
|
+ // targetType: 'dynamic',
|
|
127
|
+ // propertyName: '活动详情收藏',
|
|
128
|
+ // data: '{}'
|
|
129
|
+ // }).then(res => {
|
|
130
|
+ // console.log('活动详情收藏')
|
|
131
|
+ // })
|
|
132
|
+ };
|
|
133
|
+
|
|
134
|
+ const handleSignup = () => {
|
|
135
|
+ const {
|
|
136
|
+ detail: { buildingId, dynamicId, isSign },
|
|
137
|
+ } = this.state;
|
|
138
|
+ const {
|
|
139
|
+ userInfo: {
|
|
140
|
+ person: { phone, name, nickname },
|
|
141
|
+ },
|
|
142
|
+ } = this.props;
|
|
143
|
+
|
|
144
|
+ if (isSign) {
|
|
145
|
+ Taro.showToast({
|
|
146
|
+ icon: "none",
|
|
147
|
+ title: "你已报名成功",
|
|
148
|
+ });
|
|
149
|
+ return;
|
22
|
150
|
}
|
23
|
|
- }, [IsPull])
|
|
151
|
+
|
|
152
|
+ this.setState({
|
|
153
|
+ canChoose: "block",
|
|
154
|
+ });
|
|
155
|
+ };
|
24
|
156
|
|
25
|
157
|
return (
|
26
|
|
- <view className='Page activityDetail flex-v'>
|
27
|
|
- <view className='flex-item'>
|
|
158
|
+ <view className="Page activityDetail flex-v">
|
|
159
|
+ <view className="flex-item">
|
28
|
160
|
<view>
|
29
|
|
- <ScrollView scroll-y refresher-enabled refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} refresher-background='#fff'>
|
30
|
|
- <view className='PageContent'>
|
31
|
|
-
|
32
|
|
- <view className='Top'>
|
33
|
|
- <Image mode='aspectFill' src={null} className='centerLabel'></Image>
|
|
161
|
+ <ScrollView
|
|
162
|
+ scroll-y
|
|
163
|
+ refresher-enabled
|
|
164
|
+ refresher-triggered={IsPull}
|
|
165
|
+ onrefresherrefresh={PageRefresh}
|
|
166
|
+ refresher-background="#fff"
|
|
167
|
+ >
|
|
168
|
+ <view className="PageContent">
|
|
169
|
+ <view className="Top">
|
|
170
|
+ <Image
|
|
171
|
+ mode="aspectFill"
|
|
172
|
+ src={getImgURL(detail.bannerListImg)}
|
|
173
|
+ className="centerLabel"
|
|
174
|
+ ></Image>
|
34
|
175
|
</view>
|
35
|
176
|
|
36
|
|
- <view className='Info'>
|
|
177
|
+ <view className="Info">
|
37
|
178
|
<view>
|
38
|
|
- <view className='Title flex-h'>
|
39
|
|
- <view className='flex-item'>
|
40
|
|
- <text>换了套圈圈福利 快来参加吧</text>
|
|
179
|
+ <view className="Title flex-h">
|
|
180
|
+ <view className="flex-item">
|
|
181
|
+ <text>{detail.title}</text>
|
41
|
182
|
</view>
|
42
|
|
- <text className='Tips'>17人已报名</text>
|
|
183
|
+ <text className="Tips">{detail.enlisted || 0}人已报名</text>
|
43
|
184
|
</view>
|
44
|
|
- <text className='Time'>报名截止时间:2019-07-19 12:00</text>
|
45
|
|
- <text className='Name'>“香颂 · 蔚澜半岛”</text>
|
46
|
|
- <view className='flex-h Address'>
|
|
185
|
+ <text className="Time">
|
|
186
|
+ 报名截止时间:
|
|
187
|
+ {getDateFormat(
|
|
188
|
+ new Date(detail.enlistEnd).valueOf(),
|
|
189
|
+ true,
|
|
190
|
+ "yyyy/M/d"
|
|
191
|
+ )}
|
|
192
|
+ </text>
|
|
193
|
+ {/* <text className="Name">“香颂 · 蔚澜半岛”</text> */}
|
|
194
|
+ <view className="flex-h Address">
|
47
|
195
|
<text>地址:</text>
|
48
|
|
- <view className='flex-item'>
|
49
|
|
- <text>江苏省南京市奥体大厦1楼</text>
|
|
196
|
+ <view className="flex-item">
|
|
197
|
+ <text>{detail.address}</text>
|
50
|
198
|
</view>
|
51
|
199
|
</view>
|
52
|
|
- <view className='flex-h Date'>
|
|
200
|
+ <view className="flex-h Date">
|
53
|
201
|
<text>时间:</text>
|
54
|
|
- <view className='flex-item'>
|
55
|
|
- <text>2019/10/20 10:00 - 2019/10/22 10:00</text>
|
|
202
|
+ <view className="flex-item">
|
|
203
|
+ <text>
|
|
204
|
+ {getDateFormat(
|
|
205
|
+ new Date(detail.startDate).valueOf(),
|
|
206
|
+ true,
|
|
207
|
+ "yyyy/M/d"
|
|
208
|
+ )}{" "}
|
|
209
|
+ -{" "}
|
|
210
|
+ {getDateFormat(
|
|
211
|
+ new Date(detail.endDate).valueOf(),
|
|
212
|
+ true,
|
|
213
|
+ "yyyy/M/d"
|
|
214
|
+ )}
|
|
215
|
+ </text>
|
56
|
216
|
</view>
|
57
|
217
|
</view>
|
58
|
|
- <view className='Btn'>
|
|
218
|
+ <view className="Btn">
|
59
|
219
|
<text>分享好友</text>
|
60
|
220
|
</view>
|
61
|
221
|
</view>
|
62
|
222
|
</view>
|
63
|
223
|
|
64
|
|
- <view className='ActivityIntro'>
|
65
|
|
- <view className='Title'>
|
|
224
|
+ <view className="ActivityIntro">
|
|
225
|
+ <view className="Title">
|
66
|
226
|
<text>活动介绍</text>
|
67
|
227
|
</view>
|
|
228
|
+ <Image
|
|
229
|
+ mode="aspectFill"
|
|
230
|
+ src={getImgURL(detail.imgUrl)}
|
|
231
|
+ className="img"
|
|
232
|
+ ></Image>
|
|
233
|
+ <RichText nodes={detail.desc} />
|
|
234
|
+ {/* <richText nodes={detail.desc} ></richText> */}
|
68
|
235
|
</view>
|
69
|
236
|
|
70
|
|
- <view className='Bottom'>
|
|
237
|
+ <view className="Bottom">
|
71
|
238
|
<view>
|
72
|
239
|
<view>
|
73
|
|
- <text className='iconfont icon-shengming'></text>
|
|
240
|
+ <text className="iconfont icon-shengming"></text>
|
74
|
241
|
<text>免责声明</text>
|
75
|
242
|
</view>
|
76
|
243
|
<view>
|
77
|
|
- <text>  以上价格仅供参考,具体一房一价的信息以售楼处展示为准。房屋位置交通、医疗、教育、商业等配套信息,来源于第三方不作为要约,仅供参考,双方具体权利义务应以法律规定及买卖合同约定为准。本平台对项目周边文化教育的介绍旨在提供相关信息1 意味着信息发布方对就学安排作出承诺。相关教育资首页信息存在调整的可能,应以政府教育主管部门门及办学颁布的政策规定为准。详情请仔细阅读</text>
|
78
|
|
- <text className='active'>《新联家使用免责条款》</text>
|
|
244
|
+ <text>
|
|
245
|
+   以上价格仅供参考,具体一房一价的信息以售楼处展示为准。房屋位置交通、医疗、教育、商业等配套信息,来源于第三方不作为要约,仅供参考,双方具体权利义务应以法律规定及买卖合同约定为准。本平台对项目周边文化教育的介绍旨在提供相关信息1
|
|
246
|
+ 意味着信息发布方对就学安排作出承诺。相关教育资首页信息存在调整的可能,应以政府教育主管部门门及办学颁布的政策规定为准。详情请仔细阅读
|
|
247
|
+ </text>
|
|
248
|
+ <text className="active">《新联家使用免责条款》</text>
|
79
|
249
|
</view>
|
80
|
250
|
</view>
|
81
|
251
|
</view>
|
82
|
|
-
|
83
|
252
|
</view>
|
84
|
253
|
</ScrollView>
|
85
|
254
|
</view>
|
86
|
255
|
</view>
|
87
|
|
- <view className='PageBottom flex-h'>
|
88
|
|
- <view className='Share'>
|
89
|
|
- <text className='iconfont icon-fenxiang'></text>
|
|
256
|
+ <view className="PageBottom flex-h">
|
|
257
|
+ <view className="Share">
|
|
258
|
+ <text className="iconfont icon-fenxiang"></text>
|
90
|
259
|
<text>分享</text>
|
91
|
260
|
</view>
|
92
|
|
- <view className='Collect'>
|
93
|
|
- <text className='iconfont icon-shoucang'></text>
|
|
261
|
+ <view className="Collect" onClick={handleFavo}>
|
|
262
|
+ <text
|
|
263
|
+ className="iconfont icon-shoucang"
|
|
264
|
+ style={detail.isSaved === 1 ? { color: "red" } : undefined}
|
|
265
|
+ ></text>
|
94
|
266
|
<text>收藏</text>
|
95
|
267
|
</view>
|
96
|
|
- <view className='flex-item'></view>
|
97
|
|
- <text className='Post'>立即报名</text>
|
|
268
|
+ <view className="flex-item"></view>
|
|
269
|
+
|
|
270
|
+ <text className="Post" onClick={handleSignup}>
|
|
271
|
+ {activityStatusDict[detail.activityStatus]?.text}
|
|
272
|
+ </text>
|
98
|
273
|
</view>
|
99
|
274
|
</view>
|
100
|
|
- )
|
101
|
|
-})
|
|
275
|
+ );
|
|
276
|
+});
|