liujie
6 天以前 0b982ca67a35defc06d279740749948e9ec20f6a
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
@layout("/common/_container.html"){
<style>
    div#basicInfoContent input {
        pointer-events: none;
    }
    select {
        pointer-events: none;
    }
    textarea {
        pointer-events: none;
    }
</style>
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal">
            <div class="row">
                <div class="col-sm-12">
                    <input type="hidden" id="id" value="${item.id}"/>
                    
                    <!-- 活动状态展示区域 -->
                    <div class="form-group">
                        <div class="col-sm-12">
                            @if(item.auditStatus == 0) {
                                <!-- 待审核状态 -->
                                <div class="alert alert-warning" style="margin-bottom: 20px;">
                                    <h4><i class="fa fa-clock-o"></i> 等待平台审核</h4>
                                </div>
                            @} else if(item.auditStatus == 2) {
                                <!-- 审核驳回状态 -->
                                <div class="alert alert-danger" style="margin-bottom: 20px;">
                                    <h4><i class="fa fa-times-circle"></i> 平台驳回</h4>
                                    <p style="margin-top: 10px; font-weight: bold;">驳回原因:${item.rejectReason!'未填写'}</p>
                                    @if(isNotEmpty(item.auditTime)) {
                                        <p style="margin-top: 5px; color: #666;">审核时间:${item.auditTimeFormat}</p>
                                    @}
                                </div>
                            @} else if(item.auditStatus == 1 && item.activityStatus == 0) {
                                <!-- 审核通过等待开始 -->
                                <div class="alert alert-success" style="margin-bottom: 20px;">
                                    <h4><i class="fa fa-check-circle"></i> 已通过,等待活动开始</h4>
                                    @if(isNotEmpty(item.auditTime)) {
                                        <p style="margin-top: 5px; color: #666;">审核时间:${item.auditTimeFormat}</p>
                                    @}
                                </div>
                            @} else if(item.auditStatus == 1 && (item.activityStatus == 1 || item.activityStatus == 2 || item.activityStatus == 3)) {
                                <!-- 活动进行中/已结束/已暂停状态,显示Switch -->
                                <div style="margin-bottom: 20px;">
                                    <div class="btn-group" role="group" aria-label="活动信息切换">
                                        <button type="button" class="btn btn-primary" id="basicInfoBtn" onclick="switchActivityInfo('basic')" style="background-color: #337ab7; color: white;">
                                            活动基本信息
                                        </button>
                                        <button type="button" class="btn btn-default" id="dataInfoBtn" onclick="switchActivityInfo('data')" style="background-color: white; color: black;">
                                            活动数据
                                        </button>
                                    </div>
                                </div>
                            @}
                        </div>
                    </div>
                    
                    <!-- 活动基本信息内容区域 -->
                    <div id="basicInfoContent">
                        <div class="form-group">
                            <label class="control-label col-sm-1" for="name" style="text-align: left"><span style="color: red">*</span>活动名称:</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="name" placeholder="请输入活动名称" maxlength="20" value="${item.name}" required>
                            </div>
                            @if(item.auditStatus == 1 && item.activityStatus == 1) {
                                <!-- 活动进行中时显示二维码 -->
                                <label class="control-label col-sm-1" style="text-align: left">活动二维码:</label>
                                <div class="col-sm-4">
                                    <div style="display: flex; align-items: center;">
                                        @if(isNotEmpty(item.qrCode)) {
                                            <img src="${item.qrCode}" style="width: 60px; height: 60px; border: 1px solid #ddd; margin-right: 10px;" alt="活动二维码" />
                                            <button type="button" class="btn btn-sm btn-info" onclick="TCheckCarActivityDetail.openQrPage('${item.qrCode}')">
                                                查看活动二维码
                                            </button>
                                        @} else {
                                            <span style="color: #999;">暂无二维码</span>
                                        @}
                                    </div>
                                </div>
                            @}
                        </div>
                    <div class="form-group">
                        <label class="control-label col-sm-1" for="startTime" style="text-align: left"><span style="color: red">*</span>活动时间范围:</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="startTime" placeholder="请选择日期范围" value="${item.timeRange}" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-1" style="text-align: left"><span style="color: red">*</span>活动区域:</label>
                        <div class="col-sm-3">
                            <select class="form-control" id="province" onchange="TCheckCarActivityInfoDlg.provinceChange(this)">
                                <option value="">选择省</option>
                                @for(obj in provinceList){
                                <option value="${obj.provinceCode}" ${item.provinceCode == obj.provinceCode ?
                                'selected' : ''} >${obj.provinceName}</option>
                                @}
                            </select>
                        </div>
                        <div class="col-sm-3">
                            <select class="form-control" id="city" onchange="TCheckCarActivityInfoDlg.cityChange(this)">
                                <option value="">选择市</option>
                                @if(isNotEmpty(cityList)) {
                                    @for(obj in cityList){
                                        <option value="${obj.cityCode}" ${item.cityCode == obj.cityCode ?
                                        'selected' : ''} >${obj.cityName}</option>
                                    @}
                                @}
                            </select>
                        </div>
                        <div class="col-sm-3">
                            <select class="form-control" id="area">
                                <option value="">选择区</option>
                                @if(isNotEmpty(areaList)) {
                                    @for(obj in areaList){
                                <option value="${obj.areaCode}" ${item.districtCode== obj.areaCode ?
                                'selected' : ''} >${obj.areaName}</option>
                                    @}
                                @}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-1" for="couponName" style="text-align: left"><span style="color: red">*</span>优惠券名称:</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="couponName" placeholder="请输入优惠券名称" maxlength="20" value="${item.couponName}" required />
                        </div>
                        <label class="control-label col-sm-1" for="couponNum" style="text-align: left"><span style="color: red">*</span>优惠券数量:</label>
                        <div class="col-sm-4">
                            <input type="number" class="form-control" id="couponNum" placeholder="请输入活动优惠券数量" min="0" value="${item.couponNum}" required />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-1" for="couponAmount" style="text-align: left"><span style="color: red">*</span>优惠券面额:</label>
                        <div class="col-sm-4">
                            <div class="input-group">
                                <input type="number" class="form-control" id="couponAmount" placeholder="请输入优惠券面额" min="0" value="${item.couponAmount}" required>
                                <div class="input-group-addon">元</div>
                            </div>
                        </div>
                        <label class="control-label col-sm-1" for="duration" style="text-align: left"><span style="color: red">*</span>优惠券有效期:</label>
                        <div class="col-sm-4">
                            <div class="input-group">
                                <input type="number" class="form-control" id="duration" placeholder="请输入优惠券有效期" min="0" value="${item.duration}" required>
                                <div class="input-group-addon">天</div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-1" for="explainContent" style="text-align: left"><span style="color: red">*</span>活动内容说明:</label>
                    </div>
                        <div class="form-group">
                            <div class="col-sm-9 col-sm-offset-1">
                                <textarea type="text/plain" id="explainContent" style="width:100%;height:350px;">${item.explainContent}</textarea>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 活动数据内容区域 -->
                    <div id="dataInfoContent" style="display: none;">
                        <!-- 统计数据展示 -->
                        <div class="row">
                            <div class="col-sm-12">
                                <div id="statisticsContainer" style="background-color: #f9f9f9; padding: 20px; margin-bottom: 20px; border-radius: 5px;">
                                    <div class="row">
                                        <div class="col-sm-2">
                                            <div style="text-align: center;">
                                                <div style="font-size: 28px; font-weight: bold; color: #2c3e50;" id="totalCoupons">0</div>
                                                <div style="color: #7f8c8d;">优惠券总计数量</div>
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <div style="text-align: center;">
                                                <div style="font-size: 28px; font-weight: bold; color: #27ae60;" id="receivedCoupons">0</div>
                                                <div style="color: #7f8c8d;">已领取数量</div>
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <div style="text-align: center;">
                                                <div style="font-size: 28px; font-weight: bold; color: #e74c3c;" id="remainingCoupons">0</div>
                                                <div style="color: #7f8c8d;">剩余数量</div>
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <div style="text-align: center;">
                                                <div style="font-size: 28px; font-weight: bold; color: #3498db;" id="totalAmount">¥0</div>
                                                <div style="color: #7f8c8d;">优惠券总计金额</div>
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <div style="text-align: center;">
                                                <div style="font-size: 28px; font-weight: bold; color: #f39c12;" id="usedAmount">¥0</div>
                                                <div style="color: #7f8c8d;">已使用金额</div>
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <div style="text-align: center;">
                                                <div style="font-size: 28px; font-weight: bold; color: #9b59b6;" id="unusedAmount">¥0</div>
                                                <div style="color: #7f8c8d;">未使用金额</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 优惠券领取记录列表 -->
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-title">
                                        <h5>优惠券领取记录</h5>
                                    </div>
                                    <div class="ibox-content">
                                        <!-- 搜索区域 -->
                                        <div class="row" style="margin-bottom: 15px;">
                                            <div class="col-sm-3">
                                                <div class="input-group">
                                                    <input type="text" class="form-control" id="userPhoneSearch" placeholder="请输入手机号搜索" onkeypress="if(event.keyCode==13) TCheckCarActivityDetail.searchRecords()">
                                                    <span class="input-group-btn">
                                                        <button class="btn btn-primary" type="button" onclick="TCheckCarActivityDetail.searchRecords()">
                                                            <i class="fa fa-search"></i> 搜索
                                                        </button>
                                                    </span>
                                                </div>
                                            </div>
                                            <div class="col-sm-2">
                                                <button class="btn btn-default" type="button" onclick="TCheckCarActivityDetail.resetSearch()">
                                                    <i class="fa fa-refresh"></i> 重置
                                                </button>
                                            </div>
                                        </div>
                                        <#table id="ActivityRecordsTable"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
 
            <div class="row btn-group-m-t">
                <div class="col-sm-10 col-sm-offset-1">
                    <#button btnCss="normal" name="关闭" id="cancel" icon="fa-eraser" clickFun="TCheckCarActivityInfoDlg.close()"/>
                </div>
            </div>
        </div>
 
    </div>
