profile.js
55.6 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
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
function e(e, a, r) {
return a in e ? Object.defineProperty(e, a, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[a] = r, e;
}
const app = getApp();
let self = null;
var a = getApp(),
r = a.globalData.setting,
t = a.request,
s = require("../../../utils/common.js"),
util = require("../../../utils/util.js"),
ut = util,
d = getApp().globalData;
var timestamp = Date.parse(new Date());
var date = new Date(timestamp);
// const {
// barcode,
// qrcode
// } = require('../../../utils/index.js');
var regeneratorRuntime = require('../../../utils/runtime.js');
Page({
data: {
phone: "",
url: r.url,
resourceUrl: r.resourceUrl,
iurl: r.imghost,
defaultAvatar: r.resourceUrl + "/static/images/user68.jpg",
user: null,
tc_hide: true,
stoname: "请选择",
checkDate: false,
datet: "",
year: date.getFullYear(),
store: 0,
all_sto: "",
region_name: "",
def_pick_store: "",
sort_store: 0, //门店分类
sec_sto: "",
more_store: 0, //选择门店
choice_sort_store: 0, //选择分类门店
more_store: 0, //选择门店
lat: null, //维度
lon: null, //经度
fir_pick_index: 0,
sec_pick_index: 0,
is_gps: 1,
lon: 0,
only_pk: 0,
open_ind_store: 0, //哪里打开的门店列表的控制属性
ispwhid: 1, //是否隐藏密码显示
isstcsp: 0, //是否启用密码消费
isGender: 0, //什么性别
iscalendar: 0, //是否是农历
consumption: "", //消费密码
identity_card: "", //身份证值
address: "", //地址
openid: "", //openid
pulscardname: "", //PLUS会员的卡
gradename: "", //会员权益的卡
isBool: "",
sto_sele_id: "", //所属门店id
is_zy: 0, //是否执行onshow
is_lable_set: "", //是否启用我的兴趣标签
is_bq_must:'',//兴趣标签是否必填
check_label: [], //我选择的兴趣标签
fir_guide_id: null, //存储会员详情接口出来的美导ID
isLunar: 0,
lat: null, //维度
lon: null, //经度
loading: 0,
oldBirtthDayLength:0, //生日日期个数
oldbirthday:'',//生日日期
all_pick_list:null, //所有的门店的集合
old_all_sto:null,
keyword:'', //搜索门店的关键字
sec_i:-1
},
//通过路径跳转到其他页面
goto: function (e) {
var url = e.currentTarget.dataset.url;
getApp().goto(url);
},
//查找会员选择的兴趣标签
query_checklabels: function () {
var th = this;
var url = "/api/weshop/marketing/holiday/vip/interest/label/get";
var interest_lables = th.data.interest_lables; //兴趣标签
getApp().request.promiseGet(url, {
data: {
userId: d.user_id,
storeId: r.stoid
}
}).then(res => {
if (res.data.code == 0) {
var data = res.data.data;
var VipLabel = th.data.check_label; //通过id标签找到已选择的标签
var dateList = data.VipLabel.split(",");
for (var i in dateList) {
if (dateList[i] != "") {
VipLabel.push(dateList[i]);
}
}
th.setData({
check_label: VipLabel
})
} else {
getApp().my_warnning("系统繁忙,请稍后再试", 0, th);
}
})
},
//出生日期是否是农历
iscalendar: function () {
if (this.data.user.birthday) return false;
var th = this;
var iscalendar = th.data.iscalendar;
if (iscalendar == 0) {
th.setData({
iscalendar: 1
})
} else {
th.setData({
iscalendar: 0
})
}
},
checkDate: function () {
var th = this;
if (th.data.checkDate) {
th.setData({
checkDate: false
})
} else {
th.setData({
checkDate: true
})
}
},
//---点击二级之后的选择---
choose_for_store: function (e) {
var index_c = e.currentTarget.dataset.ind;
this.setData({
sec_pick_index: index_c,
fir_pick_index: index_c
})
},
//确定def_pick为选择的门店
sure_pick: function (e) {
var th = this;
var item = null;
var openindstore = th.data.open_ind_store;
if (th.data.choice_sort_store == 0) {
var index = th.data.fir_pick_index;
if (th.data.is_show_sto_cat == 1) {
item = th.data.def_pickpu_list[index];
} else {
item =th.data.only_pk?th.data.only_pk[index]:null; //当没有门店分类的时候
}
} else {
var index = th.data.sec_pick_index;
item = th.data.sec_sto.s_arr[index];
}
if (!item) return false;
th.setData({
def_pick_store: item,
stoname: item.pickup_name,
sto_sele_name: item.pickup_name,
sto_sele_id: item.pickup_id,
sto_sele_distr: item.distr_type,
store: 0,
choice_sort_store: 0,
fir_pick_index: 0
});
if (openindstore == 1) {
th.setData({
openSpecModal: !0,
openSpecModal_ind: openindstore,
});
} else if (openindstore == 2) {
th.setData({
openSpecModal: !0,
openSpecModal_ind: openindstore,
openSpecModal_pt: 1
});
}
},
choose_for_store_fir: function (e) {
var index_c = e.currentTarget.dataset.ind;
this.setData({
fir_pick_index: index_c
})
},
wait_for_store_config: function () {
var th = this;
wx.getLocation({
type: 'gcj02',
success: function (res) {
th.data.lat = res.latitude;
th.data.lon = res.longitude;
th.data.is_get_local_ok = 1;
},
fail: function (res) {
if (res.errCode == 2) {
th.setData({
is_gps: 0
});
if (th.data.is_gps == 0) {
getApp().confirmBox("请开启GPS定位", null, 10000, !1);
}
} else {
th.setData({
is_gps: "3"
});
}
th.data.is_get_local_ok = 1;
}
})
},
onclickstore: function () {
var th = this;
if (th.data.store == 0) {
th.setData({
store: 1
})
} else {
th.setData({
store: 0
})
}
var dd = {
store_id: r.stoid,
isstop: 0,
pageSize: 2000
}
th.setData({
sort_store: 0
});
var i = getApp().request;
//如果有距离的话
if (th.data.lat != null) {
dd.lat = th.data.lat;
dd.lon = th.data.lon;
}
//----------获取门店----------------
getApp().request.get("/api/weshop/pickup/list", {
data: dd,
success: function (res) {
var e = res;
if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) {
var ishas_cate = 0;
for (let i in e.data.data.pageData) {
let item = e.data.data.pageData[i];
if (item.category_id > 0) {
ishas_cate = 1;
break;
}
}
//-- 如果有默认选择门店的时候,要把默认门店放在第一位 --
if (th.data.def_pick_store) {
for (var k = 0; k < e.data.data.pageData.length; k++) {
if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {
e.data.data.pageData.splice(k, 1); //删除
break;
}
}
e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
}
th.setData({
all_pick_list: e.data.data.pageData
});
//单总量超出5个的时候
if (e.data.data.total > 10 && ishas_cate) {
i.get("/api/weshop/storagecategory/page", {
data: {
store_id: r.stoid,
pageSize: 1000,
orderField: "sort",
orderType: 'asc',
},
success: function (ee) {
if (ee.data.code == 0) {
var check_all_cate = 0;
if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
for (let i in ee.data.data.pageData) {
let item = ee.data.data.pageData[i];
if (item.is_show == 1) {
check_all_cate = 1;
break
}
}
}
if (check_all_cate) {
var sto_cate = ee.data.data.pageData;
var sto_arr = e.data.data.pageData;
var newarr = new Array();
var qita = new Array();
var is_del_pk = 0;
//----要进行门店分组--------
for (var i = 0; i < sto_arr.length; i++) {
//找一下这个门店有没有在分类数组内
var find2 = 0, find2name = "", sort = 0;
is_del_pk = 0;
for (var m = 0; m < sto_cate.length; m++) {
if (sto_arr[i].category_id == sto_cate[m].cat_id) {
if (sto_cate[m].is_show != 1) {
is_del_pk = 1;
sto_arr.splice(i, 1);
i--;
} else {
find2 = sto_cate[m].cat_id;
find2name = sto_cate[m].cat_name;
sort = sto_cate[m].sort;
is_del_pk = 0;
}
break;
}
}
if (is_del_pk) continue;
if (newarr.length > 0) {
var find = 0;
//如果有找到,那门店就在这个分组内,否则,分类就要排在其他
if (find2 != 0) {
for (var ii = 0; ii < newarr.length; ii++) {
if (sto_arr[i].category_id == newarr[ii].cat_id) {
newarr[ii].s_arr.push(sto_arr[i]);
find = 1;
break;
}
}
if (find == 0) {
var arr0 = new Array();
arr0.push(sto_arr[i]);
var item = {
cat_id: find2,
name: find2name,
sort: sort,
s_arr: arr0
};
newarr.push(item);
}
} else {
qita.push(sto_arr[i]);
}
} else {
//如果有找到,那门店就在这个分组内,否则,分类就要排在其他
if (find2 != 0) {
var arr0 = new Array();
arr0.push(sto_arr[i]);
var item = {
cat_id: find2,
name: find2name,
sort: sort,
s_arr: arr0
};
newarr.push(item);
} else {
qita.push(sto_arr[i]);
}
}
}
var def_arr = new Array();
//-- 开始就看10个门店 --
for (var k = 0; k < 10; k++) {
if (k == e.data.data.pageData.length) break;
def_arr.push(e.data.data.pageData[k]);
}
th.setData({
def_pickpu_list: def_arr,
pickpu_list: ee.data.data.pageData
});
//门店分类要排序下
function compare(property) {
return function (a, b) {
var value1 = a[property];
var value2 = b[property];
return value1 - value2;
}
}
if (newarr.length > 0)
newarr.sort(compare("sort"));
//----安排其他的分类-----
if (qita.length > 0) {
var item = {
cat_id: -1,
name: "其他",
s_arr: qita
};
newarr.push(item);
}
th.setData({
is_show_sto_cat: 1,
all_sto: newarr
});
} else {
th.setData({
is_show_sto_cat: -1,
only_pk: e.data.data.pageData
});
}
} else {
th.setData({
is_show_sto_cat: -1,
only_pk: e.data.data.pageData
});
}
}
});
} else {
th.setData({
is_show_sto_cat: 0,
only_pk: e.data.data.pageData
});
}
}
}
})
},
//选择更多门店
more_store: function () {
this.setData({
sort_store: 1
});
},
//---选择分类门店---
choice_sort_store: function (e) {
var index = e.currentTarget.dataset.index;
var region_name = e.currentTarget.dataset.region;
var item = this.data.all_sto[index];
this.setData({
region_name: region_name,
sort_store: 0,
choice_sort_store: 1,
sec_sto: item,
sec_pick_index: 0,
sec_i: index,
});
},
// 返回按钮
returns: function () {
this.setData({
sort_store: 0,
choice_sort_store: 0
});
},
// 获取用户头像昵称
getUserProfile(e) {
var th = this;
var ob={
nickname:this.data.nickname,
head_pic:this.data.head_pic,
}
getApp().globalData.up_nick_avatar=ob;
getApp().goto('/packageE/pages/user/nick_avatar_add/nick_avatar_add');
},
//身份证号严格校验
IdentityIDCard: function (e) {
var code = e.detail.value;
//身份证号前两位代表区域
var city = {
11: "北京",
12: "天津",
13: "河北",
14: "山西",
15: "内蒙古",
21: "辽宁",
22: "吉林",
23: "黑龙江 ",
31: "上海",
32: "江苏",
33: "浙江",
34: "安徽",
35: "福建",
36: "江西",
37: "山东",
41: "河南",
42: "湖北 ",
43: "湖南",
44: "广东",
45: "广西",
46: "海南",
50: "重庆",
51: "四川",
52: "贵州",
53: "云南",
54: "西藏 ",
61: "陕西",
62: "甘肃",
63: "青海",
64: "宁夏",
65: "新疆",
71: "台湾",
81: "香港",
82: "澳门",
91: "国外 "
};
//身份证格式正则表达式
var idCardReg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;
var errorMess = ""; //错误提示信息
var isPass = true; //身份证验证是否通过(true通过、false未通过)
//如果身份证不满足格式正则表达式
if (!code || !idCardReg.test(code)) {
errorMess = "您输入的身份证号格式有误!";
isPass = false;
}
//区域数组中不包含需验证的身份证前两位
else if (!city[code.substr(0, 2)]) {
errorMess = "您输入的身份证号格式有误!";
isPass = false;
} else {
//18位身份证需要验证最后一位校验位
if (code.length == 18) {
code = code.split('');
//∑(ai×Wi)(mod 11)
//加权因子
var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
//校验位
var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
var sum = 0;
var ai = 0;
var wi = 0;
for (var i = 0; i < 17; i++) {
ai = code[i];
wi = factor[i];
sum += ai * wi;
}
var last = parity[sum % 11];
if (parity[sum % 11] != code[17]) {
errorMess = "您输入的身份证号不存在!";
isPass = false;
}
}
;
}
;
var returnParam = {
'errorMess': errorMess,
'isPass': isPass
};
if (errorMess != "") {
// wx.showModal({
// title: errorMess,
// content: '',
// showCancel: false,
// confirmText: '确定',
// confirmColor: '',
// success: function(res) {},
// fail: function(res) {},
// complete: function(res) {},
// })
getApp().my_warnning(errorMess, 0, this);
this.setData({
id: null,
});
}
;
return returnParam;
},
//------初始化加载----------
onLoad: function (t) {
self = this;
let url1 = '/api/weshop/storeconfig/get/';
let url3 = '/api/weshop/users/getErpvipidPickup';
url1 += r.stoid;
if(t.is_reg){
this.data.is_reg=1;
}
var uu = getApp().globalData.zc_dd;
if (uu) {
this.setData({head_pic: uu.head_pic, nickname: uu.nickname})
}
if (getApp().globalData.first_leader) {
//--生成会员 --
getApp().promiseGet("/api/weshop/users/get/" + r.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
if (res.data.code == 0) {
//更新会员
self.setData({
fir_user: res.data.data
})
}
})
}
app.request.get(url1, {
success: async function (res) {
if (res.data.code == 0) {
let reg_type = res.data.data.reg_type;
let reg_info = res.data.data.reg_info;
if (reg_type) { //reg_type为1才显示积分信息
if (reg_info) {
reg_info = JSON.parse(reg_info);
var user_id = 0;
//-- 获取会员信息 -
await getApp().request.promiseGet("/api/weshop/users/page", {
data: {
store_id: r.stoid, mobile: uu.mobile
}
}).then(res => {
if (ut.ajax_ok(res)) {
user_id = res.data.data.pageData[0].user_id;
}
})
if (reg_info.reginfo_coupon) {
//判断有没有领过券
self.check_is_send_quan(reg_info.reginfo_coupon, user_id);
}
if (reg_info.reginfo_lb_id) {
//判断有没有领过礼包
self.check_is_send_libao(reg_info.reginfo_lb_id, user_id);
}
}
}
self.setData({
reg_type,
reg_info,
});
}
},
});
//----获取系统参数-----
getApp().getConfig2(function (e) {
var json_d = JSON.parse(e.switch_list);
console.log('获取系统参数1');
console.log(json_d);
if (json_d.user_label_set==1) {
self.setData({is_lable_set: 1})
}
}, 1)
//-- 获取线下会员的情况 --
var req_data = {
stoid: r.stoid,
mobile: getApp().globalData.zc_dd.mobile
};
if (getApp().globalData.zc_dd.first_leader)
req_data.first_leader = getApp().globalData.zc_dd.first_leader
wx.showLoading();
getApp().request.promiseGet(url3, {data: req_data}).then(res => {
if (res.data.code == 0) {
var back_data = res.data.data;
back_data = JSON.parse(back_data);
var set_data = {is_fx: 0};
//-- 如果有包含会员的线下的信息 --
if (back_data && back_data.erpviplist) {
//-- data.data就是门店的数据 --
if (back_data.data) {
back_data.erpviplist.pickup_id = back_data.data.pickup_id;
if (!back_data.erpviplist.pick) set_data.is_fx = 1;
set_data.stoname = back_data.data.pickup_name;
set_data.sto_sele_id = back_data.data.pickup_id;
}
//-- 推荐人姓名 --
if (back_data.erpviplist.fromuser) {
set_data.tjrname = back_data.erpviplist.fromuser;
back_data.erpviplist.fromuser_id = back_data.erpviplist.fromuser;
}
//性别
if (back_data.erpviplist.sex) set_data.isGender = back_data.erpviplist.sex;
//名称
if (back_data.erpviplist.vipname) set_data.name = back_data.erpviplist.vipname;
//身份证
if (back_data.erpviplist.idcard) set_data.id = back_data.erpviplist.idcard;
//地址
if (back_data.erpviplist.address) set_data.address = back_data.erpviplist.address;
//生日
if (back_data.erpviplist.birthday) {
set_data.datet = back_data.erpviplist.birthday;
set_data.isLunar = back_data.erpviplist.islunar;
} else {
//----获取系统参数-----
getApp().getConfig2(function (e) {
var json_d = JSON.parse(e.switch_list);
console.log('获取系统参数1');
console.log(json_d);
if (json_d.is_brithday != 1) {
self.setData({isLunar: 1})
}
if (json_d.user_label_set==1) {
self.setData({is_lable_set: 1})
}
}, 1)
}
set_data.user = back_data.erpviplist;
}
else{
//----获取系统参数-----
getApp().getConfig2(function (e) {
var json_d = JSON.parse(e.switch_list);
if (json_d.is_brithday != 1) {
self.setData({isLunar: 1})
}
}, 1)
}
//-- 新的会员 --
if (back_data && back_data.data && back_data.data.pickup_id && !set_data.sto_sele_id) {
set_data.stoname = back_data.data.pickup_name;
set_data.sto_sele_id = back_data.data.pickup_id;
}
self.setData(set_data);
if (!self.data.sto_sele_id) {
self.get_store_set();
}
} else {
//----获取系统参数-----
getApp().getConfig2(function (e) {
var json_d = JSON.parse(e.switch_list);
console.log('获取系统参数2');
console.log(json_d);
if (json_d.is_brithday != 1) {
self.setData({isLunar: 1})
}
if (json_d.user_label_set==1) {
self.setData({is_lable_set: 1})
// if (json_d.is_bq_must==1) {
// self.setData({is_bq_must: 1})
// }
}
}, 1)
}
wx.hideLoading();
})
var is_back = t.is_back;
if (is_back) this.data.is_back = 1;
},
onShow: function () {
getApp().check_can_share();
if (this.data.is_zy) return false;
//如果有传值进行跳转的话
var choice_guide = null;
if (getApp().globalData.choice_guide) {
choice_guide = JSON.parse(JSON.stringify(getApp().globalData.choice_guide));
getApp().globalData.choice_guide = null;
}
//获取头像和昵称
let nick_obj = wx.getStorageSync('nick_obj')
if (nick_obj && nick_obj.head_pic && nick_obj.nickname) {
this.setData({head_pic: nick_obj.head_pic, nickname: nick_obj.nickname})
wx.removeStorageSync('nick_obj')
}
},
getIsBool(){
getApp().request.get("/api/weshop/users/grade/vip/init/get", {
data: {
storeId: r.stoid,
},
success: function(su) {
var isBool = su.data.data.isBool;
th.setData({
isBool: isBool
});
}
})
},
check_is_send_quan: function (cid, uid) {
var self = this;
let url2 = '/api/weshop/prom/coupon/get/';
//-- 如果没有会员信息的时候 --
if (!uid) {
//获取优惠券
url2 += cid;
app.request.get(url2, {
success: function (r) {
if (r.data.code == 0) {
self.setData({
couponInfo: r.data.data.name,
});
}
;
},
});
} else {
//看一下会员有没有领过注册的券
getApp().promiseGet("/api/weshop/couponList/page", {
data: {store_id: r.stoid, uid: uid, cid: cid}
}).then(res => {
var is_ling = 0;
if (res.data.code == 0 && res.data.data && res.data.data.total > 0) {
is_ling = 1;
}
//没有领过券,就显示
if (!is_ling) {
//获取优惠券
url2 += cid;
app.request.get(url2, {
success: function (r) {
if (r.data.code == 0) {
console.log('000res==>', r.data.data.name);
self.setData({
couponInfo: r.data.data.name,
});
}
;
},
});
}
})
}
},
//-- 有没有送过礼包 --
check_is_send_libao: function (lbid, uid) {
var self = this;
let url2 = '/api/weshop/marketing/giftbag/get';
if (!uid) {
//获取礼包
app.request.get(url2, {
data: {storeId: r.stoid, giftBagId: lbid},
success: function (r) {
if (r.data.code == 0) {
console.log('000res==>', r.data.data.name);
self.setData({
libao: r.data.data.lbTitle,
});
}
}
});
} else {
//看一下会员有没有领过注册的券
getApp().promiseGet("/api/weshop/marketing/gift/getgiveone", {
data: {store_id: r.stoid, user_id: uid, lbid: lbid, act_type: 7}
}).then(res => {
var is_ling = 0;
//-1就表示有领过
if (res.data.code == -1) {
is_ling = 1;
}
//没有领过礼包,就显示
if (!is_ling) {
//获取礼包
app.request.get(url2, {
data: {storeId: r.stoid, giftBagId: lbid},
success: function (r) {
if (r.data.code == 0) {
self.setData({
libao: r.data.data.lbTitle,
});
}
}
});
}
})
}
},
//------卡片的显示和关闭--------
show_tc: function () {
if (!getApp().globalData.userInfo) return false;
//base64_encode($user.mobile.'|'.date('Y-m-d H:i:s')
var val = getApp().globalData.userInfo.mobile + "|" + ut.formatTime();
val = "^" + ut.base64_encode(val);
qrcode('qrcode', val, 480, 480, this);
this.setData({
tc_hide: false,
});
},
hide_tc: function () {
this.setData({
tc_hide: true,
});
},
//地址
address: function (e) {
var val = e.detail;
this.setData({
address: val.value
});
},
//点击确认修改信息
confirm_revision: function () {
var th = this;
var isstcsp = th.data.isstcsp; //是否启用消费密码
var phone = th.data.phone; //手机号码
if (phone == "" || phone == null) {
getApp().my_warnning("手机不能为空", 0, th);
return false;
}
var consumption = th.data.consumption; //消费密码
var isstcsp = th.data.isstcsp;
if (isstcsp == 1) {
if (consumption == null || consumption == "" || consumption == undefined) {
getApp().my_warnning("消费密码不能为空", 0, th);
return false;
}
if (consumption.length < 6) {
getApp().my_warnning("消费密码不能小于6位", 0, th);
return false;
}
}
var sex = th.data.isGender; //性别
if (sex != "1" && sex != "2") {
getApp().my_warnning("请选择性别", 0, th);
return false;
}
var user_name = th.data.user.vipname; //用户姓名
if (user_name == "" || user_name == null) {
getApp().my_warnning("请输入名字", 0, th);
return false;
}
var identity_card = th.data.identity_card; //身份证
if (identity_card != null && identity_card != undefined && identity_card != "" && !(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(identity_card))) {
getApp().my_warnning("身份证号码错误", 0, th);
return false;
}
var address = th.data.address; //地址
var sto_sele_id = th.data.sto_sele_id;
var datas = {
mobile: phone, //手机号码
store_id: r.stoid,
user_id: getApp().globalData.user_id,
vipnopwd: isstcsp,
vippass: consumption, //消费密码
sex: sex, //性别
vipname: user_name, //昵称
idcard: identity_card, //身份证
address: address, //地址
pickup_id: sto_sele_id,//自提门店 所属门店
islunar: th.data.iscalendar,
birthday: th.data.datet
}
//往上提交美导的ID
if (th.data.fir_guide_id != th.data.user.staffId) {
datas.staffId = th.data.user.staffId;
}
var post_data = {...getApp().globalData.zc_dd, ...datas}
if (this.data.is_lable_set) {
getApp().globalData.zc_dd = post_data;
var g_url="/packageE/pages/user/labels/labels?pageType=1";
if(th.data.is_reg){
g_url+="&is_reg=1";
}
wx.redirectTo({
url:g_url
})
}else{
this.zu_ce(post_data);
}
},
zu_ce: function (dd) {
var th = this;
wx.showLoading({
title: "处理中.",
mask: true
})
app.request.get("/api/weshop/users/thirdLogin", {
data: dd,
success: function (e) {
wx.hideLoading();
th.setData({loading: 0});
if (e.data.code == 0) {
app.globalData.user_id = e.data.data.user_id;
}
else if(e.data.code==-3){
wx.showModal({
title: e.data.msg,
success: function (e) {
if(e.confirm){
dd.isreplacemobile=1;
if (th.data.loading) return false;
th.setData({loading: 1});
th.zu_ce(dd);
}
}
});
return false;
}
else {
return app.my_warnning("授权登入失败!" + e.data.msg,0,th);
}
getApp().globalData.login_back = 1;
wx.setStorageSync("userinfo", e.data.data);
wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = s.getFullUrl(a.globalData.userInfo.head_pic);
//wx.navigateBack({delta: 1})
//-- 看情况,是跳转等级卡,还是跳转到新人有礼 --
getApp().go_to_page(th.data.is_reg,function (){
wx.navigateBack({ delta: 1 })
})
},
failStatus: function (t) {
wx.hideLoading();
th.setData({loading: 0});
return app.my_warnning("授权登入失败,请稍后再试!", 0, that);
},
fail: function (t) {
wx.hideLoading();
th.setData({loading: 0});
return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1;
}
});
},
//选择地址
goto_address: function () {
// this.setData({ is_zy: 1 });
},
//--点击分享事件---
onShareAppMessage: function (t) {
getApp().globalData.no_clear = 1
return o.share;
},
//-- 跳转到获取导购的列表 --
go_get_guide: function () {
this.check_click_ok(function () {
getApp().goto("/packageB/pages/user/choice_guide/choice_guide");
}, 1)
},
//点击门店,导购的次数判断, type 1=导购 2=门店
check_click_ok: function (func, idx) {
var th = this;
var userId = getApp().globalData.user_id;
getApp().request.get("/api/weshop/users/getGuideNum/" + r.stoid + "/" + userId + "/" + idx, {
success: function (res) {
if (res.data.code == 0) {
func();
} else {
getApp().my_warnning(res.data.msg, 0, th);
}
}
});
},
//获取输入框内容
getInput(e) {
return e.detail.value;
},
verifyInput(e) {
let value = e.detail.value;
if (value == "" || value == null || value == undefined) {
app.my_warnning("请输入", 0, this);
}
},
//获取推荐人
getReferee(e) {
let referee = this.getInput(e);
this.data.referee = referee;
console.log(referee);
},
//获取姓名
getName(e) {
let name = this.getInput(e);
this.data.name = name;
},
//获取性别
getGender(e) {
let sex = e.currentTarget.dataset.sex;
this.setData({
isGender: sex,
});
},
//获取身份证
getId(e) {
let id = this.getInput(e);
this.data.id = id;
},
//验证身份证号码
// verifyId(e) {
// let id = this.data.id;
// if(id) {
// if (id != null && id != undefined && id != "" && !(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(id))) {
// getApp().my_warnning("身份证号码无效!", 0, this);
// }
// };
// },
//获取地址
getAddress(e) {
let address = this.getInput(e);
this.data.address = address;
},
//获取生日
getbind(e) {
console.log("获取生日222222222");
console.log(e);
let b = this.getInput(e);
let reg=/^[0-9\-]*$/
// let reg=/^\d{4}-\d{1,2}-\d{1,2}$/
if (!(reg.test(b))){
return this.data.oldbirthday
}
let length = b.length;
let oldBirtthDayLength=this.data.oldBirtthDayLength
if (length > oldBirtthDayLength) {
if (b.length==4) {
b+='-'
}
if (b.length==5 && b[4]!='-') {
return this.data.oldbirthday
}
if (b.length==8 && b[7]!='-') {
return this.data.oldbirthday
}
if (b.length==6 && b[5] >1) {
let lb = b.split('');
lb.splice(5, 0, 0);
b = lb.join('');
b+='-'
// console.log(b[5]);
// return this.data.oldbirthday
}
if (b.length==7) {
if (b[6]=='-') {
let lb = b.split('');
lb.splice(5, 0, 0);
b = lb.join('');
}else{
let s=b[5]+b[6]
if (s*1>12) {
return this.data.oldbirthday
}
b+='-'
}
}
if (b.length==10) {
let a=b[8]+b[9];
if (a*1>31) {
return this.data.oldbirthday
}
}
}
this.setData({
datet: b,
oldBirtthDayLength:length,
oldbirthday:b
});
},
//获取生日
bindChange: function (e) {
console.log("获取生日11111111");
console.log(e);
let strBirthday = e.detail.value;
let age = this.verifyBirthday(strBirthday);
if (age <= 10) {
app.my_warnning("会员年龄不能小于10岁(含10岁)", 0, this);
this.setData({
datet: '',
});
} else if (age >= 70) {
app.my_warnning("会员年龄不能超过70岁(含70岁)", 0, this);
this.setData({
datet: '',
});
} else {
let value = e.detail.value
if (value.length==8) {
value+='01'
}
if (value.length==7) {
value+='-01'
}
if (value.length==9) {
let ov=value[value.length-1]
let nv=value.slice(0,-1)
if (ov==0) {
nv+='01'
}else{
nv+='0'+ov
}
value=nv
}
// let reg= /^(\d{4})-(\d{2})-(\d{2})$/;
let reg= /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/
console.log('日期验证');
console.log(value);
console.log(reg.test(value));
if (reg.test(value)) {
this.setData({
datet: value,
});
}else{
app.my_warnning("出生日期格式不对", 0, this);
this.setData({
datet: '',
});
}
}
},
// 生日判断
verifyBirthday(strBirthday) {
var returnAge;
var strBirthdayArr = strBirthday.split("-");
var birthYear = strBirthdayArr[0];
var birthMonth = strBirthdayArr[1];
var birthDay = strBirthdayArr[2];
d = new Date();
var nowYear = d.getFullYear();
var nowMonth = d.getMonth() + 1;
var nowDay = d.getDate();
if (nowYear == birthYear) {
returnAge = 0;//同年 则为0岁
} else {
var ageDiff = nowYear - birthYear; //年之差
if (ageDiff > 0) {
if (nowMonth == birthMonth) {
var dayDiff = nowDay - birthDay;//日之差
if (dayDiff < 0) {
returnAge = ageDiff - 1;
} else {
returnAge = ageDiff;
}
} else {
var monthDiff = nowMonth - birthMonth;//月之差
if (monthDiff < 0) {
returnAge = ageDiff - 1;
} else {
returnAge = ageDiff;
}
}
} else {
returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天
}
}
return returnAge;//返回周岁年龄
},
//是否为农历
isLunar(e) {
let isLunar = null;
if (e.detail.value[0]) {
isLunar = 1;
} else {
isLunar = 0;
}
this.data.isLunar = isLunar;
// console.log(isLunar);
},
// 是否同意协议
isAgree(e) {
let isAgree = null;
if (e.detail.value[0]) {
isAgree = true;
} else {
isAgree = false;
}
// this.data.isAgree = isAgree;
this.setData({
isAgree,
});
console.log(isAgree);
},
//保存
save: function () {
var th = this;
var sto_sele_id = this.data.sto_sele_id;
var user = app.globalData.userInfo;
var data = {
store_id: r.stoid,
};
//-- 需要推荐人 --
if (this.data.reg_info.introducer_state) {
var tj = this.data.fir_user ? this.data.fir_user.mobile : '';
if (!tj) {
tj = this.data.user && this.data.user['fromuser_id'] ? this.data.user['fromuser_id'] : '';
}
let tjrname = this.data.referee || tj;
if (tjrname == "" || tjrname == null) {
//app.my_warnning("请输入推荐人", 0, this);
//return false;
}
if (tjrname) data.tjrname = tjrname;
}
//-- 需要姓名 --
if (this.data.reg_info.name_state) {
let vipname = this.data.name;
if (vipname == "" || vipname == null) {
app.my_warnning("请输入姓名", 0, this);
return false;
}
data.vipname = vipname;
}
//需要性别
if (this.data.reg_info.sex_state) {
let sex = this.data.isGender;
if (sex != "1" && sex != "2") {
app.my_warnning("请选择性别", 0, this);
return false;
}
data.sex = sex;
}
//需要生日
if (this.data.reg_info.birthday_state) {
let birthday = this.data.datet;
if (birthday == "" || birthday == null) {
app.my_warnning("请选择出生日期", 0, this);
return false;
}
data.birthday = birthday;
data.islunar = self.data.isLunar ? 1 : 0;
}
//-- 需要身份证 --
if (this.data.reg_info.idcard_state) {
let idcard = this.data.id;
if (idcard == "" || idcard == null) {
app.my_warnning("请输入身份证号码", 0, this);
return false;
}
data.idcard = idcard;
}
//需要地址
if (this.data.reg_info.address_state) {
let address = this.data.address;
if (address == "" || address == null) {
app.my_warnning("请输入地址", 0, this);
return false;
}
data.address = address;
}
//需要门店
if (this.data.reg_info.pick_state) {
let pickup_id = sto_sele_id;
if (pickup_id == "" || pickup_id == null) {
app.my_warnning("请输入门店", 0, this);
return false;
}
data.pickup_id = sto_sele_id;
}
let isAgree = this.data.isAgree;
if (!isAgree) {
app.my_warnning("请您先阅读和勾选指定的内容", 0, this);
return false;
}
let uu = getApp().globalData.zc_dd;
uu.head_pic=this.data.head_pic
uu.nickname=this.data.nickname
getApp().globalData.zc_dd=uu
var post_data = {...getApp().globalData.zc_dd, ...data};
delete post_data.sessionKey;
delete post_data.encryptedData;
delete post_data.iv;
if (th.data.loading) return false;
th.setData({loading: 1});
if (this.data.is_lable_set) {
getApp().globalData.zc_dd = post_data;
var g_url="/packageE/pages/user/labels/labels?pageType=1";
if(th.data.is_reg){
g_url+="&is_reg=1";
}
wx.redirectTo({
url: g_url
})
}else{
this.zu_ce(post_data);
}
// this.zu_ce(post_data);
},
get_store_set: function () {
var th = this;
//如果是扫码进来的
if (getApp().globalData.store_number) {
var dd = {
store_id: r.stoid,
isstop: 0,
pageSize: 1,
page: 1,
pickup_no: getApp().globalData.store_number
};
//获取扫码的门店
getApp().request.promiseGet("/api/weshop/pickup/list", {
data: dd,
}).then(res => {
if (ut.ajax_ok(res)) {
var top_store = res.data.data.pageData[0];
th.setData({
stoname: top_store.pickup_name,
sto_sele_name: top_store.pickup_name,
sto_sele_id: top_store.pickup_id,
sto_sele_distr: top_store.distr_type,
})
}
})
} else {
wx.getLocation({
type: 'gcj02',
success: function (res) {
th.data.lat = res.latitude;
th.data.lon = res.longitude;
th.set_fir_store_to_def();
},
fail: function (res) {
if (res.errCode == 2) {
getApp().confirmBox("请开启GPS定位", null, 25000, !1);
}
}
})
}
},
//-- 设置最近的店为默认的店,一开始加载的时候 --
set_fir_store_to_def() {
var th = this;
var dd = {
store_id: r.stoid,
isstop: 0,
pageSize: 1,
page: 1,
};
dd.lat = th.data.lat;
dd.lon = th.data.lon;
var top_store = getApp().globalData.pk_store;
if (top_store) {
dd.pickup_id = top_store.pickup_id;
}
//----------获取门店,最近的门店----------------
getApp().request.promiseGet("/api/weshop/pickup/list", {
data: dd,
}).then(res => {
if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
var top_store = res.data.data.pageData[0];
th.setData({
stoname: top_store.pickup_name,
sto_sele_name: top_store.pickup_name,
sto_sele_id: top_store.pickup_id,
sto_sele_distr: top_store.distr_type,
})
}
})
},
//获取搜索门店输入的值
input_store: function (e) {
this.setData({
keyword: e.detail.value
})
},
//搜索门店
searchfn() {
let choice_sort_store = this.data.choice_sort_store
if (choice_sort_store == 0) { //全局搜索
let all_pick_list = this.data.all_pick_list
let def_pickpu_list = this.data.def_pickpu_list
let keyword = this.data.keyword
if (keyword) {
let arr = all_pick_list.filter(item => {
let i = item.pickup_name.indexOf(keyword)
if (i > -1) {
return true
} else {
return false
}
})
if (arr && arr.length > 0) {
if (this.data.is_show_sto_cat == 1) {
this.setData({
def_pickpu_list: arr
})
} else {
this.setData({
only_pk: arr
})
}
} else {
wx.showToast({
title: '没有搜索到门店',
icon: 'none',
duration: 2000
})
}
} else {
if (this.data.is_show_sto_cat == 1) {
this.setData({
def_pickpu_list: all_pick_list.slice(0, 10)
})
} else {
this.setData({
only_pk: all_pick_list
})
}
}
} else { //分类下搜索
let sec_i = this.data.sec_i
let all_sto = this.data.all_sto
let old_all_sto = this.data.old_all_sto
if (!old_all_sto) {
this.setData({
old_all_sto:JSON.parse(JSON.stringify(all_sto))
})
}
let sec_sto = this.data.sec_sto
let sec_arr = this.data.old_all_sto[sec_i].s_arr
let keyword = this.data.keyword
let text = 'sec_sto.s_arr'
if (keyword) {
let arr = sec_arr.filter(item => {
let i = item.pickup_name.indexOf(keyword)
if (i > -1) {
return true
} else {
return false
}
})
if (arr && arr.length > 0) {
this.setData({
[text]: arr
})
} else {
wx.showToast({
title: '没有搜索到门店',
icon: 'none',
duration: 2000
})
}
} else {
if(this.data.old_all_sto){
this.setData({
[text]: this.data.old_all_sto[sec_i].s_arr
})
}else{
this.setData({
[text]: all_sto[sec_i].s_arr
})
}
}
}
},
});