shop.Decoration.js
85.8 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
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
webpackJsonp([13],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
//店铺装修
'use strict';
var $ = __webpack_require__(1),
common=__webpack_require__(2);
var g; //grid
var curDialogId; //当前打开的编辑弹层ID
var curPlatform = "pc"; //当前渲染页面用的模板名称
var curTemplateType = "2"; //当前模板类型 1:基础模板,2:经典模板
var shopType = 1; //店铺类型 1:单品牌,2:多品牌
var shopOperate = 'view'; //操作 editor:可编辑, view:查看不可编辑
var shopCategory = []; //店铺下所有的销售类目
var defaultSrc = "http://img01.yohoboys.com/staticimg/2016/05/19/15/01091c21f2317a64f123f1649fbbccf7ba.png"; //初始化默认图片路径
var ENUM = {
"editor-largePic":{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0},
"editor-largePic2":{"position":"", "data":[{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0}]},
"editor-smallPic":{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0},
"editor-brand":{"position":"", "name":"", "url":""},
"editor-recommend": {"position":"", "name":"", "enName":"", "src":"", "url":""},
"editor-hotRecommend":{"position":"", "src":"", "url":""},
"editor-signboard":{"position":"", "src":"", "url":"","startTime": "","endTime": "","publishStatus": 0},
"editor-newGoodTab":{"position":"", "name":"", "url":""},
"editor-hotGoodTab":{"position":"", "name":"", "url":""},
"editor-newProduct":{"productId":"", "position":"", "productName":"", "productSkn":"", "salesPrice":"", "src":"", "url":""},
"editor-hotProduct":{"productId":"", "position":"", "productName":"", "productSkn":"", "salesPrice":"", "src":"", "url":""}
}; //添加一条不同弹层使用的初始化模板
var resourcesNew = {
"shopTopBanner":{
"id":"",
"data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}]
},
"shopTopBanner_base":{
"id":"",
"data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}]
},
"navigationBar":{
"id":"",
"data": [{"name":"",url:""}, {"name":"",url:""}, {"name":"",url:""}]
},
"largeSlideImg":{
"id":"",
"data": [{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}]
},
"oneRowTwoColImages":{
"id":"",
"data": [
{"position": 2, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]},
{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}
]
},
"brandBrowse":{
"id":"",
"title":"品牌集合",
"data": []
},
"recommend":{
"id":"",
"title":"经典推荐",
"data": [{"position":1, "name":"默认商品", "enName":"", "src":defaultSrc, "url":""}]
},
"hotRecommend":{
"id":"",
"title":"",
"data": [{"position":1, "src":defaultSrc, "url":""}]
},
"signboard":{
"id":"",
"data": [{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}]
},
"goodsTabBar":{
"id":"",
"data": {
"new":[{"position":0, "name":"MORE", "url":""}],
"hot":[{"position":0, "name":"MORE", "url":""}]
}
},
"newProducts":{
"id":"",
"data": []
},
"hotProducts":{
"id":"",
"data": []
},
"allNewProducts":{
"id":"",
"data":[]
},
"allHotProducts":{
"id":"",
"data":[]
},
"shopTopBanner_APP":{
"id":"",
"isUsed":"N",
"data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}]
},
"oneRowTwoColImages_APP":{
"id":"",
"isUsed":"N",
"data": [
{"position": 2, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]},
{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}
]
},
"hotProducts_APP":{
"id":"",
"isUsed":"N",
"data": []
},
"allHotProducts_APP":{
"id":"",
"data":[]
},
"largeSlideImg_APP":{
"id":"",
"isUsed":"N",
"data": [{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}]
},
"recommend_APP":{
"id":"",
"isUsed":"N",
"isDisplay":1,
"data": [{"position":1, "name":"默认商品", "enName":"", "src":defaultSrc, "url":""}]
}
} //初始化装修信息json
var shopsId, _id, jsonMain, jsonClone;
getParams();
findDecoration();
/********************主流程*********************/
//URL获取参数
function getParams(){
var paramUrl = location.href + "";
var param = paramUrl.substring(paramUrl.indexOf("decorationDetail"));
var paramList = param.split("/");
if(paramList){
shopsId = paramList[1];
shopType = paramList[2];
shopOperate = paramList[3];
_id = paramList[4];
}
if(shopOperate == 'editor'){
$(".moduleSubmite").show().siblings().hide();
}else if(shopOperate == 'view'){
$(".tabheader").hide();
$(".moduleView").show().siblings().hide();
}else if(shopOperate == 'check'){
$(".tabheader").hide();
$(".moduleCheck").show().siblings().hide();
}
}
//json渲染模板
function showMain(){
// tab自动选中基础模板,经典模板
$('.tabheader .nav').find("li[data-toggle='"+ curTemplateType +"']").addClass("active");
// radio自动选中pc端或者app端
$('.moduleTypeView').find("input[name='brandLevel'][value='"+ curPlatform +"']").attr("checked","checked");
//渲染装修模板
if(curTemplateType == 1){
$('#main').empty().html(common.util.__template2($("#"+curTemplateType+"-pc").html(),jsonMain));
}else if(curTemplateType == 2){
$('#main').empty().html(common.util.__template2($("#"+curTemplateType+"-"+curPlatform).html(),jsonMain));
}
//基础模板不显示pc端跟app端
if(curTemplateType == "1"){
$(".moduleTypeView").hide();
}else{
$(".moduleTypeView").show();
}
//单品牌,多品牌
if(shopType == 2){
$(".model-brand").show();
}else if(shopType == 1){
$(".model-brand").hide();
}
//标签长度样式自适应
$.each($(".contentpanel-pc .model-showTitle .showTab"),function(){
if($(this).width() > 280){
$(this).css("right",(280-($(this).width()))+"px");
}
})
showEditorIconEvent();
}
//弹窗编辑主流程
function editorIconEvent(title,id){
$('.editorIcon').on('click',function(){
var content_option = getDialogOption(title);
curDialogId = id;
var option = {
title:title,
content:content_option + "<div class='editorTitle'></div><div class='editor-dialog' id='"+ id +"'></div><div class='editorTip'></div> ",
width:'70%',
button:[
{
value:"取消",
callback:function(){
if(curDialogId != "editor-brand-app"){
freshJson(id, g.__rows, 0);
}
}
},
{
value:"确认",
css:"btn-info",
callback:function(){
if(editorCheck(id)){
if(curDialogId != "editor-brand-app"){
freshJson(id, g.__rows, 1);
}
showMain();
}else{
return false;
}
}
}
]
}
if(curPlatform == "pc"){
option = setSendToAppBtm(id, option);
}
new common.dialog(option);
gridInit(id);
untilEditorEvent(id);
editorTipInit(id);
})
}
// "热门品类"编辑页面上,增加 显示/隐藏 选择项
function getDialogOption(title) {
if(title != '热门品类编辑') {
return "";
}
var showInApp = 1;
var data = jsonClone.resources.recommend_APP;
if(data) {
showInApp = data.isDisplay;
}
var showRecommendOption = "";
var hideRecommendOption = "";
if(1 === showInApp) {
showRecommendOption = "<label for='recommandradioY' class='radio-inline'><input type='radio' id='recommandradioY' name='recommandradio' value='1' checked>显示</label>";
hideRecommendOption = "<label for='recommandradioN' class='radio-inline'><input type='radio' id='recommandradioN' name='recommandradio' value='0'>隐藏</label>";
} else {
showRecommendOption = "<label for='recommandradioY' class='radio-inline'><input type='radio' id='recommandradioY' name='recommandradio' value='1'>显示</label>";
hideRecommendOption = "<label for='recommandradioN' class='radio-inline'><input type='radio' id='recommandradioN' name='recommandradio' value='0' checked>隐藏</label>";
}
return "<div><label class='radio-inline'><span>显示/隐藏热门品类: </span></label>" + showRecommendOption + hideRecommendOption;
}
/********************接口Ajax*********************/
//Ajax查询
function findDecoration(){
console.log('1');
common.util.__ajax(
{
url:'/shop/ShopsDecoratorRest/findShopsDecoratorDetail',
data: {
"shopsId": shopsId
}
},
function(rs) {
console.log(rs.data);
if(rs.data){
jsonMain = rs.data;
}
//没有装修信息,初始化装修信息
if($.isEmptyObject(jsonMain.resources)){
jsonMain.resources = $.extend(true,{},resourcesNew);
}
//装修信息中品牌内容为空,初始化品牌
if(jsonMain.brandList){
if(jsonMain.resources.brandBrowse.data.length < 1){
cloneArr(jsonMain.brandList,jsonMain.resources.brandBrowse.data);
}
}else{
common.util.__tip("店铺没有品牌,无法装修,请返回添加品牌!");
return;
}
//初始化模板类型
if(jsonMain.templateType && jsonMain.templateType != "0"){
curTemplateType = jsonMain.templateType;
}
//装修json克隆
jsonClone = $.extend(true,{},jsonMain);
//最新上架,最热商品接口
if(shopOperate == 'editor'){
findShopCategory();
if(!jsonMain.resources.allNewProducts.data || jsonMain.resources.allNewProducts.data.length < 1){
findTopNewProducts();
}
if(!jsonMain.resources.allHotProducts.data || jsonMain.resources.allHotProducts.data.length < 1){
findTopHotProducts();
}
if(!jsonMain.resources.allHotProducts_APP.data || jsonMain.resources.allHotProducts_APP.data.length < 1){
findTopHotProducts_APP();
}
/*findTopNewProducts(); findTopHotProducts(); findTopHotProducts_APP();*/
}
showMain();
},true);
}
//Ajax查询店铺下销售类目
function findShopCategory() {
common.util.__ajax({
url:'/shops/shopCategory/list',
data: {
shopId: jsonMain.shopsId
}
},function(rs){
console.log(rs);
if(rs.data){
shopCategory = rs.data;
}
},true);
}
//Ajax最新上架商品
function findTopNewProducts(){
common.util.__ajax({
url:'/shop/ShopsDecoratorRest/findNewProductList',
data: {
"shopsId": jsonMain.shopsId,
"size": 20
}
},function(rs){
if(rs.data.product_list){
jsonMain.resources.allNewProducts.data = rs.data.product_list;
}
},true);
}
//Ajax热销商品
function findTopHotProducts(){
common.util.__ajax({
url:'/shop/ShopsDecoratorRest/findHotProductList',
data: {
"shopsId": jsonMain.shopsId,
"size": 20
}
},function(rs){
if(rs.data.product_list){
jsonMain.resources.allHotProducts.data = rs.data.product_list;
}
},true);
}
//Ajax热销商品---APP
function findTopHotProducts_APP(){
common.util.__ajax({
url:'/shop/ShopsDecoratorRest/findHotProductList',
data: {
"shopsId": jsonMain.shopsId,
"size": 20
}
},function(rs){
if(rs.data.product_list){
jsonMain.resources.allHotProducts_APP.data = rs.data.product_list;
}
},true);
}
//Ajax保存,暂存:100,提交审核:200
function saveDecoration(submitStatus){
console.log(jsonMain);
common.util.__ajax({
url:'/shop/ShopsDecoratorRest/saveShopsDecorator',
data: {
"submitStatus": submitStatus,
"shopsId": jsonMain.shopsId,
"platform": jsonMain.platform,
"templateType": jsonMain.templateType,
"resources": JSON.stringify(jsonMain.resources)
}
},function(rs){
if(rs.data){
if(submitStatus == 100){
jsonMain = rs.data;
jsonClone = $.extend(true,{},jsonMain);
showMain();
}else{
setTimeout(function() {
location.href="/supplier/shop/decoration";
}, 1000);
}
}
});
}
//Ajax审核,审核通过:300,驳回:900
function checkDecoration(checkStatus,comment){
if(comment){ //驳回
common.util.__ajax({
url:'/shop/ShopsDecoratorRest/auditShopsDecorator',
data: {
"id": _id,
"checkStatus": checkStatus,
"comment": comment
}
},function(rs){
common.util.__tip("审核驳回成功!","success");
setTimeout(function() {
location.href="/supplier/check/index";
}, 1000);
},true);
}else{ //通过
common.util.__ajax({
url:'/shop/ShopsDecoratorRest/auditShopsDecorator',
data: {
"id": _id,
"checkStatus": checkStatus
}
},function(rs){
common.util.__tip("审核通过成功!","success");
setTimeout(function() {
location.href="/supplier/check/index";
}, 1000);
},true);
}
}
/********************工具类*********************/
//弹层表单grid生成器
function gridInit(id){
switch (id){
//基础模板顶部banner
case "editor-banner-base":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"店铺banner图片", render:function(item){
return "<div><input type=file name='shopBannerImage' id='shopBannerImage_"+item.__index+"' value='"+item.shopSrc+"' /></div>" +
"<div style='color: #ec971f;clear: both;padding-top: 5px;'>* 店铺banner图片尺寸:1150*200</div>";
}},
{display:"是否显示店铺名称", render:function(item){
if(item.isShowShopName == "Y"){
return "<lable><input type='radio' name='isShowShopName' value='Y' checked='checked'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N'>不显示店铺名称</lable>";
}else{
return "<lable><input type='radio' name='isShowShopName' value='Y'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N' checked='checked'>不显示店铺名称</lable>";
}
}},
{display:"商品详情页banner图片", render:function(item){
return "<div><input type=file name='DetailbannerImage' id='DetailbannerImage_"+item.__index+"' value='"+item.detailSrc+"' /></div>" +
"<div style='color: #ec971f;clear: both;padding-top: 5px;'>* 商品详情页banner图片尺寸:1920*45</div>";
}}
]
});
g.__rows=""||jsonClone.resources.shopTopBanner_base.data;
g.init(g.__rows);
break;
//经典模板顶部banner
case "editor-banner":
if(curPlatform == "pc"){
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"店铺banner图片", render:function(item){
return "<div><input type=file name='shopBannerImage' id='shopBannerImage_"+item.__index+"' value='"+item.shopSrc+"' /></div>" +
"<div style='color: #ec971f;clear: both;padding-top: 5px;'>* 店铺banner图片尺寸:1150*200</div>";
}},
{display:"是否显示店铺名称", render:function(item){
if(item.isShowShopName == "Y"){
return "<lable><input type='radio' name='isShowShopName' value='Y' checked='checked'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N'>不显示店铺名称</lable>";
}else{
return "<lable><input type='radio' name='isShowShopName' value='Y'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N' checked='checked'>不显示店铺名称</lable>";
}
}},
{display:"商品详情页banner图片", render:function(item){
return "<div><input type=file name='DetailbannerImage' id='DetailbannerImage_"+item.__index+"' value='"+item.detailSrc+"' /></div>" +
"<div style='color: #ec971f;clear: both;padding-top: 5px;'>* 商品详情页banner图片尺寸:1920*45</div>";
}}
]
});
g.__rows=""||jsonClone.resources.shopTopBanner.data;
}
if(curPlatform == "app"){
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"店铺banner图片", render:function(item){
return "<input type=file name='shopBannerImage' id='shopBannerImage_"+item.__index+"' value='"+item.shopSrc+"' />";
}},
{display:"是否显示店铺名称", render:function(item){
if(item.isShowShopName == "Y"){
return "<lable><input type='radio' name='isShowShopName' value='Y' checked='checked'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N'>不显示店铺名称</lable>";
}else{
return "<lable><input type='radio' name='isShowShopName' value='Y'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N' checked='checked'>不显示店铺名称</lable>";
}
}}
]
});
g.__rows=""||jsonClone.resources.shopTopBanner_APP.data;
}
g.init(g.__rows);
break;
//店铺导航nav
case "editor-nav":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"编号", render:function(item){
return item.__index+1;
}},
{display:"名称", render:function(item){
return "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' data-index='"+item.__index+"' maxlength='5' />";
}},
{display:"链接", render:function(item){
// return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
}}
]
});
g.__rows=""||jsonClone.resources.navigationBar.data;
g.init(g.__rows);
break;
//店铺大图资源位
case "editor-largePic":
$('.editorTitle').html("<a href='javascript:' class='btn btn-success addBtn2' style='margin-right: 20px'><i class='fa fa-plus'></i> 添加资源大图</a><span class='largePicAddTip'></span>").css("margin-bottom","10px");
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
item.position=item.position || (item.__index+1);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{display:"<div class='row'><div class='col-sm-2'>图片</div><div class='col-sm-3'>链接</div><div class='col-sm-2'>开始时间</div><div class='col-sm-2'>结束时间</div> " +
"<div class='col-sm-1'>状态</div><div class='col-sm-2'>操作</div></div>",
render: function (item) {
return resourcesHtmlInit(item,"largePic");
}
},
{display:"操作", render:function(item){
if(g.__rows.length > 1){
return "<input type=button class='btn btn-warning btn-xs deleteBtn' style='margin-top:6px' value='删除' data-index='"+item.__index+"' />";
}
}}
]
});
if(curPlatform == "pc"){
g.__rows=""||jsonClone.resources.largeSlideImg.data;
}
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.largeSlideImg_APP.data;
}
g.init(g.__rows);
break;
//店铺小图资源位
case "editor-smallPic":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{
display:"<div class='row'><div class='col-sm-2'>图片</div><div class='col-sm-3'>链接</div><div class='col-sm-2'>开始时间</div><div class='col-sm-2'>结束时间</div> " +
"<div class='col-sm-1'>状态</div><div class='col-sm-2'>操作</div></div>",
render: function (item) {
return resourcesHtmlInit(item,"smallPic");
}
}
]
});
if(curPlatform == "pc"){
g.__rows=""||jsonClone.resources.oneRowTwoColImages.data;
}
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.oneRowTwoColImages_APP.data;
}
g.init(g.__rows);
break;
//品牌一览
case "editor-brand":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
item.position=item.position || (item.__index+1);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{display:"名称", render:function(item){
return item.brandName;
}},
]
});
// 品牌一览标题可编辑
$('.editorTitle').html("<div class='form-inline' style='margin-bottom: 10px'><label>标题名称编辑:</label><input class='form-control' type=text name='title' value='"+ jsonMain.resources.brandBrowse.title +"' /></div> ");
g.__rows=""||jsonClone.resources.brandBrowse.data;
g.init(g.__rows);
break;
//经典推荐recommend
case "editor-recommend":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
item.position=item.position || (item.__index+1);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{display:"名称", render:function(item){
return "<div style='width: 5%; float: left; line-height: 40px; color: #ff0000'>*</div><div style='width: 95%; float: left'>" +
"<input class='form-control inputChange' type=text name='name' value='"+item.name+"' placeholder='中文' data-index='"+item.__index+"' />" +
"<input class='form-control inputChange' style='margin-top:10px' type=text name='enName' value='"+item.enName+"' placeholder='英文' data-index='"+item.__index+"' />" +
"</div>";
}},
{display:"图片", render:function(item){
return "<input type=file name='recommendImage' id='recommendImage_"+item.__index+"' value='"+item.src+"' />";
}},
{display:"链接", render:function(item){
// return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
}},
{display:"操作", render:function(item){
var htmlPic = "",i=item.__index;
if(g.__rows.length == 1){
htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />";
}
if(g.__rows.length > 1){
if(i == (g.__rows.length-1) && i < 15){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />";
}
if(i == (g.__rows.length-1) && i >= 15){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
}
if(i < (g.__rows.length-1)){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' />";
}
}
return htmlPic;
}}
]
});
if(curPlatform == "pc"){
$('.editorTitle').html("<div class='form-inline' style='margin-bottom: 10px'><label>标题名称编辑:</label><input class='form-control' type=text name='title' value='"+ jsonMain.resources.recommend.title +"' /></div> ");
g.__rows=""||jsonClone.resources.recommend.data;
}
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.recommend_APP.data;
}
g.init(g.__rows);
break;
//热销推荐hotRecommend
case "editor-hotRecommend":
$('.editorTitle').html("<div class='form-inline' style='margin-bottom: 10px'><label>标题名称编辑:</label><input class='form-control' type=text name='title' value='"+ jsonMain.resources.hotRecommend.title +"' /></div> ");
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
item.position=item.position || (item.__index+1);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{display:"图片", render:function(item){
return "<input type=file name='signboardImage' id='hotRecommendImage_"+item.__index+"' value='"+item.src+"' />";
}},
{display:"链接", render:function(item){
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
// return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
}},
{display:"操作", render:function(item){
var htmlPic = "",i=item.__index;
if(g.__rows.length == 1){
htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />";
}
if(g.__rows.length > 1){
if(i == (g.__rows.length-1) && i < 5){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />";
}
if(i == (g.__rows.length-1) && i >= 5){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
}
if(i < (g.__rows.length-1)){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' />";
}
}
return htmlPic;
}}
]
});
g.__rows=""||jsonClone.resources.hotRecommend.data;
g.init(g.__rows);
break;
//水牌signboard
case "editor-signboard":
$('.editorTitle').html("<a href='javascript:' class='btn btn-success addBtn2' style='margin-right: 20px'><i class='fa fa-plus'></i> 添加水牌</a><span class='largePicAddTip'></span>").css("margin-bottom","10px");
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
item.position=item.position || (item.__index+1);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{display:"<div class='row'><div class='col-sm-2'>图片</div><div class='col-sm-3'>链接</div><div class='col-sm-2'>开始时间</div><div class='col-sm-2'>结束时间</div> " +
"<div class='col-sm-1'>状态</div><div class='col-sm-2'>操作</div></div>",
render: function (item) {
return resourcesHtmlInit(item,"signboard");
}
},
{display:"操作", render:function(item){
if(g.__rows.length > 1){
return "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' />";
}
}}
]
});
g.__rows=""||jsonClone.resources.signboard.data;
g.init(g.__rows);
break;
//新品上架标签tab
case "editor-newGoodTab":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
if(item.__index == 0){
return item.position;
}else{
item.position=item.position || (item.__index);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}
}},
{display:"名称", render:function(item){
if(item.__index == 0){
return item.name;
}else{
return "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' data-index='"+item.__index+"' maxlength='5' />";
}
}},
{display:"链接", render:function(item){
// if(item.__index == 0){
// return "http://店铺商品列表页(默认)";
// }else{
// return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
// }
if(item.__index == 0){
return "http://店铺商品列表页(默认)";
}else{
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
}
}},
{display:"操作", render:function(item){
var html = "";
if(item.__index == 0 && g.__rows.length == 1){
html += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />";
}else{
if(g.__rows.length > 1 && item.__index > 0){
html += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
if(g.__rows.length > 1 && g.__rows.length < 5 && item.__index == g.__rows.length - 1){
html += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />";
}
}
}
return html;
}}
]
});
g.__rows=""||jsonClone.resources.goodsTabBar.data.new;
g.init(g.__rows);
break;
//人气单品标签tab
case "editor-hotGoodTab":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"排序", render:function(item){
if(item.__index == 0){
return item.position;
}else{
item.position=item.position || (item.__index);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}
}},
{display:"名称", render:function(item){
if(item.__index == 0){
return item.name;
}else{
return "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' data-index='"+item.__index+"' maxlength='5' />";
}
}},
{display:"链接", render:function(item){
// if(item.__index == 0){
// return "http://店铺商品列表页(默认)";
// }else{
// return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
// }
if(item.__index == 0){
return "http://店铺商品列表页(默认)";
}else{
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
}
}},
{display:"操作", render:function(item){
var html = "";
if(item.__index == 0 && g.__rows.length == 1){
html += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />";
}else{
if(g.__rows.length > 1 && item.__index > 0){
html += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
if(g.__rows.length > 1 && g.__rows.length < 5 && item.__index == g.__rows.length - 1){
html += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />";
}
}
}
return html;
}}
]
});
g.__rows=""||jsonClone.resources.goodsTabBar.data.hot;
g.init(g.__rows);
break;
//新品上架
case "editor-newProduct":
$("#"+id).html("<div id='editor-newProduct-grid' style='width: 50%; float:left;padding-left: 20px'></div><div class='top20List' style='float:left; padding-left:10%'></div> ");
g = new common.grid({
hash: false,
el:"#editor-newProduct-grid",
columns:[
{display:"排序", render:function(item){
item.position=item.position || (item.__index+1);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{display:"图片", render:function(item){
return "<img src='"+item.src+"' style='width:75px; height:80px'>";
}},
{display:"操作", render:function(item){
var html = "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
return html;
}}
]
});
productSearchShow(id);
g.__rows=""||jsonClone.resources.newProducts.data;
productTopDataShow(id, jsonMain.resources.allNewProducts); //右侧热销排名前20商品
g.init(g.__rows);
break;
//人气单品
case "editor-hotProduct":
$("#"+id).html("<div id='editor-hotProduct-grid' style='width: 50%; float:left;padding-left: 20px'></div><div class='top20List' style='float:left; padding-left:10%'></div> ");
g = new common.grid({
hash: false,
el:"#editor-hotProduct-grid",
columns:[
{display:"排序", render:function(item){
item.position=item.position || (item.__index+1);
return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />";
}},
{display:"图片", render:function(item){
return "<img src='"+item.src+"' style='width:75px; height:80px'>";
}},
{display:"操作", render:function(item){
var html = "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>";
return html;
}}
]
});
productSearchShow(id);
if(curPlatform == "pc"){
g.__rows=""||jsonClone.resources.hotProducts.data;
productTopDataShow(id, jsonMain.resources.allHotProducts); //右侧热销排名前20商品
}
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.hotProducts_APP.data;
productTopDataShow(id, jsonMain.resources.allHotProducts_APP); //右侧热销排名前20商品
}
g.init(g.__rows);
break;
default :
break;
}
}
//弹层表单确定后刷新json数据,status参数:1:确定,0:取消
function freshJson(id,data,status){
switch (id){
case "editor-banner-base":
if(status == 1){
data[0].isShowShopName = $("input[name='isShowShopName']:checked").val();
cloneArr(data,jsonMain.resources.shopTopBanner_base.data);
}else if(status == 0){
cloneArr(jsonMain.resources.shopTopBanner_base.data,data);
}
break;
case "editor-banner":
if(status == 1){
data[0].isShowShopName = $("input[name='isShowShopName']:checked").val();
if(curPlatform == "pc"){
cloneArr(data,jsonMain.resources.shopTopBanner.data);
if(jsonMain.resources.shopTopBanner_APP.isUsed == "N"){
cloneArr(data,jsonMain.resources.shopTopBanner_APP.data);
cloneArr(data,jsonClone.resources.shopTopBanner_APP.data);
}
}
if(curPlatform == "app"){
jsonMain.resources.shopTopBanner_APP.isUsed = "Y";
cloneArr(data,jsonMain.resources.shopTopBanner_APP.data);
}
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.shopTopBanner.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.shopTopBanner_APP.data,data);
}
}
break;
case "editor-nav":
if(status == 1){
cloneArr(data,jsonMain.resources.navigationBar.data);
}else if(status == 0){
cloneArr(jsonMain.resources.navigationBar.data,data);
}
break;
case "editor-largePic":
if(status == 1){
if(curPlatform == "pc"){
cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg.data);
if(jsonMain.resources.largeSlideImg_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.largeSlideImg_APP.data);
removeUrlParam(id,jsonMain.resources.largeSlideImg_APP.data); //去除url
removeUrlParam(id,jsonClone.resources.largeSlideImg_APP.data);
}
}
if(curPlatform == "app"){
jsonMain.resources.largeSlideImg_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg_APP.data);
}
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.largeSlideImg.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.largeSlideImg_APP.data,data);
}
}
break;
case "editor-smallPic":
if(status == 1){
if(curPlatform == "pc"){
cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages.data);
if(jsonMain.resources.oneRowTwoColImages_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.oneRowTwoColImages_APP.data);
removeUrlParam(id,jsonMain.resources.oneRowTwoColImages_APP.data); //去除url
removeUrlParam(id,jsonClone.resources.oneRowTwoColImages_APP.data);
}
}
if(curPlatform == "app"){
jsonMain.resources.oneRowTwoColImages_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages_APP.data);
}
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.oneRowTwoColImages.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.oneRowTwoColImages_APP.data,data);
}
}
break;
case "editor-brand":
if(status == 1){
var title = $(".editorTitle input[name='title']").val();
jsonMain.resources.brandBrowse.title = jsonClone.resources.brandBrowse.title = title;
cloneArr(sortJson(data,1),jsonMain.resources.brandBrowse.data);
}else if(status == 0){
cloneArr(jsonMain.resources.brandBrowse.data,data);
}
break;
case "editor-recommend":
if(status == 1){
if(curPlatform == "pc"){
var title = $(".editorTitle input[name='title']").val();
jsonMain.resources.recommend.title = jsonClone.resources.recommend.title = title;
cloneArr(sortJson(data,1),jsonMain.resources.recommend.data);
if(jsonMain.resources.recommend_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.recommend_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.recommend_APP.data);
removeUrlParam(id,jsonMain.resources.recommend_APP.data); //去除url
removeUrlParam(id,jsonClone.resources.recommend_APP.data);
}
}
if(curPlatform == "app"){
jsonMain.resources.recommend_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.recommend_APP.data);
var value = $("input[type='radio'][name='recommandradio']:checked").val();
jsonMain.resources.recommend_APP.isDisplay = value;
}
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.recommend.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.recommend_APP.data,data);
}
}
break;
case "editor-hotRecommend":
if(status == 1){
jsonMain.resources.hotRecommend.title = jsonClone.resources.hotRecommend.title = $(".editorTitle input[name='title']").val();
cloneArr(sortJson(data,1),jsonMain.resources.hotRecommend.data);
}else if(status == 0){
cloneArr(jsonMain.resources.hotRecommend.data,data);
}
break;
case "editor-signboard":
if(status == 1){
cloneArr(sortJson(data,1),jsonMain.resources.signboard.data);
}else if(status == 0){
cloneArr(jsonMain.resources.signboard.data,data);
}
break;
case "editor-newGoodTab":
if(status == 1){
cloneArr(sortJson(data,0),jsonMain.resources.goodsTabBar.data.new);
}else if(status == 0){
cloneArr(jsonMain.resources.goodsTabBar.data.new,data);
}
break;
case "editor-hotGoodTab":
if(status == 1){
cloneArr(sortJson(data,0),jsonMain.resources.goodsTabBar.data.hot);
}else if(status == 0){
cloneArr(jsonMain.resources.goodsTabBar.data.hot,data);
}
break;
case "editor-newProduct":
if(status == 1){
cloneArr(sortJson(data,1),jsonMain.resources.newProducts.data);
}else if(status == 0){
cloneArr(jsonMain.resources.newProducts.data,data);
}
break;
case "editor-hotProduct":
if(status == 1){
if(curPlatform == "pc"){
cloneArr(sortJson(data,1),jsonMain.resources.hotProducts.data);
if(jsonMain.resources.hotProducts_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.hotProducts_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.hotProducts_APP.data);
}
}
if(curPlatform == "app"){
jsonMain.resources.hotProducts_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.hotProducts_APP.data);
}
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.hotProducts.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.hotProducts_APP.data,data);
}
}
break;
default :
break;
}
}
//同步至APP按钮生成
function sendToAppBtmInit(id, json){
return {
value:"保存并同步至APP",
css:"btn-success",
callback: function(){
if(editorCheck(id)){
json.isUsed = "N";
freshJson(id, g.__rows, 1);
json.isUsed = "Y";
common.util.__tip("同步APP成功!","success");
showMain();
}else{
return false;
}
}
}
}
//pc端根据模块不同增加同步至APP按钮
function setSendToAppBtm(id, option){
switch (id){
case "editor-banner":
if(jsonMain.resources.shopTopBanner_APP.isUsed == "Y"){
option.button.push(sendToAppBtmInit(id, jsonMain.resources.shopTopBanner_APP));
}
return option;
break;
case "editor-largePic":
if(jsonMain.resources.largeSlideImg_APP.isUsed == "Y"){
option.button.push(sendToAppBtmInit(id, jsonMain.resources.largeSlideImg_APP));
}
return option;
break;
case "editor-smallPic":
if(jsonMain.resources.oneRowTwoColImages_APP.isUsed == "Y"){
option.button.push(sendToAppBtmInit(id, jsonMain.resources.oneRowTwoColImages_APP));
}
return option;
break;
case "editor-recommend":
if(jsonMain.resources.recommend_APP.isUsed == "Y"){
option.button.push(sendToAppBtmInit(id, jsonMain.resources.recommend_APP));
}
return option;
break;
case "editor-hotProduct":
if(jsonMain.resources.hotProducts_APP.isUsed == "Y"){
option.button.push(sendToAppBtmInit(id, jsonMain.resources.hotProducts_APP));
}
return option;
break;
default :
return option;
break;
}
}
//tip生成
function editorTipInit(id){
var tipHtml = "";
switch (id){
case "editor-banner-base":
tipHtml = "<span>提示:请上传像素1150*200的图片,图片大小不能超过500KB。</span>";
break;
case "editor-banner":
if(curPlatform == "pc"){
tipHtml = "<span>提示:请上传像素1150*200的图片,图片大小不能超过500KB。</span>";
}
if(curPlatform == "app"){
tipHtml = "<span>提示:请上传像素640*200的图片,图片大小不能超过500KB。</span>";
}
break;
case "editor-nav":
tipHtml = "<span>提示:标题名称最多5个汉字。</span>";
break;
case "editor-largePic":
tipHtml = "<span>提示:请上传像素660*358的图片,图片大小不能超过500KB。</span>";
break;
case "editor-smallPic":
if(curPlatform == "app"){
tipHtml = "<span>提示:请上传像素275*160的图片,图片大小不能超过500KB。</span>";
}else{
tipHtml = "<span>提示:请上传像素300*174的图片,图片大小不能超过500KB。</span>";
}
break;
case "editor-brand":
tipHtml = "<span>提示:内容会适配到APP的【品牌一览】中。</span>";
break;
case "editor-brand-app":
tipHtml = "<span>提示:【品牌一览】由PC端【品牌集合】适配,修改请到PC端【品牌集合】修改。</span>";
break;
case "editor-recommend":
tipHtml = "<span>提示:请上传像素150*150的图片,图片大小不能超过500KB。</span>";
break;
case "editor-signboard":
tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能超过500KB。</span>";
break;
case "editor-hotRecommend":
tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能超过500KB。</span>";
break;
case "editor-newGoodTab":
tipHtml = "<span>提示:最多编辑5个标签,标题名称最多5个汉字。</span>";
break;
case "editor-hotGoodTab":
tipHtml = "<span>提示:最多编辑5个标签,标题名称最多5个汉字。</span>";
break;
default :
break;
}
$(".editorTip").html(tipHtml);
}
//弹出框编辑校验
function editorCheck(id){
switch (id){
case "editor-nav":
return checkUrlInput();
break;
case "editor-largePic":
return (checkNumInput() && checkEndTime() && checkUrlInput());
break;
case "editor-smallPic":
return (checkNumInput() && checkEndTime() && checkUrlInput());
break;
case "editor-brand":
return checkNumInput();
break;
case "editor-recommend":
// 品牌一览标题可为空,如果为空,前后台不展示标题
// var title = $(".editorTitle input[name='title']");
// if(title.length > 0 && title.val().trim() == ""){
// title.focus().addClass("error");
// common.util.__tip("模块标题不能为空!");
// return false;
// }
if(checkNumInput() && checkUrlInput()){
var nameList = $(".grid input[name='name']");
for(var i=0; i<nameList.length; i++){
if(!nameList.eq(i).val()){
nameList.eq(i).focus().addClass("error");
common.util.__tip("中文名不能为空!");
return false;
}
}
return true;
}
break;
case "editor-hotRecommend":
return (checkNumInput() && checkUrlInput());
break;
case "editor-signboard":
return (checkNumInput() && checkEndTime() && checkUrlInput());
break;
case "editor-newGoodTab":
return (checkNumInput() && checkUrlInput());
break;
case "editor-hotGoodTab":
return (checkNumInput() && checkUrlInput());
break;
case "editor-newProduct":
return checkNumInput();
break;
case "editor-hotProduct":
return checkNumInput();
break;
default :
return true;
break;
}
}
//排序序号校验
function checkNumInput(){
var positionList = $(".grid input[name='position']");
for(var i=0; i<positionList.length; i++){
if(positionList.eq(i).val()){
if(!isNaN(positionList.eq(i).val())){
if(positionList.eq(i).val() <= 0){
positionList.eq(i).focus().select().addClass("error");
common.util.__tip("排序数字请大于0!");
return false;
}
}else{
positionList.eq(i).focus().select().addClass("error");
common.util.__tip("排序必须为数字!");
return false;
}
}else{
positionList.eq(i).focus().addClass("error");
common.util.__tip("排序不能为空!");
return false;
}
}
return true;
}
//url域名校验
function checkUrlInput(){
var urlList = $(".grid input[name='url']");
for(var i=0; i<urlList.length; i++){
var reg = new RegExp(".+\.yoho[^.]*\.(com|cn).*","g");
if(urlList.eq(i).val() != ""){
if(!reg.test(urlList.eq(i).val())){
urlList.eq(i).focus().select().addClass("error");
common.util.__tip("Url必须包含yohobuy或者yoho,域名格式为com或者cn!");
return false;
}
}
}
return true;
}
//结束时间校验
function checkEndTime(){
var endTimeList = $(".grid input[name='endTime']");
for(var i=0; i<endTimeList.length; i++){
if(!endTimeList.eq(i).val()){
endTimeList.eq(i).focus().addClass("error");
common.util.__tip("结束时间不能为空!");
return false;
}
}
return true;
}
//编辑动画事件
function showEditorIconEvent(){
if(shopOperate == 'editor'){
$(".contentpanel .model-editor").hover(
function () {
var _this = $(this);
var editorModelId = $(this).attr("data-toggle");
var editorModelTitle = $(this).attr("data-title");
var editorIcon = "";
if(editorModelId == "editor-brand-app"){
editorIcon += "<div class='editorBorder' style='border: 5px solid #ff69b4'></div>"
}else{
editorIcon += "<div class='editorBorder'></div>"
}
editorIcon += "<a class='editorIcon' href='javascript:'>编辑</a>"
_this.append(editorIcon);
//编辑事件
editorIconEvent(editorModelTitle,editorModelId);
},
function () {
$(".editorIcon").remove();
$(".editorBorder").remove();
}
);
}
}
//工具类编辑表单初始化
function untilEditorEvent(id){
var e = new common.edit("#"+id,{bucket:"yhb-img02"});
e.init();
e.on("callback",function(obj){
if(/^file_onComplete_shopBannerImage_/.test(obj.key)){
var _index = obj.key.replace(/^file_onComplete_shopBannerImage_/,'');
g.__rows[_index].shopSrc = obj.data;
}
if(/^file_onComplete_DetailbannerImage_/.test(obj.key)){
var _index = obj.key.replace(/^file_onComplete_DetailbannerImage_/,'');
g.__rows[_index].detailSrc = obj.data;
}
if(/^file_onComplete_largePicImage_/.test(obj.key)){
var _index = obj.key.replace(/^file_onComplete_largePicImage_/,'');
var _indexList = _index.split("_");
g.__rows[_indexList[0]].data[_indexList[1]].src = obj.data;
}
if(/^file_onComplete_smallPicImage_/.test(obj.key)){
var _index = obj.key.replace(/^file_onComplete_smallPicImage_/,'');
var _indexList = _index.split("_");
g.__rows[_indexList[0]].data[_indexList[1]].src = obj.data;
}
if(/^file_onComplete_recommendImage_/.test(obj.key)){
var _index = obj.key.replace(/^file_onComplete_recommendImage_/,'');
g.__rows[_index].src = obj.data;
}
if(/^file_onComplete_hotRecommendImage_/.test(obj.key)){
var _index = obj.key.replace(/^file_onComplete_hotRecommendImage_/,'');
g.__rows[_index].src = obj.data;
}
if(/^file_onComplete_signboardImage_/.test(obj.key)){
var _index = obj.key.replace(/^file_onComplete_signboardImage_/,'');
var _indexList = _index.split("_");
g.__rows[_indexList[0]].data[_indexList[1]].src = obj.data;
}
});
$("#"+id+" nav").hide();
$(".modal-dialog .modal-header .close").hide();
$(".modal-dialog .modal-body .editor-dialog").css("overflow-y","auto");
$(".modal-dialog .modal-body .editor-dialog").css("overflow-x","hidden");
}
//资源位图片代码生成器
function resourcesHtmlInit(item,resName){
// var picList = item.data,
// htmlPic = "";
// for(var i=0; i<picList.length; i++){
// picList[i].url=picList[i].url.replace(/'/g,'\"'); // 字符串里面双引号转换成单引号
// htmlPic += "<div class='row'>" +
// "<div class='col-sm-2'><input type=file name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' /></div>" +
// "<div class='col-sm-3'><input type=text class='form-control inputChange urlInput' name='url' value='"+picList[i].url+"' data-index='"+item.__index+"_"+i+"' /></div>" +
// "<div class='col-sm-2'>";
// if(i>0){
// htmlPic += "<input type=text class='form-control' disabled jsaction='time:end:endTime_"+item.__index+"_"+ i +"' id='startTime_"+item.__index+"_"+ i +"' name='startTime' value='"+ picList[i].startTime +"' />" +
// "<span style='color: #999; font-size: 12px'>*上一条结束时间</span>";
// }else{
// htmlPic += "<input type=text class='form-control inputChange' style='background-color:#fff' readOnly='true' jsaction='time:end:endTime_"+item.__index+"_"+ i +"' id='startTime_"+item.__index+"_"+ i +"' name='startTime' value='"+ picList[i].startTime +"' data-index='"+ item.__index +"_"+ i +"' />";
// }
// htmlPic += "</div><div class='col-sm-2'>" +
// "<input type=text class='form-control inputChange' style='background-color:#fff' readOnly='true' jsaction='time:start:startTime_"+item.__index+"_"+ i +"' id='endTime_"+item.__index+"_"+ i +"' name='endTime' value='"+ picList[i].endTime +"' data-index='"+ item.__index +"_"+ i +"' /></div>" +
// "<div class='col-sm-1'><span class='publishStatus' style='white-space: nowrap; line-height: 40px'>"+ checkdate(picList[i].startTime,picList[i].endTime) +"</span></div>" +
// "<div class='col-sm-2' style='line-height: 40px'>";
// if(i == (picList.length-1) && picList.length > 1){
// htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+ item.__index +"_"+ i +"' /><br>";
// htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+ item.__index +"_"+ i +"' />";
// }
// if(i < (picList.length-1) && picList.length > 1){
// htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+ item.__index +"_"+ i +"' />";
// }
// if(i == (picList.length-1) && picList.length == 1){
// htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+ item.__index +"_"+ i +"' />";
// }
// htmlPic += "</div></div>";
// }
// return htmlPic;
var picList = item.data,
htmlPic = "";
for(var i=0; i<picList.length; i++){
//picList[i].url=picList[i].url.replace(/'/g,'\"'); // 字符串里面单引号转换成双引号
if(i == 0){
htmlPic += "<div class='row' style='padding: 10px 0'>";
}else{
htmlPic += "<div class='row' style='padding: 10px 0; border-top: 1px solid #dddddd'>";
}
//图片,大图资源位,小图资源位,水牌图片尺寸校验——fileType参数
htmlPic += "<div class='col-sm-2'>";
if(curPlatform == "pc"){
if(curDialogId == "editor-largePic"){//经典模板pc大图资源位
htmlPic += "<input type=file fileType='6' name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' />";
}
if(curDialogId == "editor-smallPic"){//经典模板pc小图资源位
htmlPic += "<input type=file fileType='7' name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' />";
}
if(curDialogId == "editor-signboard"){//基础模板水牌
htmlPic += "<input type=file fileType='3' name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' />";
}
}
if(curPlatform == "app"){
if(curDialogId == "editor-largePic"){//经典模板app大图资源位
htmlPic += "<input type=file fileType='11' name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' />";
}
if(curDialogId == "editor-smallPic"){//经典模板app小图资源位
htmlPic += "<input type=file fileType='12' name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' />";
}
}
htmlPic += "</div>";
//url&销售类目
console.log(picList[i].url);
if(picList[i].url != ''){
picList[i].linkType = picList[i].linkType || '0';
}else{
picList[i].linkType = picList[i].linkType || '1';
}
picList[i].categoryId = picList[i].categoryId || '-1';
htmlPic += "<div class='col-sm-3'>";
htmlPic += common.util.__template2($("#link").html(),{data:picList[i], categoryList:shopCategory, index:item.__index+'_'+i});
htmlPic += "</div>";
//开始时间
htmlPic += "<div class='col-sm-2'>";
if(i>0){
htmlPic += "<input type=text class='form-control' disabled jsaction='time:end:endTime_"+item.__index+"_"+ i +"' id='startTime_"+item.__index+"_"+ i +"' name='startTime' value='"+ picList[i].startTime +"' />" +
"<span style='color: #999; font-size: 12px'>*上一条结束时间</span>";
}else{
htmlPic += "<input type=text class='form-control inputChange' style='background-color:#fff' readOnly='true' jsaction='time:end:endTime_"+item.__index+"_"+ i +"' id='startTime_"+item.__index+"_"+ i +"' name='startTime' value='"+ picList[i].startTime +"' data-index='"+ item.__index +"_"+ i +"' />";
}
htmlPic += "</div>";
//结束时间
htmlPic += "<div class='col-sm-2'>"
+ "<input type=text class='form-control inputChange' style='background-color:#fff' readOnly='true' jsaction='time:start:startTime_"+item.__index+"_"+ i +"' id='endTime_"+item.__index+"_"+ i +"' name='endTime' value='"+ picList[i].endTime +"' data-index='"+ item.__index +"_"+ i +"' />"
+ "</div>";
//状态
htmlPic += "<div class='col-sm-1'><span class='publishStatus' style='white-space: nowrap; line-height: 40px'>"+ checkdate(picList[i].startTime,picList[i].endTime) +"</span></div>";
//操作
htmlPic += "<div class='col-sm-2' style='line-height: 40px'>";
if(i == (picList.length-1) && picList.length > 1){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+ item.__index +"_"+ i +"' /><br>";
htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+ item.__index +"_"+ i +"' />";
}
if(i < (picList.length-1) && picList.length > 1){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+ item.__index +"_"+ i +"' />";
}
if(i == (picList.length-1) && picList.length == 1){
htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+ item.__index +"_"+ i +"' />";
}
htmlPic += "</div></div>";
}
return htmlPic;
}
// 最新排行上面,增加模糊搜索
function productSearchShow(id) {
var ipt = $('<input type="text" class="form-control" placeholder="商品 SKN" style="display: inline-block;width: 200px;margin-right: 10px">');
var btn = $('<a href="javascript:;" class="btn btn-info">添加</a>');
$("#"+id).prepend($("<div style='float: left; width: 100%; padding: 0 0 13px 20px'></div>").append(ipt).append(btn));
btn.click(function() {
var skn = $(this).prev("input").val();
// validate skn
if (!$.isNumeric(skn)) {
common.util.__tip("请输入正确的 SKN", "warning");
return;
}
$.post('/shop/ShopsDecoratorRest/findProductBySKN',{ productSkn: skn, shopsId: shopsId }, function (resp) {
if (resp.code != 200) {
common.util.__tip(resp.message, "warning");
return;
}
// 判断数据存在
if (!resp.data) {
common.util.__tip("店铺中没有该 SKN, 请确保该商品已上加,且有库存。", "warning");
return;
}
// 添加 item
var added = addTop20Product(resp.data);
// 增加成功,清空输入框数据
if (added) { ipt.val(""); }
});
});
}
//展示最新,最热排名前20条
function productTopDataShow(id, products){
if(products.data && products.data.length > 0){
$("#"+id+" .top20List").html(common.util.__template2($("#top20Products").html(),products));
productTopDataLink(g.__rows);
}else{
$("#"+id+" .top20List").html("<font color='red'>* 最新上架20条加载失败,请重新加载页面!</font>");
}
}
//top20商品根据以展示商品自动勾选
function productTopDataLink(productList){
$(".top20List li").removeClass("selected");
for(var i=0; i<productList.length; i++){
var productId = productList[i].productId;
$(".top20List").find("li[data-productId = "+ productId +"]").addClass("selected");
}
$(".topTip span").text("已经勾选"+ productList.length +"件,最多勾选8件商品!");
}
//json数组排序, dis参数:0:从小到大,1:从大到小
function sortJson(arr,dir){
var len = arr.length, tmp;
for(var i=0; i < len-1; i++){
if(dir == 0){
for(var j=0; j < len-1-i; j++){
if(parseInt(arr[j].position) > parseInt(arr[j+1].position)){
tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
}
}
if(dir == 1){
for(var j=0; j < len-1-i; j++){
if(parseInt(arr[j].position) < parseInt(arr[j+1].position)){
tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
}
}
}
return arr;
}
//数组克隆
function cloneArr(arr1,arr2){
arr2.length = 0;
for(var i=0; i<arr1.length; i++){
arr2.push($.extend(true,{},arr1[i]));
}
return arr2;
}
//时间校验
function checkdate(startDate,endDate){
if (endDate) {
var endDateTemp = endDate.split(" ");
var arrEndDate = endDateTemp[0].split("-");
var arrEndTime = endDateTemp[1].split(":");
var allEndDate = new Date(arrEndDate[0], parseInt(arrEndDate[1])-1, arrEndDate[2], arrEndTime[0], arrEndTime[1], arrEndTime[2]);
}
if(startDate){
var startDateTemp = startDate.split(" ");
var arrStartDate = startDateTemp[0].split("-");
var arrStartTime = startDateTemp[1].split(":");
var allStartDate = new Date(arrStartDate[0], parseInt(arrStartDate[1])-1, arrStartDate[2], arrStartTime[0], arrStartTime[1], arrStartTime[2]);
}
var nowDate = new Date();
if(startDate && endDate){
if(nowDate > allEndDate) {
return "<b style='color: #ec971f'>已过期</b>";
}else if(allStartDate > nowDate){
return "<b style='color: #428bca'>未发布</b>";
}else{
return "<b style='color: #5cb85c'>发布中</b>";
}
}else if(!startDate && endDate){
if(nowDate > allEndDate) {
return "<b style='color: #ec971f'>已过期</b>";
}else{
return "<b style='color: #5cb85c'>发布中</b>";
}
}else{
return "<b style='color: #428bca'>未发布</b>";
}
return true;
}
//去除json中的url参数
function removeUrlParam(id, data){
if(id == "editor-largePic" || id == "editor-smallPic"){
for(var i=0; i<data.length; i++){
var data2 = data[i].data;
for(var j=0; j<data2.length; j++){
data2[j].url = "";
}
}
}
if(id == "editor-recommend"){
for(var i=0; i<data.length; i++){
data[i].url = "";
}
}
}
/********************事件绑定*********************/
//基础模板,经典模板切换
$(document).on("click",".tabheader .nav-tabs li",function(){
$(this).addClass('active').siblings('li').removeClass('active');
curTemplateType = $(this).attr("data-toggle");
showMain();
})
//pc,app切换
$(document).on("click","input[name=brandLevel]",function(){
curPlatform = $("input[name=brandLevel]:checked").val();
showMain();
})
//暂存模板
$(document).on("click","#saveModule",function(){
saveDecoration(100);
})
//提交审核
$(document).on("click","#submitModule",function(){
jsonMain.templateType = curTemplateType;
var templateName = curTemplateType=='2'?"经典模板":"基础模板";
common.dialog.confirm(
"提交审核确认",
"你确认使用<strong style='color:#5cb85c'>"+ templateName + "</strong>,并提交审核么?审核过程中,店铺装修将无法修改!",
function(){
saveDecoration(200);
},
function(){}
)
})
//审核通过
$(document).on("click","#checkOk",function(){
common.dialog.confirm(
"审核确认",
"你确认<strong style='color:#5cb85c'>审核通过</strong>么?",
function(){
checkDecoration(300);
},
function(){}
);
})
//驳回
$(document).on("click","#checkNo",function(){
common.dialog.confirm(
"审核驳回",
"你确认<strong style='color:#d9534f'>审核驳回</strong>么?如果确认,<strong style='color: #f0ad4e'>请填写驳回理由!</strong>" +
"<textarea id='checkComment' class='form-control' rows='3' style='margin: 10px 0'></textarea>" +
"<div class='editorTip' style='display: none'><span>提示:请填写驳回理由!</span></div>",
function(){
var comment = $("#checkComment").val();
if(comment){
checkDecoration(900,comment);
}else{
$(".editorTip").show();
return false;
}
},
function(){}
);
})
//销售类目&自定义切换
$(document).on("change", ".linkSelect", function () {
if($(this).val() == 0){ //自定义
$(this).next('.link_url').show().next('.link_category').hide();
}else{ //销售类目
$(this).next('.link_url').hide().next('.link_category').show();
}
});
//选择销售类目时,监听id跟名称
$(document).on("change", ".categoryChange", function () {
var _index = $(this).attr("data-index");
var indexList = _index.split("_");
var categoryName = this.options[this.selectedIndex].text;
if(indexList.length > 1){
(g.__rows[indexList[0]].data)[indexList[1]].categoryId = $(this).val();
(g.__rows[indexList[0]].data)[indexList[1]].categoryName = categoryName;
}else{
g.__rows[indexList[0]].categoryId = $(this).val();
g.__rows[indexList[0]].categoryName = categoryName;
}
});
//删除
$(document).on("click",".deleteBtn",function(){
var _index = $(this).data("index")+"";
var indexList = _index.split("_");
if(indexList.length > 1){
[].splice.call(g.__rows[indexList[0]].data,indexList[1],1);
}else{
[].splice.call(g.__rows,indexList[0],1);
}
g.init(g.__rows);
untilEditorEvent(curDialogId);
if(curDialogId == "editor-newProduct" || curDialogId == "editor-hotProduct"){
productTopDataLink(g.__rows);
}
});
//添加一条
$(document).on("click",".addBtn",function(){
var _index = $(this).data("index")+"";
var indexList = _index.split("_");
if(indexList.length > 1){
g.__rows[indexList[0]].data.push($.extend({},ENUM[curDialogId]));
if(curDialogId == "editor-largePic" || curDialogId == "editor-smallPic" || curDialogId == "editor-signboard"){
(g.__rows[indexList[0]].data)[(parseInt(indexList[1]) + 1)].startTime = (g.__rows[indexList[0]].data)[indexList[1]].endTime;
}
}else{
g.__rows.push($.extend({},ENUM[curDialogId]));
}
g.init(g.__rows);
untilEditorEvent(curDialogId);
});
//资源位大图,水牌添加一条资源位
$(document).on("click",".addBtn2",function(){
if( curDialogId == "editor-largePic" && g.__rows.length > 4){
$(".largePicAddTip").text("* 最多只能添加5个资源位大图!").css("color","#ff0000");
return;
}else{
$(".largePicAddTip").empty();
g.__rows.push($.extend(true,{},ENUM["editor-largePic2"]));
g.init(g.__rows);
untilEditorEvent(curDialogId);
}
});
//input change同时更新json
$(document).on("change",".inputChange",function(){
var _index = $(this).attr("data-index");
var indexList = _index.split("_");
var _name = $(this).attr("name");
if(indexList.length > 1){
(g.__rows[indexList[0]].data)[indexList[1]][_name] = $(this).val();
}else{
g.__rows[indexList[0]][_name] = $(this).val();
}
if(curDialogId == "editor-largePic" || curDialogId == "editor-smallPic" || curDialogId == "editor-signboard"){
if($(this).attr("name") == "endTime"){
if(g.__rows[indexList[0]].data.length - 1 > indexList[1]){
(g.__rows[indexList[0]].data)[(parseInt(indexList[1]) + 1)].startTime = $(this).val();
$(this).parents(".row").next().children().find("input[name='startTime']").val($(this).val());
var endDate = $(this).parents(".row").next().children().find("input[name='endTime']").val();
$(this).parents(".row").next().children().find(".publishStatus").html(checkdate($(this).val(),endDate));
}
var startDate = $(this).parents(".row").find("input[name='startTime']").val();
$(this).parents(".row").find(".publishStatus").html(checkdate(startDate,$(this).val()));
}
if($(this).attr("name") == "startTime"){
var endDate = $(this).parents(".row").find("input[name='endTime']").val();
$(this).parents(".row").find(".publishStatus").html(checkdate($(this).val(),endDate));
}
}
$(this).removeClass("error");
});
//选择Top20
$(document).on("click",".topAdd",function(){
if($(this).hasClass("selected")){
$(this).removeClass("selected");
var cutProductId = $(this).attr("data-productId");
for(var i=0; i<g.__rows.length; i++){
if(g.__rows[i].productId == cutProductId){
[].splice.call(g.__rows,i,1);
break;
}
}
g.init(g.__rows);
untilEditorEvent(curDialogId);
productTopDataLink(g.__rows);
}else{
if(g.__rows.length >= 8){
$(".topTip span").text("商品数量已满8个,无法继续添加商品!");
return;
}
$(this).addClass("selected");
var item = {};
item.src = $(this).find('img').attr("src");
item.productId = $(this).attr("data-productId");
item.productName = $(this).attr("data-productName");
item.salesPrice = $(this).attr("data-productPrice");
item.productSkn = $(this).attr("data-productSkn");
item.goodsId = $(this).attr("data-goodsId");
item.cnAlphabet = $(this).attr("data-cnAlphabet");
addTop20Product(item);
}
});
function existInRows(rows, skn) {
for (var i = 0, l = rows.length; i < l; i++) {
if (rows[i].productSkn == skn) {
return true;
}
}
return false;
}
function addTop20Product(item) {
// 判断数量
if(g.__rows.length >= 8){
$(".topTip span").text("商品数量已满8个,无法继续添加商品!");
common.util.__tip("商品数量已满8个,无法继续添加商品!", "warning");
return false;
}
// 判断是否存在
if (existInRows(g.__rows, item.productSkn)) {
common.util.__tip("该商品已存在!", "warning");
return false;
}
// 添加
g.__rows.push(item);
g.init(g.__rows);
untilEditorEvent(curDialogId);
productTopDataLink(g.__rows);
return true;
}
/***/ }
]);