</div>
<script src="${ctxPath}/static/modular/system/tCheckCarActivity/tCheckCarActivity_info.js"></script>
<script>
    laydate.render({
        elem: '#startTime',
        range: true,
        trigger: 'click',
        min: 0
    });
    
    // 活动信息切换功能
    function switchActivityInfo(type) {
        var basicBtn = document.getElementById('basicInfoBtn');
        var dataBtn = document.getElementById('dataInfoBtn');
        var basicInfoContent = document.getElementById('basicInfoContent');
        var dataInfoContent = document.getElementById('dataInfoContent');
        
        if (type === 'basic') {
            // 切换到基本信息
            basicBtn.className = 'btn btn-primary';
            basicBtn.style.backgroundColor = '#337ab7';
            basicBtn.style.color = 'white';
            
            dataBtn.className = 'btn btn-default';
            dataBtn.style.backgroundColor = 'white';
            dataBtn.style.color = 'black';
            
            if (basicInfoContent) basicInfoContent.style.display = 'block';
            if (dataInfoContent) dataInfoContent.style.display = 'none';
        } else if (type === 'data') {
            // 切换到活动数据
            dataBtn.className = 'btn btn-primary';
            dataBtn.style.backgroundColor = '#337ab7';
            dataBtn.style.color = 'white';
            
            basicBtn.className = 'btn btn-default';
            basicBtn.style.backgroundColor = 'white';
            basicBtn.style.color = 'black';
            
            if (basicInfoContent) basicInfoContent.style.display = 'none';
            if (dataInfoContent) dataInfoContent.style.display = 'block';
            
            //切换到数据页面时加载数据
            TCheckCarActivityDetail.loadActivityData();
        }
    }
    
    // 详情页面二维码查看对象
    var TCheckCarActivityDetail = {
        layerIndex: -1,
        recordsTable: null,
        
        /**
         * 加载活动数据
         */
        loadActivityData: function() {
            var activityId = $('#id').val();
            this.loadStatistics(activityId);
            this.initRecordsTable(activityId);
        },
        
        /**
         * 加载统计数据
         */
        loadStatistics: function(activityId) {
            var ajax = new $ax(Feng.ctxPath + "/tCheckCarActivity/statistics/" + activityId, function(data) {
                if (data) {
                    $('#totalCoupons').text(data.totalCoupons || 0);
                    $('#receivedCoupons').text(data.receivedCoupons || 0);
                    $('#remainingCoupons').text(data.remainingCoupons || 0);
                    $('#totalAmount').text('¥' + (data.totalAmount || 0));
                    $('#usedAmount').text('¥' + (data.usedAmount || 0));
                    $('#unusedAmount').text('¥' + (data.unusedAmount || 0));
                }
            }, function(data) {
                Feng.error("加载统计数据失败!");
            });
            ajax.start();
        },
        
        /**
         * 初始化记录表格
         */
        initRecordsTable: function(activityId) {
            var columns = [
                {field: 'selectItem', radio: true},
                {title: '用户名', field: 'userName', visible: true, align: 'center', valign: 'middle'},
                {title: '手机号', field: 'userPhone', visible: true, align: 'center', valign: 'middle'},
                {title: '领取时间', field: 'receiveTime', visible: true, align: 'center', valign: 'middle'},
                {title: '当前状态', field: 'status', visible: true, align: 'center', valign: 'middle',
                    formatter: function(value, row, index) {
                    return row.status === 1 ? '已使用' : '未使用';
                    }
                },
                {title: '使用时间', field: 'useTime', visible: true, align: 'center', valign: 'middle'},
                {title: '使用订单号', field: 'checkOrderCode', visible: true, align: 'center', valign: 'middle'}
            ];
            
            var table = new BSTable("ActivityRecordsTable", "/tCheckCarActivity/records/" + activityId, columns);
            table.setPaginationType("server");
            this.recordsTable = table.init();
        },
        
        openQrPage: function (qrCode) {
            // 验证二维码地址
            if (!qrCode || qrCode.trim() === '') {
                Feng.error("二维码地址为空!");
                return;
            }
            
            // 构建弹窗HTML内容
            var qrCodeHtml = '<div style="text-align: center; padding: 20px;">' +
                '<div id="qrcode-container" style="margin-bottom: 20px;">' +
                '<img id="qrcode-img" src="' + qrCode + '" style="width: 300px; height: 300px; border: 1px solid #ddd;" alt="二维码" />' +
                '</div>' +
                '<button id="download-qr-btn" type="button" class="btn btn-primary" style="margin-top: 10px;">' +
                '下载二维码图片</button>' +
                '</div>';
            
            // 打开弹窗
            var index = layer.open({
                type: 1,
                title: '二维码查看',
                area: ['400px', '500px'],
                fix: false,
                maxmin: true,
                content: qrCodeHtml,
                success: function(layero, index) {
                    // 绑定下载按钮事件
                    $('#download-qr-btn').click(function() {
                        TCheckCarActivityDetail.downloadQrCode(qrCode);
                    });
                    
                    // 图片加载失败处理
                    $('#qrcode-img').on('error', function() {
                        $(this).attr('alt', '二维码加载失败');
                        $(this).css({'background-color': '#f5f5f5', 'line-height': '300px'});
                    });
                }
            });
            this.layerIndex = index;
        },
        downloadQrCode: function(qrCode) {
            try {
                if (!qrCode) {
                    Feng.error("二维码地址无效,无法下载!");
                    return;
                }
                
                // 创建下载链接
                var link = document.createElement('a');
                link.download = '二维码_' + new Date().getTime() + '.png';
                link.href = qrCode;
                link.target = '_blank';
                
                // 触发下载
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
                
                Feng.success("二维码图片下载成功!");
            } catch (e) {
                console.error('下载二维码失败:', e);
                Feng.error("下载失败!请重试。");
            }
        },
        
        /**
         * 搜索记录
         */
        searchRecords: function() {
            if (this.recordsTable) {
                var userPhone = $('#userPhoneSearch').val();
                this.recordsTable.refresh({query: {userPhone: userPhone}});
            }
        },
        
        /**
         * 重置搜索
         */
        resetSearch: function() {
            $('#userPhoneSearch').val('');
            if (this.recordsTable) {
                this.searchRecords();
            }
        }
    };
</script>
@}