puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
/**
 * 初始化详情对话框
 */
var couponInfoDlg = {
    couponInfoData: {},
    goodsPicArray: [], //商品图片数组
    goodsCover: '', //商品封面图
    storeIds: [],
};
 
/**
 * 清除数据
 */
couponInfoDlg.clearData = function () {
    this.couponInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
couponInfoDlg.set = function (key, val) {
    this.couponInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
couponInfoDlg.get = function (key) {
    return $("#" + key).val();
}
 
/**
 * 关闭此对话框
 */
couponInfoDlg.close = function () {
    parent.layer.close(window.parent.TCoupon.layerIndex);
}
couponInfoDlg.close1 = function () {
    parent.layer.close(window.parent.TCouponExamine.layerIndex);
}
 
 
/**
 * 兑换方式1
 */
function exchangeMethod1() {
    $("#needAmount").hide();
    $("#needIntegral").show();
    $('#requiredPoints').val('');
    $('#requiredCash').val('');
}
 
/**
 * 兑换方式2
 */
function exchangeMethod2() {
    $("#needAmount").show();
    $("#needIntegral").show();
    $('#requiredPoints').val('');
    $('#requiredCash').val('');
}
 
/**
 * 兑换方式3
 */
function exchangeMethod3() {
    $("#needAmount").show();
    $("#needIntegral").hide();
    $('#requiredPoints').val('');
    $('#requiredCash').val('');
}
 
/**
 * 全国通用
 */
function scopeOfApplication1() {
    $("#storeSelect").hide();
    $("#citySelect").hide();
 
    //移除指定门店的数据:
    // 找到 tbody 元素
    var tbody = document.getElementById("coun");
 
    // 移除所有子元素(即行)
    while (tbody.firstChild) {
        tbody.removeChild(tbody.firstChild);
    }
    couponInfoDlg.storeIds = [];
 
    //移除指城市的数据:
    num = 0;
    var cityDemoDiv = document.getElementById("cityDemo");
 
    cityDemoDiv.innerHTML = ""; // 将内容置为空字符串
    var provinceSelect = document.getElementById("provinceData");
    var cityDataSelect = document.getElementById("cityData");
    provinceSelect.innerHTML = '<option value="">请选择</option>';
    cityDataSelect.innerHTML = '<option value="">请选择</option>';
    getProvince(null);
}
/**
 * 指定城市
 */
function scopeOfApplication2() {
    $("#storeSelect").hide();
    $("#citySelect").show();
 
    //移除指定门店的数据:
    // 找到 tbody 元素
    var tbody = document.getElementById("coun");
    // 移除所有子元素(即行)
    while (tbody.firstChild) {
        tbody.removeChild(tbody.firstChild);
    }
    couponInfoDlg.storeIds = [];
 
 
 
}
/**
 * 指定门店
 */
function scopeOfApplication3() {
    $("#storeSelect").show();
    $("#citySelect").hide();
 
    //移除指城市的数据:
    num = 0;
    var cityDemoDiv = document.getElementById("cityDemo");
 
    cityDemoDiv.innerHTML = ""; // 将内容置为空字符串
    var provinceSelect = document.getElementById("provinceData");
    var cityDataSelect = document.getElementById("cityData");
    provinceSelect.innerHTML = '<option value="">请选择</option>';
    cityDataSelect.innerHTML = '<option value="">请选择</option>';
    getProvince(null);
 
 
}
 
/**
 * 满减券
 */
function radio1() {
    $("#conditionalAmount").removeAttr("disabled");
    $("#deductionAmount").removeAttr("disabled");
 
    $("#voucherAmount").val('')
    $("#voucherAmount").attr('disabled', 'disabled');
 
    $("#experienceName").val('')
    $("#experienceName").attr('disabled', 'disabled');
}
 
/**
 * 代金券
 */
function radio2() {
    $("#voucherAmount").removeAttr("disabled");
 
    $("#conditionalAmount").val('')
    $("#deductionAmount").val('')
    $("#deductionAmount").attr('disabled', 'disabled');
    $("#conditionalAmount").attr('disabled', 'disabled');
 
    $("#experienceName").val('')
    $("#experienceName").attr('disabled', 'disabled');
 
}
 
/**
 * 体验券
 */
function radio3() {
    $("#experienceName").removeAttr("disabled");
 
    $("#conditionalAmount").val('')
    $("#deductionAmount").val('')
    $("#deductionAmount").attr('disabled', 'disabled');
    $("#conditionalAmount").attr('disabled', 'disabled');
 
    $("#voucherAmount").val('')
    $("#voucherAmount").attr('disabled', 'disabled');
 
}
 
 
function changeCity(n){
 
    var provinceSelect = null;
    if (n === undefined || n === null || n === ''){
        provinceSelect = document.getElementById("provinceData");
    }else {
        provinceSelect = document.getElementById("provinceData"+n);
    }
 
    var citySelect = null;
    if (n === undefined || n === null || n === ''){
        citySelect = document.getElementById("cityData");
    }else {
        citySelect = document.getElementById("cityData"+n);
    }
 
    var selectedProvince = provinceSelect.value;
    // 清空城市下拉框
    citySelect.innerHTML = '<option value="">请选择</option>';
    if (selectedProvince === "") {
        return;
    }
    var ajax = new $ax(Feng.ctxPath + "/tCouponManage/getCity", function(data){
        data.forEach(province => {
            var option = document.createElement("option");
            option.value = province.id;  // 根据你的数据结构确定省份的id字段
            option.text = province.name;  // 根据你的数据结构确定省份的name字段
            citySelect.appendChild(option);
        });
    },function(data){
        console.log('data:',data)
        Feng.error("获取失败!" + data.responseJSON.message + "!");
    });
    ajax.set('province',selectedProvince);
    ajax.start();
}
 
function getProvince(n){
    var ajax = new $ax(Feng.ctxPath + "/tCouponManage/getProvince", function(data){
        var provinceSelect = null;
        if (n === undefined || n === null || ''){
            provinceSelect = document.getElementById("provinceData");
        }else {
            provinceSelect = document.getElementById("provinceData"+n);
        }
        data.forEach(province => {
            var option = document.createElement("option");
            option.value = province.id;  // 根据你的数据结构确定省份的id字段
            option.text = province.name;  // 根据你的数据结构确定省份的name字段
            provinceSelect.appendChild(option);
        });
    },function(data){
        Feng.error("下拉失败!" + data.responseJSON.message + "!");
    });
    ajax.start();
}
 
function storeList(){
    var index = layer.open({
        type: 2,
        title: '门店列表',
        area: ['80%', '80%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tCouponManage/storeList'
    });
    this.layerIndex = index;
}
 
 
let num = 0;
couponInfoDlg.addBranch = function () {
    num = num+1;
    var a= "";
    a = "<div style=\'margin-left: 25%\' class=\"col-sm-9 control-label\">\n" +
        "                            <select class=\"col-sm-1\"  id=\'provinceData"+num+"\' style=\"margin-top: 1%;width: 25%\" onchange=\'changeCity("+num+")\'>\n" +
        "                                <option value=\"\">请选择</option>\n" +
        "                            </select>\n" +
        "                            <label class=\"col-sm-1\"  style=\"width: 9%;margin-top: 7px\">省</label>\n" +
        "                            <select  class=\"col-sm-1\" style=\"margin-top: 1%;width: 25%\" id=\'cityData"+num+"\'>\n" +
        "                                <option value=\"\">请选择</option>\n" +
        "                            </select>\n" +
        "                            <label class=\"col-sm-1\" style=\"width: 7%;margin-top: 7px\">市</label>\n" +
        "                            <label name=\"addBranch\" class=\"col-sm-1\" onclick=\"couponInfoDlg.delete(this)\" style=\"border: 0px;cursor: pointer;margin-top: 1%\"><i class=\"fa fa-trash\"></i></label>"+
        "                        </div>";
    $("#cityDemo").append($(a));
    getProvince(num);
}
 
 
couponInfoDlg.selecUserOpt = function (arrays){
    //获取所有的值
    var subArr= this.storeIds;
    $(".timeClass").each(function () {
        subArr.push($(this).find("input[name*='id']").val());
    });
    var str = '';
    for(var i in arrays){
        var b = true;
        for(var j in subArr){
            if(arrays[i].id === Number(subArr[j])){
                b = false;
                break
            }
        }
        if(b){
            str += '<tr class="timeClass">' +
                '<td><input type="hidden" id="id" name="id" value="'+arrays[i].id+'"><input type="hidden" id="provinceCity" name="provinceCity" value="'+arrays[i].provinceCity+'">' + arrays[i].provinceCity + '</td>' +
                '<td><input type="hidden" id="accountName" name="accountName" value="'+arrays[i].accountName+'">' + arrays[i].accountName + '</td>' +
                '<td><input type="hidden" id="name" name="name" value="'+arrays[i].name+'">' + arrays[i].name + '</td><td><button onclick="deleteSub(this)">移除</button></td></tr>';
            this.storeIds.push(arrays[i].id);
        }
    }
    $("#coun").append(str);
}
 
function deleteSub(e) {
    var row = $(e).closest('tr');
    var value = row.find('#id').val();
    couponInfoDlg.storeIds.splice(couponInfoDlg.storeIds.indexOf(parseInt(value)), 1)
    $(e).parent().parent().remove();
}
 
 
couponInfoDlg.delete = function (o) {
    $(o).parent("div").remove()
}
couponInfoDlg.audit = function () {
    var id = $("#id").val();
    var state = $("#state").val();
    console.log("让我看看state")
    console.log(state)
    if (state == "未通过"){
        Feng.error("当前优惠券不可再次审核!");
        return ;
    }
    let audit = document.querySelector('input[name="r1"]:checked').value;
    let text = $("#text").val()
    if(audit==3){
        if(text==''){
            Feng.info("请输入拒绝理由")
            return false;
        }
    }
    var ajax = new $ax(Feng.ctxPath + "/tCouponExamine/examine", function (data) {
        if (data.code == 200) {
            Feng.success("操作成功!");
 
            window.parent.TCouponExamine.table.refresh();
            couponInfoDlg.close1();
        } else if(data=="repeat"){
            window.location.reload();
            window.parent.layer.closeAll();
            Feng.error("请勿重复操作");
        }else {
            return  Feng.error(data.msg);
        }
    }, function (data) {
        Feng.error("操作失败!")
        window.location.reload();
        window.parent.layer.closeAll();
        return   Feng.error("操作失败!");
    });
 
    ajax.set("id", id);
    ajax.set("state", audit);
    ajax.set("remark", text);
    ajax.start();
    layer.closeAll();
}
/**
 * 提交
 */
couponInfoDlg.addSubmit = function () {
 
    var cityIds = [];
    // 优惠券名称
    var couponName = $('#name').val();
    if (couponName === undefined || couponName === '' || couponName === null){
        return Feng.error('优惠券名称不能为空');
    }
    // 优惠券类型
    let prescription = $(":radio[name='prescription']:checked").val();
    // 满xx金额
    let conditionalAmount = $('#conditionalAmount').val();
    // 减xx金额
    let deductionAmount = $('#deductionAmount').val();
    // 可抵扣xx金额
    let voucherAmount = $('#voucherAmount').val();
    // 体验券名称
    let experienceName = $('#experienceName').val();
    if (prescription === '1'){
        if (conditionalAmount === undefined || conditionalAmount === '' || conditionalAmount === null){
            return Feng.error('条件金额不能为空');
        }
        if (deductionAmount === undefined || deductionAmount === '' || deductionAmount === null){
            return Feng.error('减扣金额不能为空');
        }
    }
    if (prescription === '2'){
        if (voucherAmount === undefined || voucherAmount === '' || voucherAmount === null){
            return Feng.error('抵扣金额不能为空');
        }
    }
    if (prescription === '3'){
        if (experienceName === undefined || experienceName === '' || experienceName === null){
            return Feng.error('体验券名称不能为空');
        }
    }
 
 
    if ($('#userType').val()==1) {
        // 说明
        var illustrate = $('#illustrate').val();
        if (illustrate === undefined || illustrate === '' || illustrate === null) {
            return Feng.error('优惠券说明不能为空');
        }
    }
    // 发放方式
    let distributionMethod = $(":radio[name='distributionMethod']:checked").val();
    if (distributionMethod === undefined || distributionMethod === '' || distributionMethod === null){
        return Feng.error('发放方式不能为空');
    }
    // 所需积分
    var requiredPoints = $('#requiredPoints').val();
    // 所需现金
    var requiredCash = $('#requiredCash').val();
    // 用户人群
    let userGroup = $(':radio[name="userGroup"]:checked').val();
 
    // 发放数量
    var quantityIssued = $('#quantityIssued').val();
    if (quantityIssued === undefined || quantityIssued === '' || quantityIssued === null){
        return Feng.error('发放数量不能为空');
    }
    // 限领数量
    var pickUpQuantity = $('#pickUpQuantity').val();
    if (pickUpQuantity === undefined || pickUpQuantity === '' || pickUpQuantity === null){
        return Feng.error('限领数量不能为空');
    }
    // 有效期
    var periodOfValidity = $('#periodOfValidity').val();
    if (periodOfValidity === undefined || periodOfValidity === '' || periodOfValidity === null){
        return Feng.error('有效期不能为空');
    }
    if ($('#userType').val()==1){
    // 兑换方式
    let exchangeMethod = $(':radio[name="exchangeMethod"]:checked').val();
        console.log("看看exchangeMethod")
        console.log(exchangeMethod)
    if (distributionMethod === '1') {
        if (exchangeMethod === '' || exchangeMethod === undefined || exchangeMethod === null) {
            return Feng.error('兑换方式不能为空');
        }
    }
    if (exchangeMethod === '1' ){
        if (requiredPoints === undefined || requiredPoints === '' || requiredPoints === null){
            return Feng.error('所需积分不能为空');
        }
    }
    if (exchangeMethod === '2' && distributionMethod === '1'){
        if (requiredPoints === undefined || requiredPoints === '' || requiredPoints === null){
            return Feng.error('所需积分不能为空');
        }
        if (requiredCash === undefined || requiredCash === '' || requiredCash === null){
            return Feng.error('所需现金不能为空');
        }
    }
    if (exchangeMethod === '3' && distributionMethod === '1'){
        if (requiredCash === undefined || requiredCash === '' || requiredCash === null){
            return Feng.error('所需现金不能为空');
        }
    }
    }
    let company = $(':radio[name="company"]:checked').val();
    var cts = "";
    if ($('#userType').val()==1) {
        if (company === '2') {
            var myselect = document.getElementById('cityData');
            var seCity = myselect.options[myselect.selectedIndex].value;
            if (seCity === null || seCity === undefined || seCity === '') {
                return Feng.error('请选中一个省市');
            }
            cityIds.push(seCity);
            if (num > 0) {
                for (let i = 1; i <= num; i++) {
                    var insSelect = document.getElementById('cityData' + i);
                    var inData = insSelect.options[insSelect.selectedIndex].value;
                    if (inData !== undefined || inData !== null || inData !== '') {
                        cityIds.push(inData);
                    }
                }
            }
            cts = cityIds.join(',');
            console.log("============到达城市"+cts)
 
        }
 
    }
    const commaSeparatedString = this.goodsPicArray.join(',');
 
    var stores = "";
    if (company === '3'){
        console.log('3---this.storeIds',this.storeIds);
        if (couponInfoDlg.storeIds.length === 0 ){
            return Feng.error('请至少选择一个门店');
        }
        stores = this.storeIds.join(',');
        console.log('stores--===--',stores)
    }
 
    var ensure = document.getElementById("ensure");
    ensure.disabled = true;
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tCouponManage/commitData", function (data) {
        ensure.disabled = false;
        Feng.success("添加成功!");
        window.parent.TCoupon.table.refresh();
        couponInfoDlg.close();
    }, function (data) {
        ensure.disabled = false;
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set("userType",$('#userType').val());
    ajax.set("cityManagerId",0);
    ajax.set("couponName",couponName);
    ajax.set("prescription",prescription);
    ajax.set("condition",conditionalAmount);
    ajax.set("subtraction",deductionAmount);
    ajax.set("discount",voucherAmount);
    ajax.set("experience",experienceName);
    var illustrate = $('#illustrate').val();
    ajax.set("illustrate",illustrate);
    ajax.set("distributionMethod",distributionMethod);
    ajax.set("requiredPoints",requiredPoints);
    ajax.set("requiredCash",requiredCash);
    ajax.set("userGroup",userGroup);
    ajax.set("quantityIssued",quantityIssued);
    ajax.set("pickUpQuantity",pickUpQuantity);
    ajax.set("periodOfValidity",periodOfValidity);
 
    if ($('#userType').val()==2) {
        ajax.set("exchangeMethod",1);
    }else{
        let exchangeMethod = $(':radio[name="exchangeMethod"]:checked').val();
        ajax.set("exchangeMethod",exchangeMethod);
    }
    ajax.set("goodImg",this.goodsCover);
    ajax.set("goodImgs",commaSeparatedString);
    ajax.set("company",company);
    ajax.set("cityIds",cts);
    ajax.set("storeIds",stores);
    ajax.start();
 
}
 
/**
 * 收集数据
 */
couponInfoDlg.collectData = function () {
    this
        .set('couponId')
        .set('name')
        .set('type')
        .set('typeName')
        .set('times')
        .set('sheetsNum')
        .set('auditStatus')
        .set('reason')
        .set('remark')
        .set('startTime')
        .set('endTime')
        .set('activityId')
        .set('createId')
        .set('createTime')
        .set('timeType')
        .set('expDay')
        .set('couponCode')
        .set('instructions')
        .set('belongs')
        .set('useTimes');
}
 
 
$(function () {
 
    getProvince(null);
    radio1();
    var OBJradio = document.getElementsByName("prescription")
    for (i = 0; i < OBJradio.length; i++) {//循环查找这个radio
        if ($("#t1").val() == OBJradio[i].value) {//判断是否与radio的值相同
            OBJradio[i].checked = true//修改选中状态
        }
    }
 
    var OBJradio = document.getElementsByName("distributionMethod")
    for (i = 0; i < OBJradio.length; i++) {//循环查找这个radio
        if ($("#t2").val() == OBJradio[i].value) {//判断是否与radio的值相同
            OBJradio[i].checked = true//修改选中状态
        }
    }
    var OBJradio = document.getElementsByName("exchangeMethod")
    for (i = 0; i < OBJradio.length; i++) {//循环查找这个radio
        if ($("#t3").val() == OBJradio[i].value) {//判断是否与radio的值相同
            OBJradio[i].checked = true//修改选中状态
        }
    }
    var OBJradio = document.getElementsByName("userGroup")
    for (i = 0; i < OBJradio.length; i++) {//循环查找这个radio
        if ($("#t4").val() == OBJradio[i].value) {//判断是否与radio的值相同
            OBJradio[i].checked = true//修改选中状态
        }
    }
    var OBJradio = document.getElementsByName("company")
    for (i = 0; i < OBJradio.length; i++) {//循环查找这个radio
        if ($("#t5").val() == OBJradio[i].value) {//判断是否与radio的值相同
            OBJradio[i].checked = true//修改选中状态
        }
    }
    if($("#t5").val() ==2){
        $("#citySelect").show();
    }
    if($("#t5").val() ==3){
        $("#storeSelect").show();
    }
    if($("#t1").val()==1){
        console.log(1)
        $("#conditionalAmount").val($("#one").val())
        $("#deductionAmount").val($("#two").val())
    }
    if($("#t1").val()==2){
        radio2()
        $("#voucherAmount").val($("#one").val())
    }
    if($("#t1").val()==3){
        console.log(3)
        $("#experienceName").val($("#three").val())
    }
 
    var userType = $('#userType').val();
    if (userType === '1'){
        // 兑换方式
        $('#exchangeType').show();
        $('#needAmount').show();
        $('#needIntegral').show();
        // 图片
        $('#app').show();
        $('#app1').show();
        // 适用范围
        $('#belongsCon').show();
        $('#belongsNationwide').show();
        $('#belongsCity').show();
        $('#belongsStore').show();
    }
    if (userType === '2'){
        $('#needIntegral').show();
        $('#belongsCon').show();
        $('#belongsStore').show();
        $('#storeSelect').show();
    }
    if (userType === '3'){
        // 兑换方式
        $('#exchangeType').show();
        $('#needAmount').show();
        $('#needIntegral').show();
        // 图片
        $('#app').show();
        $('#app1').show();
        // 适用范围
    }
 
 
 
 
    const distributionMethodOptions = document.getElementsByName('distributionMethod');
 
// 监听distributionMethod选项的变化
    for (let i = 0; i < distributionMethodOptions.length; i++) {
        distributionMethodOptions[i].addEventListener('change', function() {
            // 获取选中的distributionMethod值
            const selectedDistributionMethod = document.querySelector('input[name="distributionMethod"]:checked').value;
            console.log("看看选择")
            console.log(selectedDistributionMethod);
            // 判断选中的值是否不等于1
            if (selectedDistributionMethod !== '1') {
                console.log("已经选择1")
                // 隐藏exchangeType
                document.getElementById('exchangeType').style.display = 'none';
                document.getElementById('needAmount').style.display = 'none';
                document.getElementById('needIntegral').style.display = 'none';
            } else {
                // 显示exchangeType
                document.getElementById('exchangeType').style.display = 'block';
                document.getElementById('needAmount').style.display = 'block';
                document.getElementById('needIntegral').style.display = 'block';
            }
            // 如果选择发放方式为注册赠送
            if (selectedDistributionMethod == "2"){
                const userGroupRadios = document.querySelectorAll('input[name="userGroup"][value="1"], input[name="userGroup"][value="3"]');
                console.log("看看要隐藏的")
                console.log(userGroupRadios)
                // 隐藏值为 1 或 2 的 radio 按钮,并显示值为 2 的 radio 按钮
                userGroupRadios.forEach(userRadio => {
                    console.log("隐藏啊")
                    userRadio.style.display = 'none';
                });
                $('#u1').hide();
                $('#u3').hide();
                const userGroupTwo = document.querySelector('input[name="userGroup"][value="2"]');
                userGroupTwo.style.display = 'inline-block';
                userGroupTwo.checked = true;
            }else{
                // 如果选择的不是值为 2 的 radio 按钮,则显示所有的 userGroup radio 按钮
                const userGroupRadios = document.querySelectorAll('input[name="userGroup"]');
                userGroupRadios.forEach(userRadio => {
                    userRadio.style.display = 'inline-block';
                });
                const userGroupTwo = document.querySelector('input[name="userGroup"][value="1"]');
                userGroupTwo.style.display = 'inline-block';
                userGroupTwo.checked = true;
                $('#u1').show();
                $('#u3').show();
            }
        });
    }
 
 
 
});