activity_share.js
46.3 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
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
// packageA//pages/goods_share/goods_share.js
var app=getApp(),oo = app.globalData.setting,os=oo,ut = require("../../../utils/util.js");
var regeneratorRuntime = require('../../../utils/runtime.js');
Page({
/**
* 页面的初始数据
*/
data: {
// tab
tab: ['秒杀','拼单','促销','专享礼包','预售','团购','组合购','幸运购'],
currentIndex: 0,
//促销页tab
tab2: ['订单促销','搭配促销','优惠促销'],
currentIndex2: 0,
//秒杀和拼单底部tab
currentIndex3: 0,
// 控制价格
active1: false,
// 控制佣金
active2: false,
url:oo.imghost,
//popup
hiddenPopup: true,
list:[],
is_load:0, //是否正在加载
is_no_data:0, //没有数据
is_no_more:0, //没有更多数据
key_str:'',
pattern:0, //分成的方式
currentPage:1, //当前的页码
canvasHidden: 1, //-- 隐藏画布 --
dis_switch:0, //-- 分销开关 --
pattern:0, //-- 分成的方式 --
share_hidden:1, //-- 分享的按钮隐藏 --
share_good:null, //--- 要分享的商品 ---
timer:0,
hui_active:null, //优惠活动分享
//点击活动详情的时候的响应
list2:[],
is_load2:0,
is_no_data2:0, //没有数据
is_no_more2:0, //没有更多数据
currentPage2:1, //页码
prom_goods:null, //优惠活动的条件
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var th=this;
//接受有没有导购的参数
var first_leader=options.first_leader;
var StaffId=options.StaffId;
var StorageId=options.StorageId;
if(first_leader){
//-- user_id代过来免登录 --
getApp().globalData.user_id=first_leader;
getApp().getUserFir();
//设置分享会员和导购id和归属门店ID
this.setData({first_leader:first_leader,StaffId:StaffId,StorageId:StorageId});
}
console.log("11111111");
this.requestGoodsList();
console.log("22222");
//-- 自定义海报 --
getApp().request.promiseGet("/api/weshop/goods/poster/page",{
data:{store_id:os.stoid, type:1, is_use:1 }
}).then(res=>{
if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0] ){
var poster_data=res.data.data.pageData[0];
var json_str=poster_data.jsonStr;
if(json_str){
var json_data=JSON.parse(json_str);
if(json_data.bg_img){
//-- 把图片那到本地 --
wx.getImageInfo({
src:json_data.bg_img,
success: function(res) {
var path= res.path;
th.setData({share_b_img:path})
},
fail: function(res) {}
});
}
th.setData({poster:json_data})
}
}
})
//获取分销的配置
getApp().request.promiseGet("/api/weshop/storeDistribut/get/"+oo.stoid,{}).then(res=>{
if(res.data.code==0){
th.setData({dis_switch:res.data.data.switch,pattern:res.data.data.pattern});
}
})
//获取用户设备信息,屏幕宽度
wx.getSystemInfo({
success: res => {
th.setData({
screenWidth: res.screenWidth
})
}
});
//-- ---秒杀和拼团都要有定时器---
if(!options.currentIndex || options.currentIndex<=1){
//设置全局定时器
th.data.timer=setInterval(function () {
th.countDown();
},1000);
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () { getApp().check_can_share(); },
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
//--清理定时器--
clearInterval(this.timer);
},
/**e
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
getApp().globalData.no_clear=1;
var th = this;
//礼包的转发
if(th.data.currentIndex==3) {
var lbid=th.data.hui_active.lbId;
var url="/pages/giftpack/giftpacklist/giftpacklist?lbId="+lbid+"&isBuy=1";
if(getApp().globalData.user_id){
url+="&first_leader="+getApp().globalData.user_id;
}
var img=this.data.share_img;
var title=th.data.hui_active.giftTitle;
var ob={
title:title,
path:url,
imageUrl: img,
};
th.setData({share_hidden:1});
th.insert_act_share(title,lbid,6,null,th.data.hui_active.payMoney);
return ob;
}else if(th.data.currentIndex==4) {
let item = this.data.hui_active;
let pre_id = item.id;
let goods_id = item.goods_id;
let price = item.presell_money;
let url = `packageC/pages/presell/goodsInfo/goodsInfo?goods_id=${goods_id}&pre_id=${pre_id}`;
//如果是服务卡项的时候
if(item.goods_type==1){
url = `packageC/pages/presell/cardInfo/goodsInfo?goods_id=${goods_id}&pre_id=${pre_id}`;
}
let title = item.goods_name;
let img = this.data.url + item.original_img;
let ind = 9;
// console.log('preselll=======>>>>>', item, url);
if(getApp().globalData.user_id){
url += "&first_leader=" + getApp().globalData.user_id;
}
th.insert_act_share(title,pre_id,ind,item.goods_sn,price);
th.setData({share_hidden:1,share_good:null});
return {
title: price + "元 " +title,
path: url,
imageUrl: img,
};
} else if(th.data.currentIndex==6) {
let item = this.data.hui_active;
let id = item.id;
let title = item.name;
let price = item.zhprice;
let url = `/packageB/pages/zuhegou/index/index?id=${id}&title=${title}`;
let img = this.data.url + item.img_url;
let ind = 11;
// console.log('zuhebuy=======>>>>>', item, url);
if(getApp().globalData.user_id){
url += "&first_leader=" + getApp().globalData.user_id;
}
th.insert_act_share(title,id,ind,null,price);
th.setData({share_hidden:1});
return {
title: price + "元 " +title,
path: url,
imageUrl: img,
};
} else if(th.data.currentIndex==7) {
// /packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=462393&group_id=288
let item = this.data.hui_active;
// console.log('luckygo>>>>>', item);
let id = item.id;
let goods_id = item.goods_id;
let title = item.title;
let price = item.group_price / 100;
let url = `/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=${goods_id}&group_id=${id}`;
let img = this.data.url + item.original_img;
let ind = 12;
// console.log('zuhebuy=======>>>>>', item, url);
if(getApp().globalData.user_id){
url += "&first_leader=" + getApp().globalData.user_id;
}
th.insert_act_share(title,id,ind,null,price);
th.setData({share_hidden:1});
return {
title: price + "元 " +title,
path: url,
imageUrl: img,
};
} else {
//---秒杀,拼团,促销, 团购---
var item=this.data.share_good;
if(item){
var price = item.price;
if(!price) price=item.shop_price;
item.prom_id=item.id;
var url='';
switch(th.data.currentIndex){
case 0:
item.prom_type=1;
//服务卡项的时候
if(item.goods_type>0)
url="/packageA/pages/goodsInfo/goodsInfo?goods_id=" + item.goods_id+"&prom_type=1&prom_id="+item.prom_id;
break;
case 1:
item.prom_type=6;
//服务卡项的时候
if(item.goods_type>0)
url="/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?goods_id=" + item.goods_id+"&prom_type="+item.prom_type+"&prom_id="+item.prom_id;
break;
case 2:
if(th.data.currentIndex2==1) item.prom_type = 5;
if(th.data.currentIndex2==2) {
item.prom_type = 3;
item.id=item.prom_id;
}
break;
case 5:
item.prom_type = 2;
//服务卡项的时候
if(item.goods_type>0)
url="/packageG/pages/group_buy/goodsInfo/goodsInfo?goods_id=" + item.goods_id+"&prom_id="+item.prom_id;
break;
}
var title= item.goods_name;
var img=this.data.url+item.original_img;
if(!url) url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id+"&prom_type="+item.prom_type+"&prom_id="+item.prom_id;
if(getApp().globalData.user_id){
url+="&first_leader="+getApp().globalData.user_id;
}
var ob={
title: price + "元 " +title,
path:url,
imageUrl: img,
};
th.setData({share_hidden:1,share_good:null});
var ind=3;//秒杀活动分享
if(th.data.currentIndex==0){
ind=3;//秒杀活动分享
}else if(th.data.currentIndex==1){
ind=4;//拼团
}else if(th.data.currentIndex==2){
ind=5;//促销
}else if(th.data.currentIndex==5){
ind=10;//团购
}
//插入活动
if(item.prom_type==3){
var hui_active=this.data.hui_active;
th.insert_act_share(hui_active.name,hui_active.id,5,item.goods_sn,price);
}else{
th.insert_act_share(item.title,item.id,ind,item.goods_sn,price);
}
return ob;
}else{
var url="/pages/index/index/index";
if(getApp().globalData.user_id){
url+="?first_leader="+getApp().globalData.user_id;
}
var hui_active=this.data.hui_active;
var title=hui_active.title;
if(!title) title=hui_active.name;
if(!title) title=hui_active.main_goods_name;
if(!title) title=hui_active.giftTitle;
var ob={
title: title,path:url,
};
th.setData({share_hidden:1,share_good:null});
var ind=0;//促销
if(th.data.currentIndex==2){ ind=5;}
//插入活动
th.insert_act_share(title,hui_active.id,ind,null,null);
return ob;
}
}
},
//-- 点击tab --
clickTab(e) {
var th=this;
if(this.data.currentIndex!=e.target.dataset.index){
this.setData({
currentIndex: e.target.dataset.index,is_no_data:0,is_no_more:0,list:[],
});
this.data.is_load=0;
this.data.currentPage=1;
this.requestGoodsList();
if(e.target.dataset.index<=1){
//设置全局定时器
this.data.timer=setInterval(function () {
th.countDown();
},1000);
}else{
clearInterval(this.timer);
}
}
},
//-- 点击促销页tab --
clickTab2(e) {
if(this.data.currentIndex2!=e.target.dataset.index){
this.setData({
currentIndex2: e.target.dataset.index,is_no_data:0,is_no_more:0,list:[],list2:[]
});
this.data.is_load=0;
this.data.currentPage=1;
this.requestGoodsList();
}
},
//-- 点击秒杀和拼单底部tab,火热进行和即将开始 --
clickTab3(e) {
if(this.data.currentIndex3!=e.target.dataset.index){
this.setData({
currentIndex3: e.target.dataset.index,is_no_data:0,is_no_more:0,list:[],
});
this.data.is_load=0;
this.data.currentPage=1;
this.requestGoodsList();
}
},
// 关闭弹出层
closePopup() {
this.setData({
hiddenPopup: true
});
},
//--- 显示弹出层 ---
showPopup(e) {
var th=this;
var index=e.currentTarget.dataset.index;
var hui_active=this.data.list[index];
//---搭配促销--
this.setData({hui_active: hui_active});
////---搭配促销--
if(this.data.currentIndex2==2){
this.get_prom_goods();
}else{
//-- 获取搭配购的从商品的信息 --
getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + hui_active.main_goods_id,{}).then(res=>{
if(res.data.code==0){
var info=res.data.data
th.setData({['hui_active.ginfo']:info});
}
})
this.get_colloction();
}
this.setData({hiddenPopup:false});
},
get_colloction: async function(){
var list=null;
//-- 获取搭配购的从商品的信息 --
await app.request.promiseGet("/api/weshop/goods/getGoodsPromList/"+oo.stoid+"/"+this.data.hui_active.main_goods_id+"/2"+"/"+(getApp().globalData.user_id || 0) ,{}).then(res=>{
if(res.data.code==0){
list=res.data.data.collocationList;
}
})
if(list){
for(var i in list){
await app.request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + list[i].goods_id,{}).then(res=>{
if(res.data.code==0){
var info=res.data.data
list[i].shop_price=info.shop_price;
}
})
}
}
this.setData({list2:list});//把数据弄到前台
},
//-- 获取优惠商品的活动 --
get_prom_goods:function(){
var list=null;
var th=this;
var prom_goods=null;
var hui_active=this.data.hui_active;
th.data.is_no_more2=0;
th.data.is_no_data2=0;
th.data.currentPage2=1;
th.setData({list2:[]})
//-- 获取优惠活动的详情信息 --
app.request.promiseGet("/api/weshop/promgoodslist/getPromGoodsInfo/"+hui_active.id,{}).then(res=>{
if(res.data.code==0){
prom_goods=res.data.data;
th.setData({prom_goods:prom_goods});
}
})
//-- 指定商品参与,才有商品列表分 --
if(hui_active.good_object==1){
this.request_prom_goods();
}
},
//-- -------获取商品列表--------
requestGoodsList:function() {
var th=this;
if(th.data.is_load) return false; //-- 正在加载
if(th.data.is_no_data) return false; //-- 没有数据
if(th.data.is_no_more) return false; //-- 没有更多
th.data.is_load=1;
var url="";
var req_data={
page:this.data.currentPage,
store_id:oo.stoid,
}
var user_id=getApp().globalData.user_id;
if(!user_id) user_id=0;
switch(th.data.currentIndex){
case 0: //--秒杀--
url="/api/ms/flash_sale/spikepage";
if(th.data.currentIndex3==0){
url+="?timetype=1"; //火热进行中
}else{
url+="?timetype=0"; //即将开始
}
req_data.is_show=1;
req_data.is_end=0;
req_data.user_id=user_id;
if(th.data.key_str && th.data.key_str.trim()){
req_data.key_str=th.data.key_str.trim();
}
break;
case 1: //--拼团--
url="/api/weshop/teamlist/pageteam";
if(th.data.currentIndex3==0){
url+="/1"; //火热进行中
}else{
url+="/0"; //即将开始
}
req_data.is_show=1;
req_data.is_end=0;
if(th.data.key_str && th.data.key_str.trim()){
req_data.key_str=th.data.key_str.trim();
}
break;
case 2: //--促销--
if(th.data.currentIndex2==0){
url="//api/weshop/promorder/page";
if(th.data.key_str && th.data.key_str.trim()){
req_data.name=th.data.key_str.trim();
}
}else if(th.data.currentIndex2==1){
url="/api/weshop/prom/collocation/pageCollocationGoods";
if(th.data.key_str && th.data.key_str.trim()){
req_data.name=th.data.key_str.trim();
}
}else{
url="/api/weshop/promgoods/page";
if(th.data.key_str && th.data.key_str.trim()){
req_data.name=th.data.key_str.trim();
}
}
break;
case 3: //专享礼包
url='/api/weshop/marketing/giftbag/pageMd';
if(th.data.key_str && th.data.key_str.trim()){
req_data.key_str=th.data.key_str.trim();
}
break;
case 4: //预售
url = '/api/weshop/marketing/marketingPresellList/page';
req_data.is_end = 0;
req_data.pageSize = 10;
req_data.timetype = 1;
req_data.isuse = 1;
req_data.user_id = user_id;
if(th.data.key_str && th.data.key_str.trim()){
req_data.key_str=th.data.key_str.trim();
}
break;
case 5: //团购
url = '/api/weshop/goods/groupBuy/page';
req_data.is_show = 1;
req_data.is_end = 0;
req_data.timetype = 1;
if(th.data.key_str && th.data.key_str.trim()){
req_data.key_str = th.data.key_str.trim();
}
break;
case 6: //组合购
// "/api/weshop/prom/zhbuy/page?is_end=0&timetype=1&page=" + e.data.currentPage
url = '/api/weshop/prom/zhbuy/page';
req_data.user_id = user_id;
req_data.is_end = 0;
req_data.timetype = 1;
// req_data.page = 20;
if(th.data.key_str && th.data.key_str.trim()){
req_data.key_str = th.data.key_str.trim();
}
break;
case 7: //幸运购
url = '/api/weshop/prom/luckyActivity/page';
req_data.is_end = 0;
req_data.timetype = 1;
if(th.data.key_str && th.data.key_str.trim()){
req_data.key_str = th.data.key_str.trim();
}
break;
}
if(this.data.key_str && this.data.key_str.trim()){
var str=this.data.key_str.trim();
req_data.key_str=str;
}
//-- ---调用接口----
app.request.promiseGet(url,{data:req_data,isShowLoading:1}).then(res=>{
console.log("2222");
console.log(url);
console.log(res);
th.data.is_load=0;
if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
th.data.currentPage++;
var data=res.data.data.pageData;
if(th.data.currentIndex==0){
for(let i in data){
let item=data[i];
if(item.user_price) item.price=item.price;
}
}
if(res.data.data.page*10>res.data.data.total){th.setData({is_no_more:1});}
var list=th.data.list;
list=list.concat(data);
console.log('list------>>>>', data)
th.setData({list:list});
}else{
if(th.data.currentPage==1){
th.setData({is_no_data:1});
}
}
})
},
//-- -------获取活动详情的商品的列表--------
request_prom_goods:function(){
var th=this;
if(th.data.is_load2) return false; //-- 正在加载
if(th.data.is_no_data2) return false; //-- 没有数据
if(th.data.is_no_more2) return false; //-- 没有更多
th.data.is_load2=1;
var req_data={
page:th.data.currentPage2
}
app.request.promiseGet("/api/weshop/goods/page?store_id="+oo.stoid+"&prom_type=3&prom_id="+th.data.hui_active.id,{
data:req_data,isShowLoading:1
}).then(res=>{
th.data.is_load2=0;
if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
th.data.currentPage2++;
var data=res.data.data.pageData;
if(res.data.data.page*10>res.data.data.total){th.setData({is_no_more2:1});}
var list=th.data.list2;
list=list.concat(data);
th.setData({list2:list});
}else{
if(th.data.currentPage==1){
th.setData({is_no_data2:1});
}
}
})
},
//--- 获取卡类列表 ---
getPlusCardType: function (func) {
var storid = oo.stoid;
var th = this;
getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
if(res.data.code!=0 || !res.data.data){
var ob={"card_list":[],"name_map":''};
func(ob);
return false;
}
var plusCard = res.data.data;
var arr = [1219, 2089, 3031];
var new_arr = new Array();
var card_name_map=new Map();
var user = getApp().globalData.userInfo;
for (var i = 0; i < plusCard.length; i++) {
if ((user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) {
continue;
}
var name="card"+plusCard[i].CorrPrice.toLowerCase();
card_name_map.set(name,plusCard[i].CardName);
new_arr.push(plusCard[i]);
}
var ob={"card_list":new_arr,"name_map":card_name_map};
func(ob);
})
},
//---图片失败,默认图片---
bind_bnerr2: function (e) {
var _errImg = e.target.dataset.errorimg;
var _errObj = {};
_errObj[_errImg] ="/miniapp/images/default_g_img.gif";
this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
},
//-- ---更多加载----
refresh:function(){
this.requestGoodsList();
},
//--定义的保存图片方法,分享团---
saveImageToPhotosAlbum: function() {
//--先判断会员状态--
// var user_info = getApp().globalData.userInfo;
// if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
// //getApp().my_warnning("请先登录",0,this);
// wx.navigateTo({ url: '/packageE/pages/togoin/togoin', })
// return false;
// }
//类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团
var type = 0;
wx.showLoading({
title: '生成中...',
})
var that = this, th = that;
//设置画板显示,才能开始绘图,并关闭底部按钮
that.setData({
canvasHidden: false,share_hidden:1
})
var app = getApp();
var unit = that.data.screenWidth / 750 * 1.35; //基础单位,
var prom_type=0;
var prom_id=th.data.share_good.id;
var scene='';
var goods_path='pages/goods/goodsInfo/goodsInfo';
var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0;
switch(th.data.currentIndex){
case 0:
prom_type=1;
//服务卡项的时候
if(th.data.share_good.goods_type>0){
scene = th.data.share_good.goods_id;
if (user_id > 0) {
scene += "_" + user_id;
}else{
scene += "_0";
}
scene += "_0";
scene += "_" + 1+"_"+prom_id;
goods_path='packageA/pages/goodsInfo/goodsInfo';
}
break;
case 1:
prom_type=6;
//服务卡项的时候
if(th.data.share_good.goods_type>0){
scene =th.data.share_good.goods_id+'';
if (user_id > 0) {
scene += "_" + user_id;
}else{
scene += "_0";
}
scene += "_0";
scene += "_6";
scene += "_"+prom_id;
goods_path='packageA/pages/serviceCard_pd/goodsInfo/goodsInfo';
}
break;
case 2:
if(th.data.currentIndex2==1) prom_type = 5;
if(th.data.currentIndex2==2){
prom_type = 3;
prom_id=th.data.share_good.prom_id;
}
break;
case 5:
prom_type = 2;
//服务卡项的时候
if(th.data.share_good.goods_type>0){
scene =th.data.share_good.goods_id+'';
if (user_id > 0) {
scene += "_" + user_id;
}else{
scene += "_0";
}
scene += "_0";
scene += "_" +prom_id;
goods_path='packageG/pages/group_buy/goodsInfo/goodsInfo';
}
break
}
if(!scene){
scene = th.data.share_good.goods_id+""+"."+prom_type+"."+prom_id;
if(user_id>0){
scene+="_"+user_id;
}
}
var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
os.stoid + "?sceneValue=" + scene + "&pageValue="+goods_path;
console.log(path3);
var ind=3;
if(that.data.currentIndex==1){
ind=4;
}
//-- 价格 --
var pri0 = th.data.share_good.shop_price;
if (th.data.share_good.price)
pri0 = th.data.share_good.price;
if(th.data.share_good.prom_type==3){
th.insert_act_share(th.data.hui_active.name,th.data.hui_active.id,5,th.data.share_good.goods_sn,pri0); //插入分享
}else{
th.insert_act_share(th.data.share_good.title,th.data.share_good.id,ind,th.data.share_good.goods_sn,pri0); //插入分享
}
//读取文件成功则OK--
wx.getImageInfo({
src: path3,
success: function(res) {
//回调写法
th.get_head_temp(th.get_goods_temp, function() {
var vpath = res.path;
var context = wx.createCanvasContext('share');
//先画背景
var pg_path = "../../../images/share/share_bg.png";
//-- 如果有自定义海报的时候,判断背景的图片 --
if(th.data.share_b_img){
pg_path=th.data.share_b_img;
}
context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
let nick=app.globalData.userInfo?app.globalData.userInfo.nickname:'';
//-- 是自定义海报的情况下 --
if(th.data.poster && parseInt(th.data.poster.style)==2){
//在线上分享人的情况下
if(parseInt(th.data.poster.show_headpic)){
//获取坐标
var x=parseFloat(th.data.poster.head_x)*2;
var y=parseFloat(th.data.poster.head_y)*2;
var x1=(x+90) *unit;
var y1=(y+50) *unit;
//--昵称---
context.setFontSize(24 * unit)
context.setFillStyle("black")
context.fillText(nick, x1, y1);
var width = 24 * nick.length * unit + 4 * unit;
//强烈推荐 改许程
var tj_path = "../../../images/share/q_tj.png";
context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit);
context.setFontSize(16 * unit)
context.setLineJoin('round'); //交点设置成圆角
context.setFillStyle("white")
context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit);
}
}else{
//--昵称---
context.setFontSize(24 * unit)
context.setFillStyle("black")
context.fillText(nick, 152 * unit, 76 * unit);
var width = 24 * nick.length * unit + 2 * unit;
//强烈推荐 改许程
var tj_path = "../../../images/share/q_tj.png";
context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
context.setFontSize(16 * unit)
context.setLineJoin('round'); //交点设置成圆角
context.setFillStyle("white")
context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 76 * unit);
}
//---产品名称---
//文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
context.setFillStyle("black");
context.setFontSize(21.3 * unit)
th.draw_Text(context, th.data.share_good.goods_name,
38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
//------产品的价格-------
context.setFontSize(23 * unit)
context.setFillStyle("red")
context.fillText("¥", 416 * unit, 185 * unit);
context.setFontSize(31 * unit)
pri0 = parseFloat(pri0).toFixed(2);
context.fillText(pri0, 438 * unit, 185 * unit);
//---市场价划掉---
context.setFillStyle("gray")
context.setFontSize(22 * unit)
context.fillText("¥" + th.data.share_good.market_price, 426 * unit, 213 * unit);
context.setStrokeStyle('gray')
context.setLineWidth(1 * unit)
context.moveTo(426 * unit, 206 * unit)
context.lineTo(510 * unit, 206 * unit)
context.stroke();
//---中间大图---
context.drawImage(th.data.share_goods_img, 68 * unit, 242 * unit, 410 * unit, 410 * unit);
//-------大图后面就不一样了-----------
switch (type) {
case 0: //普通商品的展示
//中间的几个字
if(th.data.poster && parseInt(th.data.poster.style)==2 ){
if(parseInt(th.data.poster.show_quality)){
var g_path = "../../../images/share/s_gou.png";
context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
context.setFillStyle("red")
context.setFontSize(18 * unit)
context.fillText("正品保证", 84 * unit, 690 * unit);
context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
context.setFillStyle("red")
context.setFontSize(18 * unit)
context.fillText("纯实体店", 246 * unit, 690 * unit);
context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
context.setFillStyle("red")
context.setFontSize(18 * unit)
context.fillText("官方验证", 420 * unit, 690 * unit);
}
}else{
var g_path = "../../../images/share/s_gou.png";
context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
context.setFillStyle("red")
context.setFontSize(18 * unit)
context.fillText("正品保证", 84 * unit, 690 * unit);
context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
context.setFillStyle("red")
context.setFontSize(18 * unit)
context.fillText("纯实体店", 246 * unit, 690 * unit);
context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
context.setFillStyle("red")
context.setFontSize(18 * unit)
context.fillText("官方验证", 420 * unit, 690 * unit);
}
//---画线---
context.setLineWidth(1 * unit)
context.moveTo(32 * unit, 710 * unit)
context.lineTo(520 * unit, 710 * unit)
context.stroke();
//---文字---
context.setFillStyle("black")
context.setFontSize(22 * unit)
// 原来start --->
context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit);
context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit);
//---二维吗图---
//-- 自定义海报 --
if(th.data.poster){
var erm_x= parseFloat(th.data.poster.ewm_x)*2;
var erm_y= parseFloat(th.data.poster.ewm_y)*2;
context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
}else{
//---二维吗图---
context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
}
break;
case 1: //秒杀商品的展示
//---画线---
context.setLineWidth(1 * unit)
context.moveTo(32 * unit, 670 * unit)
context.lineTo(520 * unit, 670 * unit)
context.stroke();
//画秒杀的图片
var miaos_path = '../../../images/share/miao_share.png';
context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
//---文字---
context.setFontSize(22 * unit)
context.setFillStyle("black")
context.fillText("特惠好物,限时秒杀", 40 * unit, 806 * unit);
context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
//---二维吗图---
//-- 自定义海报 --
if(th.data.poster){
var erm_x= parseFloat(th.data.poster.ewm_x)*2;
var erm_y= parseFloat(th.data.poster.ewm_y)*2;
context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
}else{
//---二维吗图---
context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
}
break;
case 2: //会员团和商家团的展示
//---画线---
context.setLineWidth(1 * unit)
context.moveTo(32 * unit, 670 * unit)
context.lineTo(520 * unit, 670 * unit)
context.stroke();
//---文字---
context.setFontSize(22 * unit)
context.font = 'normal bold';
context.setFillStyle("black")
context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
//绘制成团图片
var ct_img = "../../../images/share/ct_num.png";
context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit);
var ct_num = th.data.prom_act.ct_num;
context.setFontSize(14 * unit)
context.font = 'normal';
context.setFillStyle("red")
if (ct_num < 10) {
context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit);
} else {
context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit);
}
context.setFontSize(22 * unit)
context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
context.setFillStyle("gray")
context.fillText("快来和我一起拼团吧!", 40 * unit, 826 * unit);
context.setFillStyle("black")
context.font = 'normal bold 18px sans-serif';
context.setFontSize(21.3 * unit)
context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit);
//---二维吗图---
//-- 自定义海报 --
if(th.data.poster){
var erm_x= parseFloat(th.data.poster.ewm_x)*2;
var erm_y= parseFloat(th.data.poster.ewm_y)*2;
context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
}else{
//---二维吗图---
context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
}
break
case 3: //阶梯团的展示
//---画线---
context.setLineWidth(1 * unit)
context.moveTo(32 * unit, 670 * unit)
context.lineTo(520 * unit, 670 * unit)
context.stroke();
//---文字---
context.setFontSize(22 * unit)
context.font = 'normal bold';
context.setFillStyle("black")
context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit);
//---绘制中间阶梯的价格---
var list = th.data.prom_act.ct_rylist;
for (var i = 0; i < list.length; i++) {
var item = list[i];
var wi = i * 90 * unit;
context.font = 'normal';
context.setFontSize(16 * unit)
context.setFillStyle("red")
context.fillText("¥", 40 * unit + wi, 756 * unit);
context.setFontSize(22 * unit)
var pri = parseFloat(item.price).toFixed(2);
context.fillText(pri, 56 * unit + wi, 756 * unit);
context.setFillStyle("gray")
context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
}
//----------------下面部分----------------
context.setFillStyle("gray")
context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
context.setFillStyle("black")
context.font = 'normal bold 18px sans-serif';
context.setFontSize(22 * unit)
context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
//-- 自定义海报 --
if(th.data.poster){
var erm_x= parseFloat(th.data.poster.ewm_x)*2;
var erm_y= parseFloat(th.data.poster.ewm_y)*2;
context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
}else{
//---二维吗图---
context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
}
break
}
//--- 如果是自定义海报的时候 ---
if(th.data.poster && parseInt(th.data.poster.style)==2){
//如果显示会员信息的话
if(parseInt(th.data.poster.show_headpic)){
//获取坐标
var x= parseFloat(th.data.poster.head_x)*2;
var y=parseFloat(th.data.poster.head_y)*2;
//---绘制圆形要放在最后----
context.save();
context.beginPath();
var h_x = x* unit;
var h_y = y * unit;
var h_r = 40 * unit;
var cx = h_x + h_r;
var cy = h_y + h_r;
context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
context.closePath();
context.fill();
context.clip();
context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
context.restore();
}
}else{
//---绘制圆形要放在最后----
context.save();
context.beginPath();
var h_x = 60 * unit;
var h_y = 24 * unit;
var h_r = 40 * unit;
var cx = h_x + h_r;
var cy = h_y + h_r;
context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
context.closePath();
context.fill();
context.clip();
context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
context.restore();
}
//把画板内容绘制成图片,并回调 画板图片路径
context.draw(false, function() {
setTimeout(function() {
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 750,
height: 1217,
destWidth: 1.2 * 750 * 750 / that.data.screenWidth,
destHeight: 1.2 * 1217 * 750 / that.data.screenWidth,
canvasId: 'share',
success: function(res) {
that.setData({
shareImgPath: res.tempFilePath,
canvasHidden: true
})
if (!res.tempFilePath) {
wx.showModal({
title: '提示',
content: '图片绘制中,请稍后重试',
showCancel: false
})
return false;
}
getApp().pre_img(that.data.shareImgPath);
//-- 将商品清空 --
th.setData({share_good:null});
wx.hideLoading();
}
})
}, 500)
});
});
}
});
},
//---点击分享优惠活动---
share_index:function(e){
//--先判断会员状态--
// var user_info = getApp().globalData.userInfo;
// if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
// //getApp().my_warnning("请先登录",0,this);
// wx.navigateTo({ url: '/packageE/pages/togoin/togoin', })
// return false;
// }
var index=e.currentTarget.dataset.index;
var item=this.data.list[index];
this.setData({share_hidden:0,hui_active:item});
var com = this.selectComponent("#share_button"); //组件的id
com.set_type(1);
},
//---点击分享商品---
share_good:function(e){
//--先判断会员状态--
// var user_info = getApp().globalData.userInfo;
// if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
// //getApp().my_warnning("请先登录",0,this);
// wx.navigateTo({ url: '/packageE/pages/togoin/togoin', })
// return false;
// }
var index=e.currentTarget.dataset.index;
var item=this.data.list[index];
//如果是搭配购
if(item.main_goods_id){
item.goods_id=item.main_goods_id;
item.goods_name=item.main_goods_name;
}
this.setData({share_hidden:0,share_good:item});
var com = this.selectComponent("#share_button"); //组件的id
com.set_type(0);
},
//----活动详情里面的分享---
share_good2:function(e){
//--先判断会员状态--
// var user_info = getApp().globalData.userInfo;
// if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
// //getApp().my_warnning("请先登录",0,this);
// wx.navigateTo({ url: '/packageE/pages/togoin/togoin', })
// return false;
// }
var index=e.currentTarget.dataset.index;
var item=this.data.list2[index];
this.setData({share_hidden:0,share_good:item});
var com = this.selectComponent("#share_button"); //组件的id
com.set_type(0);
},
//-----详情里面的分享-------
share_detail:function(e){
//--先判断会员状态--
// var user_info = getApp().globalData.userInfo;
// if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
// //getApp().my_warnning("请先登录",0,this);
// wx.navigateTo({ url: '/packageE/pages/togoin/togoin', })
// return false;
// }
var com = this.selectComponent("#share_button"); //组件的id
com.set_type(0);
var idx=e.currentTarget.dataset.index;
var item=this.data.list2[index];
this.setData({share_hidden:0,share_good:item});
},
cancel:function(){
this.setData({share_hidden:1});
},
//--获取头像的本地缓存,回调写法--
get_head_temp: function(tt, func) {
var ee = this;
if (ee.data.share_head) {
tt(func);
return false;
}
//---获取分享图片的本地地址,头像和商品图片----
var path2 = getApp().globalData.userInfo?getApp().globalData.userInfo.head_pic:'';
if (path2 == "") {
ee.data.share_head = "../../../images/share/hui_hear_pic.png";
tt(func);
} else {
path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
wx.getImageInfo({
src: path2,
success: function(res) {
//res.path是网络图片的本地地址
ee.data.share_head = res.path;
tt(func);
},
fail: function(res) {
ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的
tt(func);
}
});
}
},
//--获取商品图片的本地缓存,回调写法--
get_goods_temp: function(tt) {
var ee = this;
//获取商品是分享图信息
wx.getImageInfo({
src: ee.data.url+ee.data.share_good.original_img,
success: function(res) {
//res.path是网络图片的本地地址
ee.data.share_goods_img = res.path;
tt();
},
fail: function(res) {
//获取默认空白图
wx.getImageInfo({
src: ee.data.url+'/miniapp/images/default_g_img.gif',
success: function(res) {
ee.data.share_goods_img = res.path; //分享的图片不能用网络的
tt();
}
})
}
});
},
//文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
var lineWidth = 0;
var lastSubStrIndex = 0; //每次开始截取的字符串的索引
var han = 0;
for (let i = 0; i < str.length; i++) {
if (han == 2) return;
//lineWidth += ctx.measureText(str[i]).width;
lineWidth += ut.measureText(str[i], 21.3 * unit);
if (lineWidth > canvasWidth) {
han++;
if (han == 2)
ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分
else
ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight);
initHeight += 22; //22为字体的高度
lineWidth = 0;
lastSubStrIndex = i;
titleHeight += 20;
}
if (i == str.length - 1) { //绘制剩余部分
ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight);
}
}
},
//---小于10的格式化函数----
timeFormat(param) {
return param < 10 ? '0' + param : param;
},
//----倒计时函数-----
countDown() {
if(!this.data.timer) return false;
var th=this;
// 获取当前时间,同时得到活动结束时间数组
let newTime =ut.gettimestamp();
var endTimeList = this.data.list;
if(endTimeList==null) return null
// 对结束时间进行处理渲染到页面
for (var i = 0; i < endTimeList.length;i++){
var o = endTimeList[i];
var endTime = o.end_time;
let obj = null;
// 如果活动未结束,对时间进行处理
if (endTime - newTime > 0){
let time = (endTime - newTime);
// 获取天、时、分、秒
let day = parseInt(time / (60 * 60 * 24));
let hou = parseInt(time % (60 * 60 * 24) / 3600);
let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
obj = {
day: this.timeFormat(day), hou: this.timeFormat(hou), min: this.timeFormat(min), sec: this.timeFormat(sec), hide: 1
}
}else{
//活动已结束,全部设置为'00'
obj = { day: '00', hou: '00', min: '00', sec: '00' }
}
var txt ="list["+i+"].djs";
th.setData({ [txt]: obj});
}
},
//-------搜索的相关功能------
set_search_value:function(e){
var key_str=e.detail.value;
if(key_str) key_str=key_str.trim();
this.setData({key_str:key_str});
},
search_data:function(){
this.setData({
is_no_data:0,is_no_more:0,list:[],
});
this.data.is_load=0;
this.data.currentPage=1;
this.requestGoodsList();
},
go_goods: function (e) {
var index = e.currentTarget.dataset.index;
var item = this.data.list[index];
var url='';
switch (this.data.currentIndex) {
case 0:
item.prom_type = 1;
break;
case 1:
item.prom_type = 6;
break;
case 2:
if (th.data.currentIndex2 == 1) item.prom_type = 5;
if (th.data.currentIndex2 == 2) item.prom_type = 3;
break;
case 5:
item.prom_type = 2;
break;
}
item.prom_id = item.id;
//-- 秒杀,拼单,团购,预售 --
if(item.goods_type>0){
switch (item.prom_type){
case 1: //秒杀
url = "/packageA/pages/goodsInfo/goodsInfo?goods_id=" + item.goods_id;
break;
case 2: //团购
url = '/packageG/pages/group_buy/goodsInfo/goodsInfo?goods_id=' + item.goods_id;
break;
case 6: //拼单
url="/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?goods_id=" + item.goods_id
break;
case 8: //预售
url = `pageValue=packageC/pages/presell/cardInfo/goodsInfo?goods_id=${item.goods_id}&pre_id=${item.id}`;
break;
}
}else {
url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id;
}
url += "&prom_type=" + item.prom_type + "&prom_id=" + item.prom_id
getApp().goto(url);
},
go_coll_good:function(e){
var gid=e.currentTarget.dataset.gid;
var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid;
getApp().goto(url);
},
go_libao:function(e){
var index=e.currentTarget.dataset.index;
var item=this.data.list[index];
var lbid=item.lbId;
var url="/pages/giftpack/giftpacklist/giftpacklist?lbId="+lbid+"&isBuy=1";
getApp().goto(url);
},
//-- 推送活动分享 --
insert_act_share:function(title,actid,ind,ShareActNo,ActMoney){
var th = this;
var url="/api/weshop/sharetypeList/save";
var req_data={
shareActId:actid,
shareActName:title,
shareType:ind,
shareUserId:th.data.first_leader,
shareStaffId:th.data.StaffId,
shareStorageId:th.data.StorageId,
shareTime:ut.gettimestamp(),
storeId:os.stoid
}
if(!ShareActNo) ShareActNo=actid; //如果没有带编号就带活动id
if(ActMoney) req_data.ActMoney=ActMoney; //如果金额就要把参数带入
req_data.ShareActNo=ShareActNo;
//插入数据
getApp().request.post(url,{
data:req_data,
success:function(){}
})
//收入线下数据
req_data.userId=th.data.first_leader;
delete req_data.shareUserId;
//插入数据
getApp().request.post('/api/weshop/MdShareType/saveShare',{
data:req_data,
success:function(){}
})
},
//跳转
go: function (e) {
var url = e.currentTarget.dataset.url;
getApp().goto(url);
},
})