index.js
28.7 KB
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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
// scanGroup/jyScan/index/index.js
import config from "../../../utils/config.js"
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
marqueeStyle: '',
marqueeStyle1: '',
marqueeList: [],
userId: null,
pageData: null,
scanRewardVO: null,
subGoodsVOS: [],
ruleShow: false,
alertShow: false,
alertText: '',
alertInfo: '',
alertTime: "",
showCouponComMess: false,
isFormFilled: false,
isOneReward: true, //均瑶只有一种666元红包需要完善信息,且三种信息都需要
submitForm: {
name: null,
phone: null,
idCard: null,
},
receiveVis: false,
received: false,
isNoAward: false, //没有中奖的情况
showRedPack: false, //红包
showCodeSituation: false, //二维码活动情况
txt: "",
showSecondRedPack: false, //待解锁红包
secondRedPackBg: 'https://hbrand.oss-cn-hangzhou.aliyuncs.com/cpp/jyScan/second_bg1.png',
excitationRedPack: false, //激励红包
groupRule: '<p style="text-align:center;">\n\t消费者声明及活动详细规则\n</p>\n<p>\n\t请在参与本活动前仔细阅读本活动的各项条款,如果您参加了本活动,则活动主办方认为您已充分理解并同意该规则中的各条款:\n</p>\n<ol>\n\t<li>\n\t\t活动主办方及其联系方式:\n\t</li>\n</ol>\n<p style="text-indent:24px;">\n\t均瑶集团上海食品有限公司(以下简称“主办方”)\n</p>\n<p style="text-indent:24px;">\n\t联系电话:021-60251969(话费自理,工作日:9:00-12:00,13:30-18:00)\n</p>\n<ol>\n\t<li>\n\t\t活动期间及兑奖时间:\n\t</li>\n</ol>\n<p style="text-indent:24px;">\n\t即日起至2026年4月30日23:59:59截止。\n</p>\n<p style="text-indent:24px;">\n\t为充分保障中奖者权益,兑奖时间为即日起至2026年5月1日23:59:59截止,逾期视为自动放弃兑奖。\n</p>\n<ol>\n\t<li>\n\t\t活动区域:\n\t</li>\n</ol>\n<p style="text-indent:24px;">\n\t仅限中国大陆地区(不含港、澳、台)\n</p>\n<ol>\n\t<li>\n\t\t活动参与条件及参与方式:\n\t</li>\n</ol>\n<p style="text-indent:28px;">\n\t即日起,凡购买“扫码赢红包”味动力AD钙奶饮品(2个口味),揭开活动产品包装上活动标签(因其包装设计二维码于瓶盖内,故为揭开瓶盖,敬请谅解),微信扫描其内二维码,进入活动小程序,根据提示完成授权或登陆即可参与活动。参与活动的消费者有机会赢取666元微信红包一份、1.8元微信红包一份或0.6元微信红包一份;同时,还有机会获得复购奖励“1.8元复购红包”,获得复购奖励后再买一瓶活动产品并扫描再次购买的活动产品瓶盖内二维码后即可解锁领取1.8元现金红包,复购奖励数量有限,发完即止。\n</p>\n<ol>\n\t<li>\n\t\t开奖方式与开奖时间:\n\t</li>\n</ol>\n<p>\n\t 参与活动后,根据微信平台活动小程序页面提示,手机扫码即时开奖,若显示中奖,则线上即时领取红包即可。\n</p>\n<ol>\n\t<li>\n\t\t奖项种类设置:\n\t</li>\n</ol>\n<p style="text-indent:24px;">\n\t本活动奖项种类分为常规抽奖与复购奖励。\n</p>\n<ol>\n\t<li>\n\t\t其中常规抽奖设立奖品价格、奖品品名、奖品种类、奖品数量及中奖概率如下:\n\t</li>\n</ol>\n<p style="text-indent:24px;">\n\t一等奖:666元微信现金红包一份,价值人民币六百六十六元,本活动共设18份;中奖概率约为0.0039%\n</p>\n<p style="text-indent:24px;">\n\t二等奖:1.8元微信现金红包一份,价值人民币一元八角,本活动共设6,000份;中奖概率约为1.33%\n</p>\n<p style="text-indent:24px;">\n\t三等奖:0.6元微信现金红包一份,价值人民币八角,本活动共设80,000份;中奖概率约为17.78%\n</p>\n<p style="text-indent:24px;">\n\t其余未中奖将出现“谢谢惠顾”字样。\n</p>\n<p style="text-indent:24px;">\n\t*各奖项中奖率无法整除,谨请谅解。\n</p>\n<ol>\n\t<li>\n\t\t复购奖励设立奖品价格、奖品品名、奖品种类、奖品数量如下:\n\t</li>\n</ol>\n<p style="text-indent:24px;">\n\t复购奖励:人民币1.8元微信现金红包一份,价值人民币壹元捌角,共30,000份,数量有限,先到先得,发完即止。\n</p>\n<ol>\n\t<li>\n\t\t兑奖条件、兑奖方式及奖品交付方式:\n\t</li>\n</ol>\n<p style="text-indent:24px;">\n\t微信扫描活动产品包装上活动标签后,按手机页面提示操作进行兑奖。\n</p>\n<ol>\n\t<li>\n\t\t常规抽奖兑换方式、兑奖方式及奖品交付方式如下:\n\t</li>\n</ol>\n<ol>\n\t<li>\n\t\t如若抽中一等奖666元,需要完善中奖者姓名、身份证、手机号信息并确认提交即可兑奖。提请注意:因微信平台对商家转账到零钱的单笔提现金额上限至200元,即该奖项到账微信钱包时会自动拆分成4笔同时到中奖者微信账户余额;\n\t</li>\n\t<li>\n\t\t如若抽中二等奖1.8元/三等奖0.8元,点击领取即可兑奖,不需要完善中奖者信息;所得现金红包将存入本人微信账户,可在历史中奖记录中查看。\n\t</li>\n</ol>\n<ol>\n\t<li>\n\t\t复购奖励兑换方式、兑奖方式及奖品交付方式如下:\n\t</li>\n</ol>\n<p>\n\t 如若抽中复购奖励,复购奖励中奖者再买一瓶活动产品并点击活动页面中的“扫码激活”扫描再次购买的活动产品瓶盖内二维码后点击领取即可兑奖,不需要完善中奖者信息;所得现金红包将自动存入本人微信账户,可在历史中奖记录中查看。\n</p>\n<p style="text-indent:24px;">\n\t红包提现需遵守腾讯公司微信红包提现规则,由系统自动发放,转账延时属正常情况。本次活动所产生的个人所得税由均瑶集团上海食品有限公司依法代扣代缴,现金红包均为税后所得。\n</p>\n<ol>\n\t<li>\n\t\t活动声明、弃奖条件及注意事项:\n\t</li>\n</ol>\n<ol>\n\t<li>\n\t\t均瑶集团上海食品有限公司对活动产品真实性及有效性具有鉴定及确认权。\n\t</li>\n\t<li>\n\t\t本次活动产品总计投入2,250,000份,每个活动产品二维码只可参与一次抽奖活动,重复扫码无效。\n\t</li>\n\t<li>\n\t\t为保证活动参与体验,主办方将检测活动消费者所提交的相关数据以确保真实性。若检测出消费者有恶意或者虚假刷单行为,主办方有权取消其参加本次活动资格。提请注意:每个微信OpenID活动期间日参与次数限6次,超过参与次数后限制参与,并提示微信号参与已达日上限。消费者可以次日零点后再扫码参与。\n\t</li>\n\t<li>\n\t\t现金红包须在兑奖截止日期前(如需完善相关信息应当在兑换有效期内完善并正确)完成兑奖,过期视为弃奖,主办方不予补发。\n\t</li>\n\t<li>\n\t\t复购奖励中奖者,若未在中奖后72小时内再次购买活动产品并扫描再次购买的活动产品瓶盖内二维码的,视为弃奖。\n\t</li>\n\t<li>\n\t\t消费者应当在活动期间内参与活动并在兑奖期间内完成兑奖,否则视为弃奖。\n\t</li>\n\t<li>\n\t\t活动主办方不对因网络传输原因而导致消费者提交的信息错误或延误承担任何责任。\n\t</li>\n\t<li>\n\t\t消费者领奖过程中所发生的个人费用(包含但不限于上网费、手机流量费、短信费、咨询客服电话费)需自理,主办方不做任何形式的补偿。本活动对象为以消费为目的的消费者,禁止非真实活动参与者的刷单行为,活动参与者不遵守活动规则的,主办方有权根据法律法规及活动规则不予兑换/追回已兑换活动奖品,并且主办方保留追究无参与资格者一切法律责任的权力。\n\t</li>\n\t<li>\n\t\t若因消费者个人原因造成账号、密码遗失,并导致参与活动兑奖的消费者无法提交个人信息的情况,活动主办方不承担责任。\n\t</li>\n\t<li>\n\t\t如发现消费者恶意刷奖行为,包括但不限于:入侵本次活动所使用的网络服务器、使用技术手段获取活动后台信息或篡改活动后台中奖规则、参与记录不符合活动的最低参与要求、盗用他人信息参与活动、冒充他人获得红包等不正当行为,主办方有权取消其活动参与权和收回其所得红包。同时保留依法追究其法律责任的权利。\n\t</li>\n\t<li>\n\t\t活动过程中出现“不可抗力”事件或计算机系统故障直接或间接地造成活动主办方无法履行其全部或部分义务,则活动主办方将免予履行该义务,并无需承担相应的责任。“不可抗力”事件包括但不限于,地震、台风、火灾、水灾、战争、法律法规调整、政府命令禁止、因黑客攻击、计算机病毒影响、系统崩溃、数据丢失或其他人为原因造成计算机系统故障,及其他自然或人为灾害等导致活动无法继续开展的,且活动主办方不可预见、无法避免并无法控制的事件。\n\t</li>\n\t<li>\n\t\t活动过程中,如因政府法律法规调整或行政命令要求,活动主办方有权根据上述调整或要求随时调整活动内容及规则。活动内容及规则调整时,活动主办方将另行向活动参与者公告通知相关的调整,但无需征得活动参与者的同意。主办方有权根据法律法规、司法或行政命令的要求以及活动的实际情况,在法律允许的范围内随时取消、中止或终止此次活动。\n\t</li>\n\t<li>\n\t\t本次活动奖品所涉之相关服务由第三方服务提供商提供,使用服务的相关限制及注意事项以具体服务提供商的要求为准。对于消费者在领取和使用奖品过程中发生的任何伤害和损失,如该伤害和损失非由主办方之过错导致,主办方不承担任何责任。\n\t</li>\n\t<li>\n\t\t消费者需就因其违反本条款及细则的任何规定、侵犯他人权利或其他任何违法的行为而引起的所有索偿、责任、损失、损害、费用和开支对主办方做出补偿。\n\t</li>\n\t<li>\n\t\t本活动适用中华人民共和国法律。因本活动引起的或本活动有关的任何争议,由争议双方友好协商解决。如任何争议不能通过双方友好协商解决的,可通过其他有效法律途径征求最终解决方式。\n\t</li>\n\t<li>\n\t\t活动主办方、本促销活动的代理公司、广告公司、印刷商和相关合作企业之员工、家属,不可参加此次促销活动, 以示公允。\n\t</li>\n\t<li>\n\t\t个人信息:\n\t</li>\n</ol>\n<ol>\n\t<li>\n\t\t用户向活动主办方提供的个人微信资料数据只会用作本次活动用途,及会被保密处理。\n\t</li>\n\t<li>\n\t\t用户必须授权使用个人微信账号登陆进行互动;若未能及时提供,将不能参加本次活动。\n\t</li>\n\t<li>\n\t\t用户进入本活动时,需要点击同意并授权个人的基本资料给活动主办方使用。本活动将通过微信收集用户基本信息,包括:微信信息资料。以上信息将被主办方委托的第三方用于本活动的奖品派发、活动数据分析等。活动主办方将采取适当的规范手段以保护个人信息安全,防止资料丢失、被盗用或遭篡改。\n\t</li>\n\t<li>\n\t\t用户在使用互联网时对个人信息的运用需进行监管和负责,如有通过公告版等形式自愿提供及公开的个人资料被他人使用或传播,与本活动无关。\n\t</li>\n\t<li>\n\t\t如用户本人主动将微信账号与密码共享,或因各种不可抗力因素所导致的个人资料泄露、丢失、被盗用或被篡改,主办方不承担任何责任。\n\t</li>\n\t<li>\n\t\t如经得用户同意,主办方可使用有关个人资料数据作直接商品促销用途;否则,主办方将不能使用其个人资料作前述直接促销用途。用户须确保所提供的个人资料属实及有效。\n\t</li>\n</ol>',
locate: '',
received: false,
showWelfare: false,
juanSrc: "",
showjuan: false,
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {
if (getApp().globalData.userInfo?.token || app.utils.getToken()) {
await this.getLocation().then(res => {
this.setData({
locate: res
})
})
let pageData = {}
if(options?.pageData){
pageData = JSON.parse(decodeURIComponent(options?.pageData))
}
let userId = wx.getStorageSync('nick')?.userId
if (!userId) {
// userId = getApp().globalData.userInfo?.openId
}
this.setData({
userId,
pageData
})
console.log(pageData, 'pageData11111', userId, 'userId');
if(options.tag){
console.log(options.tag,"options.tag");
//明码抽奖
let {code,uri} = app.utils.getCodeAndUri(options.tag)
console.log(code,uri,"code,uri");
let pageData ={
...pageData,
qrCode:code,
qrUri:uri
}
this.setData({
pageData
})
this.doActivity()
}
else{
console.log(pageData,111111);
this.getPromotion(pageData) //junyao 查询二维码信息和活动信息
}
// this.getMarquee()
} else {
app.utils.needLogin()
}
// if (!app.utils.getToken()) {
// app.utils.needLogin()
// } else {
// const pageData = JSON.parse(decodeURIComponent(options.pageData))
// const userId = wx.getStorageSync('nick')?.userId
// this.setData({
// userId,
// pageData
// })
// this.getMarquee()
// }
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
async onShow() {
},
getPromotion(pageData) { //查询二维码信息和活动信息
let latitude = getApp().globalData.userInfo.latitude
let longitude = getApp().globalData.userInfo.longitude
const apiBase = config.dataServer
wx.request({
url: apiBase + `/tag/v2/promotion?longitude=${longitude}&latitude=${latitude}`,
header: {
'Authorization': `Bearer ${getApp().globalData.userInfo?.token}`,
'serialId': getApp().userInfo?.serialId
},
method: "GET",
data: {
code: pageData.qrCode, //wxff6674eabc54fc28 wx0f695ef70a18d602 wx43fc214041ea41da
uri: pageData.qrUri,
wechatSource: "", //小程序场景值 小程序里扫码:-1000
tagCodeType: "STANDARD", //码类型
pageInfo: true //是否需要页面模板信息(需命中方案)
},
timeout: 30 * 1000,
success: (res) => {
//拟写
let type = res.type
type = "3"
switch (type) {
case '1':
this.setData({
showCodeSituation: true,
txt: "二维码已经参与活动"
})
break;
case '2':
this.setData({
showCodeSituation: true,
txt: "二维码不可激活"
})
break;
case '3':
this.setData({
showCodeSituation: true,
txt: "激励奖励已达上限"
})
break;
case '4':
this.setData({
showCodeSituation: true,
txt: "前方拥堵,还请耐心等待 请稍后再来试试"
})
break;
case '5':
this.setData({
showCodeSituation: true,
txt: "您扫码的二维码不正确 请换一个试试"
})
break;
}
wx.hideLoading()
// wx.reLaunch({
// url: this.myrouter ? decodeURIComponent(
// this.myrouter) :
// '/custom-pages/custom-index/index'
// })
},
fail: (res) => {
console.log(res)
// const msg = await getErrortxt()
// wx.showModal({
// title: '提示',
// content: msg,
// showCancel: false,
// confirmText: '知道了',
// confirmColor: '#fe8600'
// })
},
complete: () => {
// wx.hideNavigationBarLoading()
// if (showLoading) {
// wx.hideLoading()
// }
}
})
},
// 获取地理位置
getLocation() {
return new Promise((resolve, reject) => {
wx.getFuzzyLocation({
type: 'gcj02',
success: (res) => {
getApp().globalData.userInfo.latitude = res.latitude
getApp().globalData.userInfo.longitude = res.longitude
resolve(res.latitude + ',' + res.longitude)
},
fail: function(res) {
console.log('位置信息结果', res)
// wx.navigateTo({
// url: '/pages/defaultError/defaultError?errorId=0&errorMsg=授权失败|我们需要您的位置信息来判断您能否参与活动, 请允许授权'
// })
wx.showModal({
title: '提示',
content: '我们需要您的位置信息来判断您能否参与活动,请允许授权',
confirmText: '去授权',
confirmColor: '#00478b',
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
wx.openSetting({})
}
}
})
}
})
})
},
tapBtnAuth() {
wx.openSetting({})
},
async doActivity() {
console.log(this.data.pageData,"this.data.pageData");
await this.getLocation().then(res => {
this.setData({
locate: res
})
})
const apiBase = config.dataServer
console.log(this.data.locate,"this.data.locate");
// 抽奖/明码进来自动抽奖
wx.request({
url: apiBase + `/lottery/v2/tag?longitude=${this.data.locate.split(",")[0]}&latitude=${this.data.locate.split(",")[1]}`,
header: {
'Authorization': `Bearer ${getApp().globalData.userInfo?.token}`,
'serialId': getApp().userInfo?.serialId
},
method: "POST",
data: {
code: this.data.pageData.qrCode, //码code
uri: this.data.pageData.qrUri, //码uri
tagCodeType: "STANDARD", //码类型(默认标准类型)STANDARD(微信码-微信扫一扫) WECHAT_URL(微信码-小程序扫一扫)
buttonKey: "", //按钮值
awardPosition: false, //是否需要奖项位置(大转盘抽奖使用)
needPlanInfo: false, //是否需要方案信息
banquetPicture: "" //宴会图片 url
},
timeout: 30 * 1000,
success: (res) => {
console.log(res, "res"); //抽奖后返回的结果 新接口
let type = "5"
switch (type) {
//弹出中奖结果
case "1":
//showRedPack
this.setData({
scanRewardVO: (res.data?.prizes && res.data?.prizes[0]) || {
amount: 1
},
showRedPack: true,
excitationRedPack: true
})
return
case "2":
//完善个人信息
this.setData({
showCouponComMess: true,
isOneReward: true //手机授权/填写身份信息
})
return
case "3":
// receiveVis
this.setData({
receiveVis: true,
isNoAward: true // 获奖/谢谢参与
})
return
case "4":
// 领取成功,继续扫码
this.setData({
showSecondRedPack: true,
})
return
case "5":
let price = "5" // 5 50 10 100
let juanSrc = `/images/junyao/juan${price}.png`
// 领取成功,继续扫码
this.setData({
juanSrc,
showjuan: true
})
return
}
},
fail: (res) => {
const [title, info] = res.data.errorMsg.split('|')
this.setData({
alertShow: true,
alertInfo: title || '',
alertText: info || '',
})
},
complete: () => {
// wx.hideNavigationBarLoading()
// if (showLoading) {
// wx.hideLoading()
// }
}
})
return
// app.utils.doPost({
// url: '/activity/doActivityWithLocate.json',
// params: {
// locate: this.data.locate,
// qrCode: this.data.pageData.qrCode
// }
// }).then(res => {
// if (res.data.scanRewardVO) {
// res.data.scanRewardVO.brandId = res.data.brandId
// // let subGoodsVOS = Array.isArray(res.data.subGoodsVOS) ? res.data.subGoodsVOS : ['激励红包'] //null
// let subGoodsVOS = res.data.subGoodsVOS
// this.setData({
// scanRewardVO: res.data.scanRewardVO,
// // subGoodsVOS:Array.isArray(res.data.subGoodsVOS) ? res.data.subGoodsVOS : ['激励红包'] //null
// subGoodsVOS: res.data.subGoodsVOS
// }, () => {
// if (this.data.scanRewardVO.presentType == 9 && Array.isArray(
// subGoodsVOS) && subGoodsVOS.length) { //谢谢惠顾
// this.setData({
// showSecondRedPack: true,
// secondRedPackBg: 'https://hbrand.oss-cn-hangzhou.aliyuncs.com/cpp/jyScan/second_bg2.png'
// })
// } else if (this.data.scanRewardVO.presentType == 9 && Array.isArray(
// subGoodsVOS) && !subGoodsVOS.length) { //待解锁库存没有了
// this.setData({
// receiveVis: true,
// isNoAward: true
// })
// } else if (this.data.scanRewardVO.presentType == 2 && Array.isArray(
// subGoodsVOS)) {
// this.setData({
// showRedPack: true
// })
// } else if (this.data.scanRewardVO.presentType == 2 && !Array.isArray(
// subGoodsVOS)) {
// this.setData({
// showRedPack: true,
// excitationRedPack: true
// })
// }
// })
// } else {
// const [title, info, time] = res.data.errorMsg.split('|')
// this.setData({
// alertShow: true,
// alertInfo: title || '',
// alertText: info || '',
// alertTime: time || ''
// })
// }
// this.setData({
// received: true
// })
// })
},
closeJuan(){
this.setData({
showjuan: false
})
},
// 领取红包
goReceive() {
const {
groupId,
brandId,
voucherNo
} = this.data.scanRewardVO
const postData = {
groupId,
brandId,
voucherNo
}
this.setData({
showRedPack: false //关闭红包
})
return
//原先的接口业务
app.utils.doPost({
url: '/my/getWinGoodsAndCompleteInfo.json',
params: postData
}, true)
.then(async res => {
await this.getUserInfo()
const data = res.data
if (data.needComplete && (data.prizeWeChatPhone || this.data.submitForm.phone) && (data
.prizeUserName || this.data.submitForm.name) && (data.prizeIdcard || this.data
.submitForm.idCard)) {
this.setData({
showCouponComMess: true,
showRedPack: false //关闭红包
})
} else if (!data.needComplete) {
if (data.needSplit) {
const {
groupId,
brandId,
voucherNo
} = this.data.scanRewardVO
this.doTransfer('/my/doTransferToSplit.json', {
groupId,
brandId,
voucherNo
})
} else {
const {
groupId,
brandId,
voucherNo
} = this.data.scanRewardVO
this.doTransfer('/my/doTransfer.json', {
groupId,
brandId,
voucherNo
})
}
}
})
},
// 获取用户信息
getUserInfo() {
return app.utils.doPost({
url: '/my/getUserInfo.json',
params: {}
}).then(res => {
this.setData({
'submitForm.phone': res.data.phone || null,
'submitForm.idCard': res.data.idCard || null,
'submitForm.name': res.data.name || null
}, () => {
this.checkIsFilled()
})
})
},
doTransfer(url, data) {
app.utils.doPost({
url,
params: data
}).then(res => {
if (Array.isArray(this.data.subGoodsVOS) && this.data.subGoodsVOS.length) {
this.setData({
showSecondRedPack: true,
showRedPack: false
})
} else if (Array.isArray(this.data.subGoodsVOS) && !this.data.subGoodsVOS.length) {
this.setData({
showRedPack: false,
receiveVis: true
})
} else if (!Array.isArray(this.data.subGoodsVOS)) {
this.setData({
showRedPack: false,
receiveVis: true
})
} else {
this.setData({
showRedPack: false,
receiveVis: true
})
}
this.messBoxClose()
})
},
onBindInput(e) {
const {
key
} = e.currentTarget.dataset
this.setData({
[`submitForm.${key}`]: e.detail.value
})
this.checkIsFilled()
},
getPhoneNumber(e) {
console.log(e, "e");
const {
code
} = e.detail
if (!code) return
//请求后台获取手机号码
// app.utils.doPost({
// url: '/daNoneUtc/doWechatBindPhone.json',
// params: {
// code
// }
// },true).then(res => {
// this.setData({
// 'submitForm.phone': res.data
// })
// this.checkIsFilled()
// })
},
IdCard(id) {
var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
return reg.test(id)
},
formSubmit() {
let params = {
...this.data.submitForm,
ignorePhone: 1
}
if (this.data.isOneReward) {
if (!this.IdCard(params.idCard)) {
wx.showToast({
title: '请输入格式正确的身份证',
icon: 'none'
})
return
}
app.utils.doPost({
url: '/completeMemberInfoAndSession.json',
params: params
}).then(res => {
if (res) {
const {
groupId,
brandId,
voucherNo
} = this.data.scanRewardVO
this.doTransfer('/my/doTransferToSplit.json', {
groupId,
brandId,
voucherNo
})
}
})
} else {
delete params.name
delete params.idCard
app.utils.doPost({
url: '/completeMemberInfoAndSession.json',
params: params
}).then(res => {
if (res) {
const {
groupId,
brandId,
voucherNo
} = this.data.scanRewardVO
this.doTransfer('/my/doTransfer.json', {
groupId,
brandId,
voucherNo
})
}
})
}
},
// 关闭完善信息弹窗
messBoxClose() {
this.setData({
// isOneReward:false,
showCouponComMess: false,
submitForm: {
name: null,
phone: null,
idCard: null,
},
})
},
welfareBoxClose() {
this.setData({
showWelfare: false,
})
},
// 校验数据是否填写完整
checkIsFilled() {
if (this.data.isOneReward) {
if (this.data.submitForm.name && this.data.submitForm.phone && this.data.submitForm.idCard) {
this.setData({
isFormFilled: true
})
} else {
this.setData({
isFormFilled: false
})
}
} else {
if (this.data.submitForm.phone) {
this.setData({
isFormFilled: true
})
} else {
this.setData({
isFormFilled: false
})
}
}
},
// 继续扫码
handleScan() {
wx.scanCode({
success: res => {
const url = res.result
const qr = app.utils.GetUrlPara(url, 'r').replace(/[\n\r]/g, '')
if (qr) {
wx.reLaunch({
url: `/scanGroup/index/index?qr=${qr}`
})
} else {
wx.showModal({
title: '提示',
content: '请扫描正确的二维码',
showCancel: false,
confirmText: '好的'
})
}
}
})
},
closeReceiveModal() {
this.setData({
receiveVis: false
})
},
closeCodeSituation() {
this.setData({
showCodeSituation: false
})
},
closeRedPack() {
this.setData({
showRedPack: false
})
},
closeSecondRedPack() {
this.setData({
showSecondRedPack: false
})
},
getMarquee() {
app.utils.doPost({
url: '/income/queryWinTop.json',
params: {
groupId: this.data.pageData.id,
topNum: 5,
winType: 2
},
needErrorLog: true
})
.then(res => {
// console.log(res.data);
this.setMarquee(res.data)
})
// const list=[{storeName:'门店门店',amount:15},{storeName:'门店111111111111111111门店',amount:1000}]
// this.setMarquee(list)
},
setMarquee(res) {
const _this = this
this.setData({
// 这里重新赋值,然后设置滚动
marqueeList: res
},
() => {
setTimeout(() => {
const query = _this.createSelectorQuery()
query.select('.marquee-content').boundingClientRect()
query.select('.marquee-item').boundingClientRect()
query.exec(res => {
if (!res[0] || !res[1]) return
const contentWidth = res[0].width
const width = parseInt(res[1].width)
// 判断一个marquee-item宽度是否比marquee-content宽
if (contentWidth && width) {
const num = Math.ceil(contentWidth / width)
if (num > 1) {
let arr = []
for (var i = 0; i < num; i++) {
arr = arr.concat(_this.data.marqueeList)
}
_this.setData({
marqueeList: arr
})
}
// 以跑完一次contentWidth所需时间为6s 计算一个marquee-item走完的时间, 第一条走完就重新开始
const time = parseInt((width / contentWidth) * 8)
const marqueeStyle =
`animation: marquee linear ${time}s infinite;animation-delay:1s;--width: -${width}px;`
const time1 = parseInt((width / contentWidth) * 16)
const marqueeStyle1 =
`animation: marquee linear ${time1}s infinite;animation-delay:1s;--width: -${width}px;`
this.setData({
marqueeStyle,
marqueeStyle1
})
}
})
}, 80)
}
)
},
ruleShow() {
this.setData({
ruleShow: true
})
},
goRecord() {
wx.navigateTo({
url: `/scanGroup/jyScan/record/index?groupId=${this.data.pageData?.id}&voucherNo=${this.data.scanRewardVO?.voucherNo}`,
})
},
goWelfare() {
wx.navigateTo({
url: `/scanGroup/jyScan/welfare/index`,
})
},
goIndex() {
wx.switchTab({
url: '/custom-pages/custom-index/index',
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})