绿满眶商城微信小程序-uniapp
zxl
2025-06-04 b62daf4aaca5fcb8eea7bfd4149dbb92b10f50de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<template>
    <view class="container">
        <!-- 顶部海报图 -->
        <!-- 动态封面区域 -->
        <view class="cover-container">
          <!-- 图片类型 -->
          <block v-if="activityInfo.coverType === '图片' || activityInfo.coverType === '视频'">
            <image :src="getPreviewUrl(activityInfo.cover)" mode="aspectFill" class="activity-cover" />
          </block>
          <!-- 文字类型 -->
          <block v-if="activityInfo.coverType === '文字'">
            <view class="text-cover">
              <text class="cover-text">{{ activityInfo.cover }}</text>
            </view>
          </block>
        </view>
 
        <!-- 活动基本信息 -->
        <view class="info-section">
            <text class="title">{{ activityInfo.activityName }}</text>
            <view class="meta-info">
                <view>
                    <text class="time">
                        开始时间:{{ activityInfo.startTime }}
                    </text>
                    
                </view>
                <view>
                    <text class="time">
                        结束时间:{{ activityInfo.endTime }}
                    </text>
                </view>
                <view>
                    <text class="location">地点:{{ activityInfo.activityLocation || '暂无' }}</text>
                </view>
                <view>
                    <text class="location">最大人数:{{ activityInfo.limitUserNum || '暂无' }}</text>
                </view>
                <view>
                    <text class="location">活动类型:{{ activityInfo.activityType || '暂无' }}</text>
                </view>
            </view>
            <view class="tags">
                <text v-for="(tag, index) in activityInfo.tags" :key="index" class="tag">{{ tag }}</text>
            </view>
        </view>
 
        
 
        <!-- 活动详情内容 -->
        <view class="content-section">
            <rich-text :nodes="activityInfo.activityContent"></rich-text>
        </view>
        <!-- 报名状态 -->
        <view class="status-bar" :style="{ backgroundColor: statusBarColor }">
            <button class="signup-btn" @click="activityReport()" :disabled="reportBtn" >{{ reportBtn ? '已报名': '立即报名'}}</button>
        </view>
    </view>
</template>
 
<script>
    import {getPreviewUrl} from '@/api/common.js'
    import {
        getActivityDetail,
        activityReport
    } from '@/api/activity.js';
    export default {
        data() {
            return {
                activityInfo: {
                    coverType: '',
                    cover: '',
                    activityName: '',
                    startTime: '', // 时间戳
                    endTime: '',
                    activityLocation: '',
                    tags: [],
                    activityContent: '',
                    activityType: '',
                    limitUserNum:'',
                },
                reportBtn:false,
                detailId: null, // 存储接收的参数
                reportFrom: {
                    activityId: '',
                    cancel: false, //报名接口默认我false
                }
            };
        },
        onLoad(options) {
            // 接收 URL 参数
            if (options.id) {
                this.detailId = options.id;
                // 可在此处发起请求,根据 ID 加载详情数据
                this.loadDetailData();
            }
        },
        methods: {
            //报名
            activityReport() {
                this.reportFrom.activityId = this.detailId
                activityReport(this.reportFrom).then(res => {
                    if (res.statusCode === 200) {
                        this.reportBtn = true;
                        uni.showToast({
                            title: res.data.msg, // 提示文字
                            icon: 'success', // 图标类型(success/loading/none)
                            mask: true // 是否显示透明蒙层(防止触摸穿透)
                        });
                    }
                    
                })
            },
            getPreviewUrl(params){
                return getPreviewUrl(params);
            },
            getActivityDetail(id) {
                uni.showLoading({
                    title: '加载中'
                });
                getActivityDetail(id).then(res => {
                    uni.hideLoading();
                    if (res.statusCode === 200) {
                        //赋值
                        this.activityInfo.coverType = res.data.data.coverType;
                        this.activityInfo.cover = res.data.data.cover;
                        this.activityInfo.activityName = res.data.data.activityName;
                        this.activityInfo.startTime = res.data.data.startTime;
                        this.activityInfo.endTime = res.data.data.endTime;
                        this.activityInfo.activityLocation = res.data.data.activityLocation;
                        this.activityInfo.activityContent = '<h2>活动介绍</h2>' + '<p>' + res.data.data.activityContent  + '</p>';
                        this.activityInfo.activityType = res.data.data.activityType;
                        this.activityInfo.limitUserNum = res.data.data.limitUserNum;
                        this.reportBtn = res.data.data.isReport;
                        
                    }
                })
            },
            loadDetailData() {
 
                //获得详情接口
                this.getActivityDetail(this.detailId);
 
 
 
            }
        }
    };
</script>
<style lang="scss">
    /* 封面容器 */
    .cover-container {
      position: relative;
      width: 100%;
      height: 400rpx;
      overflow: hidden;
      background-color: #f5f5f5;
    }
    
    /* 图片/视频封面样式 */
    .activity-cover {
      width: 100%;
      height: 100%;
      border-radius: 0; /* 与列表页保持一致 */
    }
    
    /* 文字封面样式 - 与列表页保持一致 */
    .text-cover {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
      padding: 40rpx;
    }
    
    .cover-text {
      color: #fff;
      font-size: 36rpx;
      font-weight: bold;
      text-align: center;
      line-height: 1.4;
      text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.2);
    }
    .header-image {
        width: 100%;
        height: 400rpx;
    }
 
    .info-section {
        padding: 30rpx;
        background: #fff;
        margin-top: 20rpx;
    }
 
    .title {
        font-size: 40rpx;
        font-weight: bold;
        color: #333;
        display: block;
        margin-bottom: 20rpx;
    }
 
    .meta-info {
        margin-bottom: 20rpx;
        color: #666;
    }
 
    .time {
        margin-right: 30rpx;
    }
 
    .tags {
        display: flex;
        flex-wrap: wrap;
        margin-top: 20rpx;
    }
 
    .tag {
        font-size: 24rpx;
        padding: 8rpx 20rpx;
        background: #f0f0f0;
        border-radius: 30rpx;
        margin-right: 15rpx;
        margin-bottom: 15rpx;
    }
 
    .status-bar {
        padding: 25rpx 30rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #fff;
        font-size: 28rpx;
        margin: 20rpx 0;
    }
 
    .signup-btn {
        background: #fff;
        color: #2196F3;
        padding: 10rpx 30rpx;
        border-radius: 50rpx;
        font-size: 28rpx;
    }
 
    .content-section {
        padding: 30rpx;
        background: #fff;
        margin-top: 20rpx;
    }
 
    .footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 100rpx;
        background: #fff;
        display: flex;
        justify-content: space-around;
        align-items: center;
        border-top: 1rpx solid #eee;
        padding: 20rpx 0;
    }
 
    .footer-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 24rpx;
        color: #666;
    }
 
    .footer-icon {
        width: 40rpx;
        height: 40rpx;
        margin-bottom: 10rpx;
    }
</style>