Showing
1 changed file
with
0 additions
and
1651 deletions
1 | -//店铺装修 | ||
2 | - | ||
3 | -'use strict'; | ||
4 | -var $ = require('jquery'), | ||
5 | - common=require('../../common/common'); | ||
6 | - | ||
7 | -var g; //grid | ||
8 | -var curDialogId; //当前打开的编辑弹层ID | ||
9 | -var curPlatform = "pc"; //当前渲染页面用的模板名称 | ||
10 | -var curTemplateType = "2"; //当前模板类型 1:基础模板,2:经典模板 | ||
11 | -var shopType = 1; //店铺类型 1:单品牌,2:多品牌 | ||
12 | -var shopOperate = 'view'; //操作 editor:可编辑, view:查看不可编辑 | ||
13 | -var defaultSrc = "http://img01.yohoboys.com/staticimg/2016/05/19/15/01091c21f2317a64f123f1649fbbccf7ba.png"; //初始化默认图片路径 | ||
14 | -var ENUM = { | ||
15 | - "editor-largePic":{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0}, | ||
16 | - "editor-largePic2":{"position":"", "data":[{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0}]}, | ||
17 | - "editor-smallPic":{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0}, | ||
18 | - "editor-brand":{"position":"", "name":"", "url":""}, | ||
19 | - "editor-recommend": {"position":"", "name":"", "enName":"", "src":"", "url":""}, | ||
20 | - "editor-hotRecommend":{"position":"", "src":"", "url":""}, | ||
21 | - "editor-signboard":{"position":"", "src":"", "url":"","startTime": "","endTime": "","publishStatus": 0}, | ||
22 | - "editor-newGoodTab":{"position":"", "name":"", "url":""}, | ||
23 | - "editor-hotGoodTab":{"position":"", "name":"", "url":""}, | ||
24 | - "editor-newProduct":{"productId":"", "position":"", "productName":"", "productSkn":"", "salesPrice":"", "src":"", "url":""}, | ||
25 | - "editor-hotProduct":{"productId":"", "position":"", "productName":"", "productSkn":"", "salesPrice":"", "src":"", "url":""} | ||
26 | -}; //添加一条不同弹层使用的初始化模板 | ||
27 | -var resourcesNew = { | ||
28 | - "shopTopBanner":{ | ||
29 | - "id":"", | ||
30 | - "data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}] | ||
31 | - }, | ||
32 | - "shopTopBanner_base":{ | ||
33 | - "id":"", | ||
34 | - "data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}] | ||
35 | - }, | ||
36 | - "navigationBar":{ | ||
37 | - "id":"", | ||
38 | - "data": [{"name":"",url:""}, {"name":"",url:""}, {"name":"",url:""}] | ||
39 | - }, | ||
40 | - "largeSlideImg":{ | ||
41 | - "id":"", | ||
42 | - "data": [{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}] | ||
43 | - }, | ||
44 | - "oneRowTwoColImages":{ | ||
45 | - "id":"", | ||
46 | - "data": [ | ||
47 | - {"position": 2, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}, | ||
48 | - {"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]} | ||
49 | - ] | ||
50 | - }, | ||
51 | - "brandBrowse":{ | ||
52 | - "id":"", | ||
53 | - "data": [] | ||
54 | - }, | ||
55 | - "recommend":{ | ||
56 | - "id":"", | ||
57 | - "title":"经典推荐", | ||
58 | - "data": [{"position":1, "name":"默认商品", "enName":"", "src":defaultSrc, "url":""}] | ||
59 | - }, | ||
60 | - "hotRecommend":{ | ||
61 | - "id":"", | ||
62 | - "title":"", | ||
63 | - "data": [{"position":1, "src":defaultSrc, "url":""}] | ||
64 | - }, | ||
65 | - "signboard":{ | ||
66 | - "id":"", | ||
67 | - "data": [{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}] | ||
68 | - }, | ||
69 | - "goodsTabBar":{ | ||
70 | - "id":"", | ||
71 | - "data": { | ||
72 | - "new":[{"position":0, "name":"MORE", "url":""}], | ||
73 | - "hot":[{"position":0, "name":"MORE", "url":""}] | ||
74 | - } | ||
75 | - }, | ||
76 | - "newProducts":{ | ||
77 | - "id":"", | ||
78 | - "data": [] | ||
79 | - }, | ||
80 | - "hotProducts":{ | ||
81 | - "id":"", | ||
82 | - "data": [] | ||
83 | - }, | ||
84 | - "allNewProducts":{ | ||
85 | - "id":"", | ||
86 | - "data":[] | ||
87 | - }, | ||
88 | - "allHotProducts":{ | ||
89 | - "id":"", | ||
90 | - "data":[] | ||
91 | - }, | ||
92 | - "shopTopBanner_APP":{ | ||
93 | - "id":"", | ||
94 | - "isUsed":"N", | ||
95 | - "data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}] | ||
96 | - }, | ||
97 | - "oneRowTwoColImages_APP":{ | ||
98 | - "id":"", | ||
99 | - "isUsed":"N", | ||
100 | - "data": [ | ||
101 | - {"position": 2, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}, | ||
102 | - {"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]} | ||
103 | - ] | ||
104 | - }, | ||
105 | - "hotProducts_APP":{ | ||
106 | - "id":"", | ||
107 | - "isUsed":"N", | ||
108 | - "data": [] | ||
109 | - }, | ||
110 | - "allHotProducts_APP":{ | ||
111 | - "id":"", | ||
112 | - "data":[] | ||
113 | - }, | ||
114 | - "largeSlideImg_APP":{ | ||
115 | - "id":"", | ||
116 | - "isUsed":"N", | ||
117 | - "data": [{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}] | ||
118 | - }, | ||
119 | - "recommend_APP":{ | ||
120 | - "id":"", | ||
121 | - "isUsed":"N", | ||
122 | - "data": [{"position":1, "name":"默认商品", "enName":"", "src":defaultSrc, "url":""}] | ||
123 | - } | ||
124 | -} //初始化装修信息json | ||
125 | -var shopsId, _id, jsonMain, jsonClone; | ||
126 | - | ||
127 | -getParams(); | ||
128 | -findDecoration(); | ||
129 | - | ||
130 | -/********************主流程*********************/ | ||
131 | - | ||
132 | -//URL获取参数 | ||
133 | -function getParams(){ | ||
134 | - var paramUrl = location.href + ""; | ||
135 | - var param = paramUrl.substring(paramUrl.indexOf("decorationDetail")); | ||
136 | - var paramList = param.split("/"); | ||
137 | - | ||
138 | - if(paramList){ | ||
139 | - shopsId = paramList[1]; | ||
140 | - shopType = paramList[2]; | ||
141 | - shopOperate = paramList[3]; | ||
142 | - _id = paramList[4]; | ||
143 | - } | ||
144 | - if(shopOperate == 'editor'){ | ||
145 | - $(".moduleSubmite").show().siblings().hide(); | ||
146 | - }else if(shopOperate == 'view'){ | ||
147 | - $(".tabheader").hide(); | ||
148 | - $(".moduleView").show().siblings().hide(); | ||
149 | - }else if(shopOperate == 'check'){ | ||
150 | - $(".tabheader").hide(); | ||
151 | - $(".moduleCheck").show().siblings().hide(); | ||
152 | - } | ||
153 | -} | ||
154 | -//json渲染模板 | ||
155 | -function showMain(){ | ||
156 | - // tab自动选中基础模板,经典模板 | ||
157 | - $('.tabheader .nav').find("li[data-toggle='"+ curTemplateType +"']").addClass("active"); | ||
158 | - // radio自动选中pc端或者app端 | ||
159 | - $('.moduleTypeView').find("input[name='brandLevel'][value='"+ curPlatform +"']").attr("checked","checked"); | ||
160 | - | ||
161 | - //渲染装修模板 | ||
162 | - if(curTemplateType == 1){ | ||
163 | - $('#main').empty().html(common.util.__template2($("#"+curTemplateType+"-pc").html(),jsonMain)); | ||
164 | - }else if(curTemplateType == 2){ | ||
165 | - $('#main').empty().html(common.util.__template2($("#"+curTemplateType+"-"+curPlatform).html(),jsonMain)); | ||
166 | - } | ||
167 | - | ||
168 | - //基础模板不显示pc端跟app端 | ||
169 | - if(curTemplateType == "1"){ | ||
170 | - $(".moduleTypeView").hide(); | ||
171 | - }else{ | ||
172 | - $(".moduleTypeView").show(); | ||
173 | - } | ||
174 | - //单品牌,多品牌 | ||
175 | - if(shopType == 2){ | ||
176 | - $(".model-brand").show(); | ||
177 | - }else if(shopType == 1){ | ||
178 | - $(".model-brand").hide(); | ||
179 | - } | ||
180 | - //标签长度样式自适应 | ||
181 | - $.each($(".contentpanel-pc .model-showTitle .showTab"),function(){ | ||
182 | - if($(this).width() > 280){ | ||
183 | - $(this).css("right",(280-($(this).width()))+"px"); | ||
184 | - } | ||
185 | - }) | ||
186 | - showEditorIconEvent(); | ||
187 | -} | ||
188 | -//弹窗编辑主流程 | ||
189 | -function editorIconEvent(title,id){ | ||
190 | - $('.editorIcon').on('click',function(){ | ||
191 | - curDialogId = id; | ||
192 | - var option = { | ||
193 | - title:title, | ||
194 | - content:"<div class='editorTitle'></div><div class='editor-dialog' id='"+ id +"'></div><div class='editorTip'></div> ", | ||
195 | - width:'70%', | ||
196 | - button:[ | ||
197 | - { | ||
198 | - value:"取消", | ||
199 | - callback:function(){ | ||
200 | - if(curDialogId != "editor-brand-app"){ | ||
201 | - freshJson(id, g.__rows, 0); | ||
202 | - } | ||
203 | - } | ||
204 | - }, | ||
205 | - { | ||
206 | - value:"确认", | ||
207 | - css:"btn-info", | ||
208 | - callback:function(){ | ||
209 | - if(editorCheck(id)){ | ||
210 | - if(curDialogId != "editor-brand-app"){ | ||
211 | - freshJson(id, g.__rows, 1); | ||
212 | - } | ||
213 | - showMain(); | ||
214 | - }else{ | ||
215 | - return false; | ||
216 | - } | ||
217 | - } | ||
218 | - } | ||
219 | - ] | ||
220 | - } | ||
221 | - if(curPlatform == "pc"){ | ||
222 | - option = setSendToAppBtm(id, option); | ||
223 | - } | ||
224 | - new common.dialog(option); | ||
225 | - gridInit(id); | ||
226 | - untilEditorEvent(id); | ||
227 | - editorTipInit(id); | ||
228 | - }) | ||
229 | -} | ||
230 | - | ||
231 | -/********************接口Ajax*********************/ | ||
232 | - | ||
233 | -//Ajax查询 | ||
234 | -function findDecoration(){ | ||
235 | - console.log('1'); | ||
236 | - common.util.__ajax( | ||
237 | - { | ||
238 | - url:'/shop/ShopsDecoratorRest/findShopsDecoratorDetail', | ||
239 | - data: { | ||
240 | - "shopsId": shopsId | ||
241 | - } | ||
242 | - }, | ||
243 | - function(rs) { | ||
244 | - console.log(rs.data); | ||
245 | - if(rs.data){ | ||
246 | - jsonMain = rs.data; | ||
247 | - } | ||
248 | - //没有装修信息,初始化装修信息 | ||
249 | - if($.isEmptyObject(jsonMain.resources)){ | ||
250 | - jsonMain.resources = $.extend(true,{},resourcesNew); | ||
251 | - } | ||
252 | - //装修信息中品牌内容为空,初始化品牌 | ||
253 | - if(jsonMain.brandList){ | ||
254 | - if(jsonMain.resources.brandBrowse.data.length < 1){ | ||
255 | - cloneArr(jsonMain.brandList,jsonMain.resources.brandBrowse.data); | ||
256 | - } | ||
257 | - }else{ | ||
258 | - common.util.__tip("店铺没有品牌,无法装修,请返回添加品牌!"); | ||
259 | - return; | ||
260 | - } | ||
261 | - //初始化模板类型 | ||
262 | - if(jsonMain.templateType && jsonMain.templateType != "0"){ | ||
263 | - curTemplateType = jsonMain.templateType; | ||
264 | - } | ||
265 | - //装修json克隆 | ||
266 | - jsonClone = $.extend(true,{},jsonMain); | ||
267 | - | ||
268 | - //最新上架,最热商品接口 | ||
269 | - if(shopOperate == 'editor'){ | ||
270 | - if(!jsonMain.resources.allNewProducts.data || jsonMain.resources.allNewProducts.data.length < 1){ | ||
271 | - findTopNewProducts(); | ||
272 | - } | ||
273 | - if(!jsonMain.resources.allHotProducts.data || jsonMain.resources.allHotProducts.data.length < 1){ | ||
274 | - findTopHotProducts(); | ||
275 | - } | ||
276 | - if(!jsonMain.resources.allHotProducts_APP.data || jsonMain.resources.allHotProducts_APP.data.length < 1){ | ||
277 | - findTopHotProducts_APP(); | ||
278 | - } | ||
279 | - /*findTopNewProducts(); findTopHotProducts(); findTopHotProducts_APP();*/ | ||
280 | - } | ||
281 | - showMain(); | ||
282 | - },true); | ||
283 | -} | ||
284 | -//Ajax最新上架商品 | ||
285 | -function findTopNewProducts(){ | ||
286 | - common.util.__ajax({ | ||
287 | - url:'/shop/ShopsDecoratorRest/findNewProductList', | ||
288 | - data: { | ||
289 | - "shopsId": jsonMain.shopsId, | ||
290 | - "size": 20 | ||
291 | - } | ||
292 | - },function(rs){ | ||
293 | - if(rs.data.product_list){ | ||
294 | - jsonMain.resources.allNewProducts.data = rs.data.product_list; | ||
295 | - } | ||
296 | - },true); | ||
297 | -} | ||
298 | -//Ajax热销商品 | ||
299 | -function findTopHotProducts(){ | ||
300 | - common.util.__ajax({ | ||
301 | - url:'/shop/ShopsDecoratorRest/findHotProductList', | ||
302 | - data: { | ||
303 | - "shopsId": jsonMain.shopsId, | ||
304 | - "size": 20 | ||
305 | - } | ||
306 | - },function(rs){ | ||
307 | - if(rs.data.product_list){ | ||
308 | - jsonMain.resources.allHotProducts.data = rs.data.product_list; | ||
309 | - } | ||
310 | - },true); | ||
311 | -} | ||
312 | -//Ajax热销商品---APP | ||
313 | -function findTopHotProducts_APP(){ | ||
314 | - common.util.__ajax({ | ||
315 | - url:'/shop/ShopsDecoratorRest/findHotProductList', | ||
316 | - data: { | ||
317 | - "shopsId": jsonMain.shopsId, | ||
318 | - "size": 20 | ||
319 | - } | ||
320 | - },function(rs){ | ||
321 | - if(rs.data.product_list){ | ||
322 | - jsonMain.resources.allHotProducts_APP.data = rs.data.product_list; | ||
323 | - } | ||
324 | - },true); | ||
325 | -} | ||
326 | -//Ajax保存,暂存:100,提交审核:200 | ||
327 | -function saveDecoration(submitStatus){ | ||
328 | - console.log(jsonMain); | ||
329 | - common.util.__ajax({ | ||
330 | - url:'/shop/ShopsDecoratorRest/saveShopsDecorator', | ||
331 | - data: { | ||
332 | - "submitStatus": submitStatus, | ||
333 | - "shopsId": jsonMain.shopsId, | ||
334 | - "platform": jsonMain.platform, | ||
335 | - "templateType": jsonMain.templateType, | ||
336 | - "resources": JSON.stringify(jsonMain.resources) | ||
337 | - } | ||
338 | - },function(rs){ | ||
339 | - if(rs.data){ | ||
340 | - if(submitStatus == 100){ | ||
341 | - jsonMain = rs.data; | ||
342 | - jsonClone = $.extend(true,{},jsonMain); | ||
343 | - showMain(); | ||
344 | - }else{ | ||
345 | - setTimeout(function() { | ||
346 | - location.href="/supplier/shop/decoration"; | ||
347 | - }, 1000); | ||
348 | - } | ||
349 | - } | ||
350 | - }); | ||
351 | -} | ||
352 | -//Ajax审核,审核通过:300,驳回:900 | ||
353 | -function checkDecoration(checkStatus,comment){ | ||
354 | - if(comment){ //驳回 | ||
355 | - common.util.__ajax({ | ||
356 | - url:'/shop/ShopsDecoratorRest/auditShopsDecorator', | ||
357 | - data: { | ||
358 | - "id": _id, | ||
359 | - "checkStatus": checkStatus, | ||
360 | - "comment": comment | ||
361 | - } | ||
362 | - },function(rs){ | ||
363 | - common.util.__tip("审核驳回成功!","success"); | ||
364 | - setTimeout(function() { | ||
365 | - location.href="/supplier/check/index"; | ||
366 | - }, 1000); | ||
367 | - },true); | ||
368 | - }else{ //通过 | ||
369 | - common.util.__ajax({ | ||
370 | - url:'/shop/ShopsDecoratorRest/auditShopsDecorator', | ||
371 | - data: { | ||
372 | - "id": _id, | ||
373 | - "checkStatus": checkStatus | ||
374 | - } | ||
375 | - },function(rs){ | ||
376 | - common.util.__tip("审核通过成功!","success"); | ||
377 | - setTimeout(function() { | ||
378 | - location.href="/supplier/check/index"; | ||
379 | - }, 1000); | ||
380 | - },true); | ||
381 | - } | ||
382 | -} | ||
383 | - | ||
384 | -/********************工具类*********************/ | ||
385 | - | ||
386 | -//弹层表单grid生成器 | ||
387 | -function gridInit(id){ | ||
388 | - switch (id){ | ||
389 | - //基础模板顶部banner | ||
390 | - case "editor-banner-base": | ||
391 | - g = new common.grid({ | ||
392 | - hash: false, | ||
393 | - el:"#"+id, | ||
394 | - columns:[ | ||
395 | - {display:"店铺banner图片", render:function(item){ | ||
396 | - return "<input type=file name='shopBannerImage' id='shopBannerImage_"+item.__index+"' value='"+item.shopSrc+"' />"; | ||
397 | - }}, | ||
398 | - {display:"是否显示店铺名称", render:function(item){ | ||
399 | - if(item.isShowShopName == "Y"){ | ||
400 | - return "<lable><input type='radio' name='isShowShopName' value='Y' checked='checked'>显示店铺名称</lable><br>" + | ||
401 | - "<lable><input type='radio' name='isShowShopName' value='N'>不显示店铺名称</lable>"; | ||
402 | - }else{ | ||
403 | - return "<lable><input type='radio' name='isShowShopName' value='Y'>显示店铺名称</lable><br>" + | ||
404 | - "<lable><input type='radio' name='isShowShopName' value='N' checked='checked'>不显示店铺名称</lable>"; | ||
405 | - } | ||
406 | - }}, | ||
407 | - {display:"商品详情页banner图片", render:function(item){ | ||
408 | - return "<input type=file name='DetailbannerImage' id='DetailbannerImage_"+item.__index+"' value='"+item.detailSrc+"' />"; | ||
409 | - }} | ||
410 | - ] | ||
411 | - }); | ||
412 | - g.__rows=""||jsonClone.resources.shopTopBanner_base.data; | ||
413 | - g.init(g.__rows); | ||
414 | - break; | ||
415 | - | ||
416 | - //经典模板顶部banner | ||
417 | - case "editor-banner": | ||
418 | - if(curPlatform == "pc"){ | ||
419 | - g = new common.grid({ | ||
420 | - hash: false, | ||
421 | - el:"#"+id, | ||
422 | - columns:[ | ||
423 | - {display:"店铺banner图片", render:function(item){ | ||
424 | - return "<input type=file name='shopBannerImage' id='shopBannerImage_"+item.__index+"' value='"+item.shopSrc+"' />"; | ||
425 | - }}, | ||
426 | - {display:"是否显示店铺名称", render:function(item){ | ||
427 | - if(item.isShowShopName == "Y"){ | ||
428 | - return "<lable><input type='radio' name='isShowShopName' value='Y' checked='checked'>显示店铺名称</lable><br>" + | ||
429 | - "<lable><input type='radio' name='isShowShopName' value='N'>不显示店铺名称</lable>"; | ||
430 | - }else{ | ||
431 | - return "<lable><input type='radio' name='isShowShopName' value='Y'>显示店铺名称</lable><br>" + | ||
432 | - "<lable><input type='radio' name='isShowShopName' value='N' checked='checked'>不显示店铺名称</lable>"; | ||
433 | - } | ||
434 | - }}, | ||
435 | - {display:"商品详情页banner图片", render:function(item){ | ||
436 | - return "<input type=file name='DetailbannerImage' id='DetailbannerImage_"+item.__index+"' value='"+item.detailSrc+"' />"; | ||
437 | - }} | ||
438 | - ] | ||
439 | - }); | ||
440 | - g.__rows=""||jsonClone.resources.shopTopBanner.data; | ||
441 | - } | ||
442 | - if(curPlatform == "app"){ | ||
443 | - g = new common.grid({ | ||
444 | - hash: false, | ||
445 | - el:"#"+id, | ||
446 | - columns:[ | ||
447 | - {display:"店铺banner图片", render:function(item){ | ||
448 | - return "<input type=file name='shopBannerImage' id='shopBannerImage_"+item.__index+"' value='"+item.shopSrc+"' />"; | ||
449 | - }}, | ||
450 | - {display:"是否显示店铺名称", render:function(item){ | ||
451 | - if(item.isShowShopName == "Y"){ | ||
452 | - return "<lable><input type='radio' name='isShowShopName' value='Y' checked='checked'>显示店铺名称</lable><br>" + | ||
453 | - "<lable><input type='radio' name='isShowShopName' value='N'>不显示店铺名称</lable>"; | ||
454 | - }else{ | ||
455 | - return "<lable><input type='radio' name='isShowShopName' value='Y'>显示店铺名称</lable><br>" + | ||
456 | - "<lable><input type='radio' name='isShowShopName' value='N' checked='checked'>不显示店铺名称</lable>"; | ||
457 | - } | ||
458 | - }} | ||
459 | - ] | ||
460 | - }); | ||
461 | - g.__rows=""||jsonClone.resources.shopTopBanner_APP.data; | ||
462 | - } | ||
463 | - g.init(g.__rows); | ||
464 | - break; | ||
465 | - | ||
466 | - //店铺导航nav | ||
467 | - case "editor-nav": | ||
468 | - g = new common.grid({ | ||
469 | - hash: false, | ||
470 | - el:"#"+id, | ||
471 | - columns:[ | ||
472 | - {display:"编号", render:function(item){ | ||
473 | - return item.__index+1; | ||
474 | - }}, | ||
475 | - {display:"名称", render:function(item){ | ||
476 | - return "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' data-index='"+item.__index+"' maxlength='5' />"; | ||
477 | - }}, | ||
478 | - {display:"链接", render:function(item){ | ||
479 | - return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />"; | ||
480 | - }} | ||
481 | - ] | ||
482 | - }); | ||
483 | - g.__rows=""||jsonClone.resources.navigationBar.data; | ||
484 | - g.init(g.__rows); | ||
485 | - break; | ||
486 | - | ||
487 | - //店铺大图资源位 | ||
488 | - case "editor-largePic": | ||
489 | - $('.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"); | ||
490 | - g = new common.grid({ | ||
491 | - hash: false, | ||
492 | - el:"#"+id, | ||
493 | - columns:[ | ||
494 | - {display:"排序", render:function(item){ | ||
495 | - item.position=item.position || (item.__index+1); | ||
496 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
497 | - }}, | ||
498 | - {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> " + | ||
499 | - "<div class='col-sm-1'>状态</div><div class='col-sm-2'>操作</div></div>", | ||
500 | - render: function (item) { | ||
501 | - return resourcesHtmlInit(item,"largePic"); | ||
502 | - } | ||
503 | - }, | ||
504 | - {display:"操作", render:function(item){ | ||
505 | - if(g.__rows.length > 1){ | ||
506 | - return "<input type=button class='btn btn-warning btn-xs deleteBtn' style='margin-top:6px' value='删除' data-index='"+item.__index+"' />"; | ||
507 | - } | ||
508 | - }} | ||
509 | - ] | ||
510 | - }); | ||
511 | - if(curPlatform == "pc"){ | ||
512 | - g.__rows=""||jsonClone.resources.largeSlideImg.data; | ||
513 | - } | ||
514 | - if(curPlatform == "app"){ | ||
515 | - g.__rows=""||jsonClone.resources.largeSlideImg_APP.data; | ||
516 | - } | ||
517 | - g.init(g.__rows); | ||
518 | - break; | ||
519 | - | ||
520 | - //店铺小图资源位 | ||
521 | - case "editor-smallPic": | ||
522 | - g = new common.grid({ | ||
523 | - hash: false, | ||
524 | - el:"#"+id, | ||
525 | - columns:[ | ||
526 | - {display:"排序", render:function(item){ | ||
527 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
528 | - }}, | ||
529 | - { | ||
530 | - 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> " + | ||
531 | - "<div class='col-sm-1'>状态</div><div class='col-sm-2'>操作</div></div>", | ||
532 | - render: function (item) { | ||
533 | - return resourcesHtmlInit(item,"smallPic"); | ||
534 | - } | ||
535 | - } | ||
536 | - ] | ||
537 | - }); | ||
538 | - if(curPlatform == "pc"){ | ||
539 | - g.__rows=""||jsonClone.resources.oneRowTwoColImages.data; | ||
540 | - } | ||
541 | - if(curPlatform == "app"){ | ||
542 | - g.__rows=""||jsonClone.resources.oneRowTwoColImages_APP.data; | ||
543 | - } | ||
544 | - g.init(g.__rows); | ||
545 | - break; | ||
546 | - | ||
547 | - //品牌一览 | ||
548 | - case "editor-brand": | ||
549 | - g = new common.grid({ | ||
550 | - hash: false, | ||
551 | - el:"#"+id, | ||
552 | - columns:[ | ||
553 | - {display:"排序", render:function(item){ | ||
554 | - item.position=item.position || (item.__index+1); | ||
555 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
556 | - }}, | ||
557 | - {display:"名称", render:function(item){ | ||
558 | - return item.brandName; | ||
559 | - }}, | ||
560 | - ] | ||
561 | - }); | ||
562 | - g.__rows=""||jsonClone.resources.brandBrowse.data; | ||
563 | - g.init(g.__rows); | ||
564 | - break; | ||
565 | - | ||
566 | - //经典推荐recommend | ||
567 | - case "editor-recommend": | ||
568 | - g = new common.grid({ | ||
569 | - hash: false, | ||
570 | - el:"#"+id, | ||
571 | - columns:[ | ||
572 | - {display:"排序", render:function(item){ | ||
573 | - item.position=item.position || (item.__index+1); | ||
574 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
575 | - }}, | ||
576 | - {display:"名称", render:function(item){ | ||
577 | - return "<div style='width: 5%; float: left; line-height: 40px; color: #ff0000'>*</div><div style='width: 95%; float: left'>" + | ||
578 | - "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' placeholder='中文' data-index='"+item.__index+"' />" + | ||
579 | - "<input class='form-control inputChange' style='margin-top:10px' type=text name='enName' value='"+item.enName+"' placeholder='英文' data-index='"+item.__index+"' />" + | ||
580 | - "</div>"; | ||
581 | - }}, | ||
582 | - {display:"图片", render:function(item){ | ||
583 | - return "<input type=file name='recommendImage' id='recommendImage_"+item.__index+"' value='"+item.src+"' />"; | ||
584 | - }}, | ||
585 | - {display:"链接", render:function(item){ | ||
586 | - return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />"; | ||
587 | - }}, | ||
588 | - {display:"操作", render:function(item){ | ||
589 | - var htmlPic = "",i=item.__index; | ||
590 | - if(g.__rows.length == 1){ | ||
591 | - htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />"; | ||
592 | - } | ||
593 | - if(g.__rows.length > 1){ | ||
594 | - if(i == (g.__rows.length-1) && i < 15){ | ||
595 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
596 | - htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />"; | ||
597 | - } | ||
598 | - if(i == (g.__rows.length-1) && i >= 15){ | ||
599 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
600 | - } | ||
601 | - if(i < (g.__rows.length-1)){ | ||
602 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' />"; | ||
603 | - } | ||
604 | - } | ||
605 | - return htmlPic; | ||
606 | - }} | ||
607 | - ] | ||
608 | - }); | ||
609 | - if(curPlatform == "pc"){ | ||
610 | - $('.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> "); | ||
611 | - g.__rows=""||jsonClone.resources.recommend.data; | ||
612 | - } | ||
613 | - if(curPlatform == "app"){ | ||
614 | - g.__rows=""||jsonClone.resources.recommend_APP.data; | ||
615 | - } | ||
616 | - g.init(g.__rows); | ||
617 | - break; | ||
618 | - | ||
619 | - //热销推荐hotRecommend | ||
620 | - case "editor-hotRecommend": | ||
621 | - $('.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> "); | ||
622 | - g = new common.grid({ | ||
623 | - hash: false, | ||
624 | - el:"#"+id, | ||
625 | - columns:[ | ||
626 | - {display:"排序", render:function(item){ | ||
627 | - item.position=item.position || (item.__index+1); | ||
628 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
629 | - }}, | ||
630 | - {display:"图片", render:function(item){ | ||
631 | - return "<input type=file name='signboardImage' id='hotRecommendImage_"+item.__index+"' value='"+item.src+"' />"; | ||
632 | - }}, | ||
633 | - {display:"链接", render:function(item){ | ||
634 | - return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />"; | ||
635 | - }}, | ||
636 | - {display:"操作", render:function(item){ | ||
637 | - var htmlPic = "",i=item.__index; | ||
638 | - if(g.__rows.length == 1){ | ||
639 | - htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />"; | ||
640 | - } | ||
641 | - if(g.__rows.length > 1){ | ||
642 | - if(i == (g.__rows.length-1) && i < 5){ | ||
643 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
644 | - htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />"; | ||
645 | - } | ||
646 | - if(i == (g.__rows.length-1) && i >= 5){ | ||
647 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
648 | - } | ||
649 | - if(i < (g.__rows.length-1)){ | ||
650 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' />"; | ||
651 | - } | ||
652 | - } | ||
653 | - return htmlPic; | ||
654 | - }} | ||
655 | - ] | ||
656 | - }); | ||
657 | - g.__rows=""||jsonClone.resources.hotRecommend.data; | ||
658 | - g.init(g.__rows); | ||
659 | - break; | ||
660 | - | ||
661 | - //水牌signboard | ||
662 | - case "editor-signboard": | ||
663 | - $('.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"); | ||
664 | - g = new common.grid({ | ||
665 | - hash: false, | ||
666 | - el:"#"+id, | ||
667 | - columns:[ | ||
668 | - {display:"排序", render:function(item){ | ||
669 | - item.position=item.position || (item.__index+1); | ||
670 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
671 | - }}, | ||
672 | - {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> " + | ||
673 | - "<div class='col-sm-1'>状态</div><div class='col-sm-2'>操作</div></div>", | ||
674 | - render: function (item) { | ||
675 | - return resourcesHtmlInit(item,"signboard"); | ||
676 | - } | ||
677 | - }, | ||
678 | - {display:"操作", render:function(item){ | ||
679 | - if(g.__rows.length > 1){ | ||
680 | - return "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' />"; | ||
681 | - } | ||
682 | - }} | ||
683 | - ] | ||
684 | - }); | ||
685 | - g.__rows=""||jsonClone.resources.signboard.data; | ||
686 | - g.init(g.__rows); | ||
687 | - break; | ||
688 | - | ||
689 | - //新品上架标签tab | ||
690 | - case "editor-newGoodTab": | ||
691 | - g = new common.grid({ | ||
692 | - hash: false, | ||
693 | - el:"#"+id, | ||
694 | - columns:[ | ||
695 | - {display:"排序", render:function(item){ | ||
696 | - if(item.__index == 0){ | ||
697 | - return item.position; | ||
698 | - }else{ | ||
699 | - item.position=item.position || (item.__index); | ||
700 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
701 | - } | ||
702 | - }}, | ||
703 | - {display:"名称", render:function(item){ | ||
704 | - if(item.__index == 0){ | ||
705 | - return item.name; | ||
706 | - }else{ | ||
707 | - return "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' data-index='"+item.__index+"' maxlength='5' />"; | ||
708 | - } | ||
709 | - }}, | ||
710 | - {display:"链接", render:function(item){ | ||
711 | - if(item.__index == 0){ | ||
712 | - return "http://店铺商品列表页(默认)"; | ||
713 | - }else{ | ||
714 | - return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />"; | ||
715 | - } | ||
716 | - }}, | ||
717 | - {display:"操作", render:function(item){ | ||
718 | - var html = ""; | ||
719 | - if(item.__index == 0 && g.__rows.length == 1){ | ||
720 | - html += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />"; | ||
721 | - }else{ | ||
722 | - if(g.__rows.length > 1 && item.__index > 0){ | ||
723 | - html += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
724 | - if(g.__rows.length > 1 && g.__rows.length < 5 && item.__index == g.__rows.length - 1){ | ||
725 | - html += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />"; | ||
726 | - } | ||
727 | - } | ||
728 | - } | ||
729 | - return html; | ||
730 | - }} | ||
731 | - ] | ||
732 | - }); | ||
733 | - g.__rows=""||jsonClone.resources.goodsTabBar.data.new; | ||
734 | - g.init(g.__rows); | ||
735 | - break; | ||
736 | - | ||
737 | - //人气单品标签tab | ||
738 | - case "editor-hotGoodTab": | ||
739 | - g = new common.grid({ | ||
740 | - hash: false, | ||
741 | - el:"#"+id, | ||
742 | - columns:[ | ||
743 | - {display:"排序", render:function(item){ | ||
744 | - if(item.__index == 0){ | ||
745 | - return item.position; | ||
746 | - }else{ | ||
747 | - item.position=item.position || (item.__index); | ||
748 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
749 | - } | ||
750 | - }}, | ||
751 | - {display:"名称", render:function(item){ | ||
752 | - if(item.__index == 0){ | ||
753 | - return item.name; | ||
754 | - }else{ | ||
755 | - return "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' data-index='"+item.__index+"' maxlength='5' />"; | ||
756 | - } | ||
757 | - }}, | ||
758 | - {display:"链接", render:function(item){ | ||
759 | - if(item.__index == 0){ | ||
760 | - return "http://店铺商品列表页(默认)"; | ||
761 | - }else{ | ||
762 | - return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />"; | ||
763 | - } | ||
764 | - }}, | ||
765 | - {display:"操作", render:function(item){ | ||
766 | - var html = ""; | ||
767 | - if(item.__index == 0 && g.__rows.length == 1){ | ||
768 | - html += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+item.__index+"' />"; | ||
769 | - }else{ | ||
770 | - if(g.__rows.length > 1 && item.__index > 0){ | ||
771 | - html += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
772 | - if(g.__rows.length > 1 && g.__rows.length < 5 && item.__index == g.__rows.length - 1){ | ||
773 | - html += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+item.__index+"' />"; | ||
774 | - } | ||
775 | - } | ||
776 | - } | ||
777 | - return html; | ||
778 | - }} | ||
779 | - ] | ||
780 | - }); | ||
781 | - g.__rows=""||jsonClone.resources.goodsTabBar.data.hot; | ||
782 | - g.init(g.__rows); | ||
783 | - break; | ||
784 | - | ||
785 | - //新品上架 | ||
786 | - case "editor-newProduct": | ||
787 | - $("#"+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> "); | ||
788 | - g = new common.grid({ | ||
789 | - hash: false, | ||
790 | - el:"#editor-newProduct-grid", | ||
791 | - columns:[ | ||
792 | - {display:"排序", render:function(item){ | ||
793 | - item.position=item.position || (item.__index+1); | ||
794 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
795 | - }}, | ||
796 | - {display:"图片", render:function(item){ | ||
797 | - return "<img src='"+item.src+"' style='width:75px; height:80px'>"; | ||
798 | - }}, | ||
799 | - {display:"操作", render:function(item){ | ||
800 | - var html = "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
801 | - return html; | ||
802 | - }} | ||
803 | - ] | ||
804 | - }); | ||
805 | - g.__rows=""||jsonClone.resources.newProducts.data; | ||
806 | - productTopDataShow(id, jsonMain.resources.allNewProducts); //右侧热销排名前20商品 | ||
807 | - g.init(g.__rows); | ||
808 | - break; | ||
809 | - | ||
810 | - //人气单品 | ||
811 | - case "editor-hotProduct": | ||
812 | - $("#"+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> "); | ||
813 | - g = new common.grid({ | ||
814 | - hash: false, | ||
815 | - el:"#editor-hotProduct-grid", | ||
816 | - columns:[ | ||
817 | - {display:"排序", render:function(item){ | ||
818 | - item.position=item.position || (item.__index+1); | ||
819 | - return "<input class='form-control numInput inputChange' type=text name='position' value='"+item.position+"' data-index='"+item.__index+"' />"; | ||
820 | - }}, | ||
821 | - {display:"图片", render:function(item){ | ||
822 | - return "<img src='"+item.src+"' style='width:75px; height:80px'>"; | ||
823 | - }}, | ||
824 | - {display:"操作", render:function(item){ | ||
825 | - var html = "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' /><br>"; | ||
826 | - return html; | ||
827 | - }} | ||
828 | - ] | ||
829 | - }); | ||
830 | - if(curPlatform == "pc"){ | ||
831 | - g.__rows=""||jsonClone.resources.hotProducts.data; | ||
832 | - productTopDataShow(id, jsonMain.resources.allHotProducts); //右侧热销排名前20商品 | ||
833 | - } | ||
834 | - if(curPlatform == "app"){ | ||
835 | - g.__rows=""||jsonClone.resources.hotProducts_APP.data; | ||
836 | - productTopDataShow(id, jsonMain.resources.allHotProducts_APP); //右侧热销排名前20商品 | ||
837 | - } | ||
838 | - g.init(g.__rows); | ||
839 | - break; | ||
840 | - | ||
841 | - default : | ||
842 | - break; | ||
843 | - } | ||
844 | -} | ||
845 | -//弹层表单确定后刷新json数据,status参数:1:确定,0:取消 | ||
846 | -function freshJson(id,data,status){ | ||
847 | - switch (id){ | ||
848 | - case "editor-banner-base": | ||
849 | - if(status == 1){ | ||
850 | - data[0].isShowShopName = $("input[name='isShowShopName']:checked").val(); | ||
851 | - cloneArr(data,jsonMain.resources.shopTopBanner_base.data); | ||
852 | - }else if(status == 0){ | ||
853 | - cloneArr(jsonMain.resources.shopTopBanner_base.data,data); | ||
854 | - } | ||
855 | - break; | ||
856 | - | ||
857 | - case "editor-banner": | ||
858 | - if(status == 1){ | ||
859 | - data[0].isShowShopName = $("input[name='isShowShopName']:checked").val(); | ||
860 | - if(curPlatform == "pc"){ | ||
861 | - cloneArr(data,jsonMain.resources.shopTopBanner.data); | ||
862 | - if(jsonMain.resources.shopTopBanner_APP.isUsed == "N"){ | ||
863 | - cloneArr(data,jsonMain.resources.shopTopBanner_APP.data); | ||
864 | - cloneArr(data,jsonClone.resources.shopTopBanner_APP.data); | ||
865 | - } | ||
866 | - } | ||
867 | - if(curPlatform == "app"){ | ||
868 | - jsonMain.resources.shopTopBanner_APP.isUsed = "Y"; | ||
869 | - cloneArr(data,jsonMain.resources.shopTopBanner_APP.data); | ||
870 | - } | ||
871 | - }else if(status == 0){ | ||
872 | - if(curPlatform == "pc"){ | ||
873 | - cloneArr(jsonMain.resources.shopTopBanner.data,data); | ||
874 | - } | ||
875 | - if(curPlatform == "app"){ | ||
876 | - cloneArr(jsonMain.resources.shopTopBanner_APP.data,data); | ||
877 | - } | ||
878 | - } | ||
879 | - break; | ||
880 | - | ||
881 | - case "editor-nav": | ||
882 | - if(status == 1){ | ||
883 | - cloneArr(data,jsonMain.resources.navigationBar.data); | ||
884 | - }else if(status == 0){ | ||
885 | - cloneArr(jsonMain.resources.navigationBar.data,data); | ||
886 | - } | ||
887 | - break; | ||
888 | - | ||
889 | - case "editor-largePic": | ||
890 | - if(status == 1){ | ||
891 | - if(curPlatform == "pc"){ | ||
892 | - cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg.data); | ||
893 | - if(jsonMain.resources.largeSlideImg_APP.isUsed == "N"){ | ||
894 | - cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg_APP.data); | ||
895 | - cloneArr(sortJson(data,1),jsonClone.resources.largeSlideImg_APP.data); | ||
896 | - removeUrlParam(id,jsonMain.resources.largeSlideImg_APP.data); //去除url | ||
897 | - removeUrlParam(id,jsonClone.resources.largeSlideImg_APP.data); | ||
898 | - } | ||
899 | - } | ||
900 | - if(curPlatform == "app"){ | ||
901 | - jsonMain.resources.largeSlideImg_APP.isUsed = "Y"; | ||
902 | - cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg_APP.data); | ||
903 | - } | ||
904 | - }else if(status == 0){ | ||
905 | - if(curPlatform == "pc"){ | ||
906 | - cloneArr(jsonMain.resources.largeSlideImg.data,data); | ||
907 | - } | ||
908 | - if(curPlatform == "app"){ | ||
909 | - cloneArr(jsonMain.resources.largeSlideImg_APP.data,data); | ||
910 | - } | ||
911 | - } | ||
912 | - break; | ||
913 | - | ||
914 | - case "editor-smallPic": | ||
915 | - if(status == 1){ | ||
916 | - if(curPlatform == "pc"){ | ||
917 | - cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages.data); | ||
918 | - if(jsonMain.resources.oneRowTwoColImages_APP.isUsed == "N"){ | ||
919 | - cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages_APP.data); | ||
920 | - cloneArr(sortJson(data,1),jsonClone.resources.oneRowTwoColImages_APP.data); | ||
921 | - removeUrlParam(id,jsonMain.resources.oneRowTwoColImages_APP.data); //去除url | ||
922 | - removeUrlParam(id,jsonClone.resources.oneRowTwoColImages_APP.data); | ||
923 | - } | ||
924 | - } | ||
925 | - if(curPlatform == "app"){ | ||
926 | - jsonMain.resources.oneRowTwoColImages_APP.isUsed = "Y"; | ||
927 | - cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages_APP.data); | ||
928 | - } | ||
929 | - }else if(status == 0){ | ||
930 | - if(curPlatform == "pc"){ | ||
931 | - cloneArr(jsonMain.resources.oneRowTwoColImages.data,data); | ||
932 | - } | ||
933 | - if(curPlatform == "app"){ | ||
934 | - cloneArr(jsonMain.resources.oneRowTwoColImages_APP.data,data); | ||
935 | - } | ||
936 | - } | ||
937 | - break; | ||
938 | - | ||
939 | - case "editor-brand": | ||
940 | - if(status == 1){ | ||
941 | - cloneArr(sortJson(data,1),jsonMain.resources.brandBrowse.data); | ||
942 | - }else if(status == 0){ | ||
943 | - cloneArr(jsonMain.resources.brandBrowse.data,data); | ||
944 | - } | ||
945 | - break; | ||
946 | - | ||
947 | - case "editor-recommend": | ||
948 | - if(status == 1){ | ||
949 | - if(curPlatform == "pc"){ | ||
950 | - var title = $(".editorTitle input[name='title']").val(); | ||
951 | - jsonMain.resources.recommend.title = jsonClone.resources.recommend.title = title; | ||
952 | - cloneArr(sortJson(data,1),jsonMain.resources.recommend.data); | ||
953 | - if(jsonMain.resources.recommend_APP.isUsed == "N"){ | ||
954 | - cloneArr(sortJson(data,1),jsonMain.resources.recommend_APP.data); | ||
955 | - cloneArr(sortJson(data,1),jsonClone.resources.recommend_APP.data); | ||
956 | - removeUrlParam(id,jsonMain.resources.recommend_APP.data); //去除url | ||
957 | - removeUrlParam(id,jsonClone.resources.recommend_APP.data); | ||
958 | - } | ||
959 | - } | ||
960 | - if(curPlatform == "app"){ | ||
961 | - jsonMain.resources.recommend_APP.isUsed = "Y"; | ||
962 | - cloneArr(sortJson(data,1),jsonMain.resources.recommend_APP.data); | ||
963 | - } | ||
964 | - }else if(status == 0){ | ||
965 | - if(curPlatform == "pc"){ | ||
966 | - cloneArr(jsonMain.resources.recommend.data,data); | ||
967 | - } | ||
968 | - if(curPlatform == "app"){ | ||
969 | - cloneArr(jsonMain.resources.recommend_APP.data,data); | ||
970 | - } | ||
971 | - } | ||
972 | - break; | ||
973 | - | ||
974 | - case "editor-hotRecommend": | ||
975 | - if(status == 1){ | ||
976 | - jsonMain.resources.hotRecommend.title = jsonClone.resources.hotRecommend.title = $(".editorTitle input[name='title']").val(); | ||
977 | - cloneArr(sortJson(data,1),jsonMain.resources.hotRecommend.data); | ||
978 | - }else if(status == 0){ | ||
979 | - cloneArr(jsonMain.resources.hotRecommend.data,data); | ||
980 | - } | ||
981 | - break; | ||
982 | - | ||
983 | - case "editor-signboard": | ||
984 | - if(status == 1){ | ||
985 | - cloneArr(sortJson(data,1),jsonMain.resources.signboard.data); | ||
986 | - }else if(status == 0){ | ||
987 | - cloneArr(jsonMain.resources.signboard.data,data); | ||
988 | - } | ||
989 | - break; | ||
990 | - | ||
991 | - case "editor-newGoodTab": | ||
992 | - if(status == 1){ | ||
993 | - cloneArr(sortJson(data,0),jsonMain.resources.goodsTabBar.data.new); | ||
994 | - }else if(status == 0){ | ||
995 | - cloneArr(jsonMain.resources.goodsTabBar.data.new,data); | ||
996 | - } | ||
997 | - break; | ||
998 | - | ||
999 | - case "editor-hotGoodTab": | ||
1000 | - if(status == 1){ | ||
1001 | - cloneArr(sortJson(data,0),jsonMain.resources.goodsTabBar.data.hot); | ||
1002 | - }else if(status == 0){ | ||
1003 | - cloneArr(jsonMain.resources.goodsTabBar.data.hot,data); | ||
1004 | - } | ||
1005 | - break; | ||
1006 | - | ||
1007 | - case "editor-newProduct": | ||
1008 | - if(status == 1){ | ||
1009 | - cloneArr(sortJson(data,1),jsonMain.resources.newProducts.data); | ||
1010 | - }else if(status == 0){ | ||
1011 | - cloneArr(jsonMain.resources.newProducts.data,data); | ||
1012 | - } | ||
1013 | - break; | ||
1014 | - | ||
1015 | - case "editor-hotProduct": | ||
1016 | - if(status == 1){ | ||
1017 | - if(curPlatform == "pc"){ | ||
1018 | - cloneArr(sortJson(data,1),jsonMain.resources.hotProducts.data); | ||
1019 | - if(jsonMain.resources.hotProducts_APP.isUsed == "N"){ | ||
1020 | - cloneArr(sortJson(data,1),jsonMain.resources.hotProducts_APP.data); | ||
1021 | - cloneArr(sortJson(data,1),jsonClone.resources.hotProducts_APP.data); | ||
1022 | - } | ||
1023 | - } | ||
1024 | - if(curPlatform == "app"){ | ||
1025 | - jsonMain.resources.hotProducts_APP.isUsed = "Y"; | ||
1026 | - cloneArr(sortJson(data,1),jsonMain.resources.hotProducts_APP.data); | ||
1027 | - } | ||
1028 | - }else if(status == 0){ | ||
1029 | - if(curPlatform == "pc"){ | ||
1030 | - cloneArr(jsonMain.resources.hotProducts.data,data); | ||
1031 | - } | ||
1032 | - if(curPlatform == "app"){ | ||
1033 | - cloneArr(jsonMain.resources.hotProducts_APP.data,data); | ||
1034 | - } | ||
1035 | - } | ||
1036 | - break; | ||
1037 | - | ||
1038 | - default : | ||
1039 | - break; | ||
1040 | - } | ||
1041 | -} | ||
1042 | -//同步至APP按钮生成 | ||
1043 | -function sendToAppBtmInit(id, json){ | ||
1044 | - return { | ||
1045 | - value:"保存并同步至APP", | ||
1046 | - css:"btn-success", | ||
1047 | - callback: function(){ | ||
1048 | - if(editorCheck(id)){ | ||
1049 | - json.isUsed = "N"; | ||
1050 | - freshJson(id, g.__rows, 1); | ||
1051 | - json.isUsed = "Y"; | ||
1052 | - common.util.__tip("同步APP成功!","success"); | ||
1053 | - showMain(); | ||
1054 | - }else{ | ||
1055 | - return false; | ||
1056 | - } | ||
1057 | - } | ||
1058 | - } | ||
1059 | -} | ||
1060 | -//pc端根据模块不同增加同步至APP按钮 | ||
1061 | -function setSendToAppBtm(id, option){ | ||
1062 | - switch (id){ | ||
1063 | - case "editor-banner": | ||
1064 | - if(jsonMain.resources.shopTopBanner_APP.isUsed == "Y"){ | ||
1065 | - option.button.push(sendToAppBtmInit(id, jsonMain.resources.shopTopBanner_APP)); | ||
1066 | - } | ||
1067 | - return option; | ||
1068 | - break; | ||
1069 | - | ||
1070 | - case "editor-largePic": | ||
1071 | - if(jsonMain.resources.largeSlideImg_APP.isUsed == "Y"){ | ||
1072 | - option.button.push(sendToAppBtmInit(id, jsonMain.resources.largeSlideImg_APP)); | ||
1073 | - } | ||
1074 | - return option; | ||
1075 | - break; | ||
1076 | - | ||
1077 | - case "editor-smallPic": | ||
1078 | - if(jsonMain.resources.oneRowTwoColImages_APP.isUsed == "Y"){ | ||
1079 | - option.button.push(sendToAppBtmInit(id, jsonMain.resources.oneRowTwoColImages_APP)); | ||
1080 | - } | ||
1081 | - return option; | ||
1082 | - break; | ||
1083 | - | ||
1084 | - case "editor-recommend": | ||
1085 | - if(jsonMain.resources.recommend_APP.isUsed == "Y"){ | ||
1086 | - option.button.push(sendToAppBtmInit(id, jsonMain.resources.recommend_APP)); | ||
1087 | - } | ||
1088 | - return option; | ||
1089 | - break; | ||
1090 | - | ||
1091 | - case "editor-hotProduct": | ||
1092 | - if(jsonMain.resources.hotProducts_APP.isUsed == "Y"){ | ||
1093 | - option.button.push(sendToAppBtmInit(id, jsonMain.resources.hotProducts_APP)); | ||
1094 | - } | ||
1095 | - return option; | ||
1096 | - break; | ||
1097 | - | ||
1098 | - default : | ||
1099 | - return option; | ||
1100 | - break; | ||
1101 | - } | ||
1102 | -} | ||
1103 | -//tip生成 | ||
1104 | -function editorTipInit(id){ | ||
1105 | - var tipHtml = ""; | ||
1106 | - switch (id){ | ||
1107 | - case "editor-banner-base": | ||
1108 | - tipHtml = "<span>提示:请上传像素1150*200的图片,图片大小不能超过500KB。</span>"; | ||
1109 | - break; | ||
1110 | - case "editor-banner": | ||
1111 | - if(curPlatform == "pc"){ | ||
1112 | - tipHtml = "<span>提示:请上传像素1150*200的图片,图片大小不能超过500KB。</span>"; | ||
1113 | - } | ||
1114 | - if(curPlatform == "app"){ | ||
1115 | - tipHtml = "<span>提示:请上传像素640*200的图片,图片大小不能超过500KB。</span>"; | ||
1116 | - } | ||
1117 | - break; | ||
1118 | - case "editor-nav": | ||
1119 | - tipHtml = "<span>提示:标题名称最多5个汉字。</span>"; | ||
1120 | - break; | ||
1121 | - case "editor-largePic": | ||
1122 | - tipHtml = "<span>提示:请上传像素660*358的图片,图片大小不能超过500KB。</span>"; | ||
1123 | - break; | ||
1124 | - case "editor-smallPic": | ||
1125 | - if(curPlatform == "app"){ | ||
1126 | - tipHtml = "<span>提示:请上传像素275*160的图片,图片大小不能超过500KB。</span>"; | ||
1127 | - }else{ | ||
1128 | - tipHtml = "<span>提示:请上传像素300*174的图片,图片大小不能超过500KB。</span>"; | ||
1129 | - } | ||
1130 | - break; | ||
1131 | - case "editor-brand": | ||
1132 | - tipHtml = "<span>提示:内容会适配到APP的【品牌一览】中。</span>"; | ||
1133 | - break; | ||
1134 | - case "editor-brand-app": | ||
1135 | - tipHtml = "<span>提示:【品牌一览】由PC端【品牌集合】适配,修改请到PC端【品牌集合】修改。</span>"; | ||
1136 | - break; | ||
1137 | - case "editor-recommend": | ||
1138 | - tipHtml = "<span>提示:请上传像素150*150的图片,图片大小不能超过500KB。</span>"; | ||
1139 | - break; | ||
1140 | - case "editor-signboard": | ||
1141 | - tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能超过500KB。</span>"; | ||
1142 | - break; | ||
1143 | - case "editor-hotRecommend": | ||
1144 | - tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能超过500KB。</span>"; | ||
1145 | - break; | ||
1146 | - case "editor-newGoodTab": | ||
1147 | - tipHtml = "<span>提示:最多编辑5个标签,标题名称最多5个汉字。</span>"; | ||
1148 | - break; | ||
1149 | - case "editor-hotGoodTab": | ||
1150 | - tipHtml = "<span>提示:最多编辑5个标签,标题名称最多5个汉字。</span>"; | ||
1151 | - break; | ||
1152 | - default : | ||
1153 | - break; | ||
1154 | - } | ||
1155 | - $(".editorTip").html(tipHtml); | ||
1156 | -} | ||
1157 | -//弹出框编辑校验 | ||
1158 | -function editorCheck(id){ | ||
1159 | - switch (id){ | ||
1160 | - case "editor-nav": | ||
1161 | - return checkUrlInput(); | ||
1162 | - break; | ||
1163 | - | ||
1164 | - case "editor-largePic": | ||
1165 | - return (checkNumInput() && checkEndTime() && checkUrlInput()); | ||
1166 | - break; | ||
1167 | - | ||
1168 | - case "editor-smallPic": | ||
1169 | - return (checkNumInput() && checkEndTime() && checkUrlInput()); | ||
1170 | - break; | ||
1171 | - | ||
1172 | - case "editor-brand": | ||
1173 | - return checkNumInput(); | ||
1174 | - break; | ||
1175 | - | ||
1176 | - case "editor-recommend": | ||
1177 | - var title = $(".editorTitle input[name='title']"); | ||
1178 | - if(title.length > 0 && title.val().trim() == ""){ | ||
1179 | - title.focus().addClass("error"); | ||
1180 | - common.util.__tip("模块标题不能为空!"); | ||
1181 | - return false; | ||
1182 | - } | ||
1183 | - if(checkNumInput() && checkUrlInput()){ | ||
1184 | - var nameList = $(".grid input[name='name']"); | ||
1185 | - for(var i=0; i<nameList.length; i++){ | ||
1186 | - if(!nameList.eq(i).val()){ | ||
1187 | - nameList.eq(i).focus().addClass("error"); | ||
1188 | - common.util.__tip("中文名不能为空!"); | ||
1189 | - return false; | ||
1190 | - } | ||
1191 | - } | ||
1192 | - return true; | ||
1193 | - } | ||
1194 | - break; | ||
1195 | - | ||
1196 | - case "editor-hotRecommend": | ||
1197 | - return (checkNumInput() && checkUrlInput()); | ||
1198 | - break; | ||
1199 | - | ||
1200 | - case "editor-signboard": | ||
1201 | - return (checkNumInput() && checkEndTime() && checkUrlInput()); | ||
1202 | - break; | ||
1203 | - | ||
1204 | - case "editor-newGoodTab": | ||
1205 | - return (checkNumInput() && checkUrlInput()); | ||
1206 | - break; | ||
1207 | - | ||
1208 | - case "editor-hotGoodTab": | ||
1209 | - return (checkNumInput() && checkUrlInput()); | ||
1210 | - break; | ||
1211 | - | ||
1212 | - case "editor-newProduct": | ||
1213 | - return checkNumInput(); | ||
1214 | - break; | ||
1215 | - | ||
1216 | - case "editor-hotProduct": | ||
1217 | - return checkNumInput(); | ||
1218 | - break; | ||
1219 | - | ||
1220 | - default : | ||
1221 | - return true; | ||
1222 | - break; | ||
1223 | - } | ||
1224 | -} | ||
1225 | -//排序序号校验 | ||
1226 | -function checkNumInput(){ | ||
1227 | - var positionList = $(".grid input[name='position']"); | ||
1228 | - for(var i=0; i<positionList.length; i++){ | ||
1229 | - if(positionList.eq(i).val()){ | ||
1230 | - if(!isNaN(positionList.eq(i).val())){ | ||
1231 | - if(positionList.eq(i).val() <= 0){ | ||
1232 | - positionList.eq(i).focus().select().addClass("error"); | ||
1233 | - common.util.__tip("排序数字请大于0!"); | ||
1234 | - return false; | ||
1235 | - } | ||
1236 | - }else{ | ||
1237 | - positionList.eq(i).focus().select().addClass("error"); | ||
1238 | - common.util.__tip("排序必须为数字!"); | ||
1239 | - return false; | ||
1240 | - } | ||
1241 | - }else{ | ||
1242 | - positionList.eq(i).focus().addClass("error"); | ||
1243 | - common.util.__tip("排序不能为空!"); | ||
1244 | - return false; | ||
1245 | - } | ||
1246 | - } | ||
1247 | - return true; | ||
1248 | -} | ||
1249 | -//url域名校验 | ||
1250 | -function checkUrlInput(){ | ||
1251 | - var urlList = $(".grid input[name='url']"); | ||
1252 | - for(var i=0; i<urlList.length; i++){ | ||
1253 | - var reg = new RegExp(".+\.yoho[^.]*\.(com|cn).*","g"); | ||
1254 | - if(urlList.eq(i).val() != ""){ | ||
1255 | - if(!reg.test(urlList.eq(i).val())){ | ||
1256 | - urlList.eq(i).focus().select().addClass("error"); | ||
1257 | - common.util.__tip("Url必须包含yohobuy或者yoho,域名格式为com或者cn!"); | ||
1258 | - return false; | ||
1259 | - } | ||
1260 | - } | ||
1261 | - } | ||
1262 | - return true; | ||
1263 | -} | ||
1264 | -//结束时间校验 | ||
1265 | -function checkEndTime(){ | ||
1266 | - var endTimeList = $(".grid input[name='endTime']"); | ||
1267 | - for(var i=0; i<endTimeList.length; i++){ | ||
1268 | - if(!endTimeList.eq(i).val()){ | ||
1269 | - endTimeList.eq(i).focus().addClass("error"); | ||
1270 | - common.util.__tip("结束时间不能为空!"); | ||
1271 | - return false; | ||
1272 | - } | ||
1273 | - } | ||
1274 | - return true; | ||
1275 | -} | ||
1276 | -//编辑动画事件 | ||
1277 | -function showEditorIconEvent(){ | ||
1278 | - if(shopOperate == 'editor'){ | ||
1279 | - $(".contentpanel .model-editor").hover( | ||
1280 | - function () { | ||
1281 | - var _this = $(this); | ||
1282 | - var editorModelId = $(this).attr("data-toggle"); | ||
1283 | - var editorModelTitle = $(this).attr("data-title"); | ||
1284 | - var editorIcon = ""; | ||
1285 | - if(editorModelId == "editor-brand-app"){ | ||
1286 | - editorIcon += "<div class='editorBorder' style='border: 5px solid #ff69b4'></div>" | ||
1287 | - }else{ | ||
1288 | - editorIcon += "<div class='editorBorder'></div>" | ||
1289 | - } | ||
1290 | - editorIcon += "<a class='editorIcon' href='javascript:'>编辑</a>" | ||
1291 | - _this.append(editorIcon); | ||
1292 | - //编辑事件 | ||
1293 | - editorIconEvent(editorModelTitle,editorModelId); | ||
1294 | - }, | ||
1295 | - function () { | ||
1296 | - $(".editorIcon").remove(); | ||
1297 | - $(".editorBorder").remove(); | ||
1298 | - } | ||
1299 | - ); | ||
1300 | - } | ||
1301 | -} | ||
1302 | -//工具类编辑表单初始化 | ||
1303 | -function untilEditorEvent(id){ | ||
1304 | - var e = new common.edit("#"+id,{bucket:"yhb-img02"}); | ||
1305 | - e.init(); | ||
1306 | - e.on("callback",function(obj){ | ||
1307 | - if(/^file_onComplete_shopBannerImage_/.test(obj.key)){ | ||
1308 | - var _index = obj.key.replace(/^file_onComplete_shopBannerImage_/,''); | ||
1309 | - g.__rows[_index].shopSrc = obj.data; | ||
1310 | - } | ||
1311 | - if(/^file_onComplete_DetailbannerImage_/.test(obj.key)){ | ||
1312 | - var _index = obj.key.replace(/^file_onComplete_DetailbannerImage_/,''); | ||
1313 | - g.__rows[_index].detailSrc = obj.data; | ||
1314 | - } | ||
1315 | - if(/^file_onComplete_largePicImage_/.test(obj.key)){ | ||
1316 | - var _index = obj.key.replace(/^file_onComplete_largePicImage_/,''); | ||
1317 | - var _indexList = _index.split("_"); | ||
1318 | - g.__rows[_indexList[0]].data[_indexList[1]].src = obj.data; | ||
1319 | - } | ||
1320 | - if(/^file_onComplete_smallPicImage_/.test(obj.key)){ | ||
1321 | - var _index = obj.key.replace(/^file_onComplete_smallPicImage_/,''); | ||
1322 | - var _indexList = _index.split("_"); | ||
1323 | - g.__rows[_indexList[0]].data[_indexList[1]].src = obj.data; | ||
1324 | - } | ||
1325 | - if(/^file_onComplete_recommendImage_/.test(obj.key)){ | ||
1326 | - var _index = obj.key.replace(/^file_onComplete_recommendImage_/,''); | ||
1327 | - g.__rows[_index].src = obj.data; | ||
1328 | - } | ||
1329 | - if(/^file_onComplete_hotRecommendImage_/.test(obj.key)){ | ||
1330 | - var _index = obj.key.replace(/^file_onComplete_hotRecommendImage_/,''); | ||
1331 | - g.__rows[_index].src = obj.data; | ||
1332 | - } | ||
1333 | - if(/^file_onComplete_signboardImage_/.test(obj.key)){ | ||
1334 | - var _index = obj.key.replace(/^file_onComplete_signboardImage_/,''); | ||
1335 | - var _indexList = _index.split("_"); | ||
1336 | - g.__rows[_indexList[0]].data[_indexList[1]].src = obj.data; | ||
1337 | - } | ||
1338 | - }); | ||
1339 | - $("#"+id+" nav").hide(); | ||
1340 | - $(".modal-dialog .modal-header .close").hide(); | ||
1341 | - $(".modal-dialog .modal-body .editor-dialog").css("overflow-y","auto"); | ||
1342 | - $(".modal-dialog .modal-body .editor-dialog").css("overflow-x","hidden"); | ||
1343 | -} | ||
1344 | -//资源位图片代码生成器 | ||
1345 | -function resourcesHtmlInit(item,resName){ | ||
1346 | - var picList = item.data, | ||
1347 | - htmlPic = ""; | ||
1348 | - for(var i=0; i<picList.length; i++){ | ||
1349 | - picList[i].url=picList[i].url.replace(/'/g,'\"'); // 字符串里面双引号转换成单引号 | ||
1350 | - htmlPic += "<div class='row'>" + | ||
1351 | - "<div class='col-sm-2'><input type=file name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' /></div>" + | ||
1352 | - "<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>" + | ||
1353 | - "<div class='col-sm-2'>"; | ||
1354 | - if(i>0){ | ||
1355 | - 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 +"' />" + | ||
1356 | - "<span style='color: #999; font-size: 12px'>*上一条结束时间</span>"; | ||
1357 | - }else{ | ||
1358 | - 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 +"' />"; | ||
1359 | - } | ||
1360 | - htmlPic += "</div><div class='col-sm-2'>" + | ||
1361 | - "<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>" + | ||
1362 | - "<div class='col-sm-1'><span class='publishStatus' style='white-space: nowrap; line-height: 40px'>"+ checkdate(picList[i].startTime,picList[i].endTime) +"</span></div>" + | ||
1363 | - "<div class='col-sm-2' style='line-height: 40px'>"; | ||
1364 | - if(i == (picList.length-1) && picList.length > 1){ | ||
1365 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+ item.__index +"_"+ i +"' /><br>"; | ||
1366 | - htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+ item.__index +"_"+ i +"' />"; | ||
1367 | - } | ||
1368 | - if(i < (picList.length-1) && picList.length > 1){ | ||
1369 | - htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+ item.__index +"_"+ i +"' />"; | ||
1370 | - } | ||
1371 | - if(i == (picList.length-1) && picList.length == 1){ | ||
1372 | - htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' value='添加一条' data-index='"+ item.__index +"_"+ i +"' />"; | ||
1373 | - } | ||
1374 | - htmlPic += "</div></div>"; | ||
1375 | - } | ||
1376 | - return htmlPic; | ||
1377 | -} | ||
1378 | -//展示最新,最热排名前20条 | ||
1379 | -function productTopDataShow(id, products){ | ||
1380 | - if(products.data && products.data.length > 0){ | ||
1381 | - $("#"+id+" .top20List").html(common.util.__template2($("#top20Products").html(),products)); | ||
1382 | - productTopDataLink(g.__rows); | ||
1383 | - }else{ | ||
1384 | - $("#"+id+" .top20List").html("<font color='red'>* 最新上架20条加载失败,请重新加载页面!</font>"); | ||
1385 | - } | ||
1386 | -} | ||
1387 | -//top20商品根据以展示商品自动勾选 | ||
1388 | -function productTopDataLink(productList){ | ||
1389 | - $(".top20List li").removeClass("selected"); | ||
1390 | - for(var i=0; i<productList.length; i++){ | ||
1391 | - var productId = productList[i].productId; | ||
1392 | - $(".top20List").find("li[data-productId = "+ productId +"]").addClass("selected"); | ||
1393 | - } | ||
1394 | - $(".topTip span").text("已经勾选"+ productList.length +"件,最多勾选8件商品!"); | ||
1395 | -} | ||
1396 | -//json数组排序, dis参数:0:从小到大,1:从大到小 | ||
1397 | -function sortJson(arr,dir){ | ||
1398 | - var len = arr.length, tmp; | ||
1399 | - for(var i=0; i < len-1; i++){ | ||
1400 | - if(dir == 0){ | ||
1401 | - for(var j=0; j < len-1-i; j++){ | ||
1402 | - if(parseInt(arr[j].position) > parseInt(arr[j+1].position)){ | ||
1403 | - tmp = arr[j]; | ||
1404 | - arr[j] = arr[j+1]; | ||
1405 | - arr[j+1] = tmp; | ||
1406 | - } | ||
1407 | - } | ||
1408 | - } | ||
1409 | - if(dir == 1){ | ||
1410 | - for(var j=0; j < len-1-i; j++){ | ||
1411 | - if(parseInt(arr[j].position) < parseInt(arr[j+1].position)){ | ||
1412 | - tmp = arr[j]; | ||
1413 | - arr[j] = arr[j+1]; | ||
1414 | - arr[j+1] = tmp; | ||
1415 | - } | ||
1416 | - } | ||
1417 | - } | ||
1418 | - | ||
1419 | - } | ||
1420 | - return arr; | ||
1421 | -} | ||
1422 | -//数组克隆 | ||
1423 | -function cloneArr(arr1,arr2){ | ||
1424 | - arr2.length = 0; | ||
1425 | - for(var i=0; i<arr1.length; i++){ | ||
1426 | - arr2.push($.extend(true,{},arr1[i])); | ||
1427 | - } | ||
1428 | - return arr2; | ||
1429 | -} | ||
1430 | -//时间校验 | ||
1431 | -function checkdate(startDate,endDate){ | ||
1432 | - if (endDate) { | ||
1433 | - var endDateTemp = endDate.split(" "); | ||
1434 | - var arrEndDate = endDateTemp[0].split("-"); | ||
1435 | - var arrEndTime = endDateTemp[1].split(":"); | ||
1436 | - var allEndDate = new Date(arrEndDate[0], parseInt(arrEndDate[1])-1, arrEndDate[2], arrEndTime[0], arrEndTime[1], arrEndTime[2]); | ||
1437 | - } | ||
1438 | - if(startDate){ | ||
1439 | - var startDateTemp = startDate.split(" "); | ||
1440 | - var arrStartDate = startDateTemp[0].split("-"); | ||
1441 | - var arrStartTime = startDateTemp[1].split(":"); | ||
1442 | - var allStartDate = new Date(arrStartDate[0], parseInt(arrStartDate[1])-1, arrStartDate[2], arrStartTime[0], arrStartTime[1], arrStartTime[2]); | ||
1443 | - } | ||
1444 | - var nowDate = new Date(); | ||
1445 | - | ||
1446 | - if(startDate && endDate){ | ||
1447 | - if(nowDate > allEndDate) { | ||
1448 | - return "<b style='color: #ec971f'>已过期</b>"; | ||
1449 | - }else if(allStartDate > nowDate){ | ||
1450 | - return "<b style='color: #428bca'>未发布</b>"; | ||
1451 | - }else{ | ||
1452 | - return "<b style='color: #5cb85c'>发布中</b>"; | ||
1453 | - } | ||
1454 | - }else if(!startDate && endDate){ | ||
1455 | - if(nowDate > allEndDate) { | ||
1456 | - return "<b style='color: #ec971f'>已过期</b>"; | ||
1457 | - }else{ | ||
1458 | - return "<b style='color: #5cb85c'>发布中</b>"; | ||
1459 | - } | ||
1460 | - }else{ | ||
1461 | - return "<b style='color: #428bca'>未发布</b>"; | ||
1462 | - } | ||
1463 | - return true; | ||
1464 | -} | ||
1465 | -//去除json中的url参数 | ||
1466 | -function removeUrlParam(id, data){ | ||
1467 | - if(id == "editor-largePic" || id == "editor-smallPic"){ | ||
1468 | - for(var i=0; i<data.length; i++){ | ||
1469 | - var data2 = data[i].data; | ||
1470 | - for(var j=0; j<data2.length; j++){ | ||
1471 | - data2[j].url = ""; | ||
1472 | - } | ||
1473 | - } | ||
1474 | - } | ||
1475 | - if(id == "editor-recommend"){ | ||
1476 | - for(var i=0; i<data.length; i++){ | ||
1477 | - data[i].url = ""; | ||
1478 | - } | ||
1479 | - } | ||
1480 | -} | ||
1481 | - | ||
1482 | -/********************事件绑定*********************/ | ||
1483 | - | ||
1484 | -//基础模板,经典模板切换 | ||
1485 | -$(document).on("click",".tabheader .nav-tabs li",function(){ | ||
1486 | - $(this).addClass('active').siblings('li').removeClass('active'); | ||
1487 | - curTemplateType = $(this).attr("data-toggle"); | ||
1488 | - showMain(); | ||
1489 | -}) | ||
1490 | -//pc,app切换 | ||
1491 | -$(document).on("click","input[name=brandLevel]",function(){ | ||
1492 | - curPlatform = $("input[name=brandLevel]:checked").val(); | ||
1493 | - showMain(); | ||
1494 | -}) | ||
1495 | -//暂存模板 | ||
1496 | -$(document).on("click","#saveModule",function(){ | ||
1497 | - saveDecoration(100); | ||
1498 | -}) | ||
1499 | -//提交审核 | ||
1500 | -$(document).on("click","#submitModule",function(){ | ||
1501 | - jsonMain.templateType = curTemplateType; | ||
1502 | - var templateName = curTemplateType=='2'?"经典模板":"基础模板"; | ||
1503 | - common.dialog.confirm( | ||
1504 | - "提交审核确认", | ||
1505 | - "你确认使用<strong style='color:#5cb85c'>"+ templateName + "</strong>,并提交审核么?审核过程中,店铺装修将无法修改!", | ||
1506 | - function(){ | ||
1507 | - saveDecoration(200); | ||
1508 | - }, | ||
1509 | - function(){} | ||
1510 | - ) | ||
1511 | -}) | ||
1512 | -//审核通过 | ||
1513 | -$(document).on("click","#checkOk",function(){ | ||
1514 | - common.dialog.confirm( | ||
1515 | - "审核确认", | ||
1516 | - "你确认<strong style='color:#5cb85c'>审核通过</strong>么?", | ||
1517 | - function(){ | ||
1518 | - checkDecoration(300); | ||
1519 | - }, | ||
1520 | - function(){} | ||
1521 | - ); | ||
1522 | -}) | ||
1523 | -//驳回 | ||
1524 | -$(document).on("click","#checkNo",function(){ | ||
1525 | - common.dialog.confirm( | ||
1526 | - "审核驳回", | ||
1527 | - "你确认<strong style='color:#d9534f'>审核驳回</strong>么?如果确认,<strong style='color: #f0ad4e'>请填写驳回理由!</strong>" + | ||
1528 | - "<textarea id='checkComment' class='form-control' rows='3' style='margin: 10px 0'></textarea>" + | ||
1529 | - "<div class='editorTip' style='display: none'><span>提示:请填写驳回理由!</span></div>", | ||
1530 | - function(){ | ||
1531 | - var comment = $("#checkComment").val(); | ||
1532 | - if(comment){ | ||
1533 | - checkDecoration(900,comment); | ||
1534 | - }else{ | ||
1535 | - $(".editorTip").show(); | ||
1536 | - return false; | ||
1537 | - } | ||
1538 | - }, | ||
1539 | - function(){} | ||
1540 | - ); | ||
1541 | -}) | ||
1542 | -//删除 | ||
1543 | -$(document).on("click",".deleteBtn",function(){ | ||
1544 | - var _index = $(this).data("index")+""; | ||
1545 | - var indexList = _index.split("_"); | ||
1546 | - | ||
1547 | - if(indexList.length > 1){ | ||
1548 | - [].splice.call(g.__rows[indexList[0]].data,indexList[1],1); | ||
1549 | - }else{ | ||
1550 | - [].splice.call(g.__rows,indexList[0],1); | ||
1551 | - } | ||
1552 | - g.init(g.__rows); | ||
1553 | - untilEditorEvent(curDialogId); | ||
1554 | - | ||
1555 | - if(curDialogId == "editor-newProduct" || curDialogId == "editor-hotProduct"){ | ||
1556 | - productTopDataLink(g.__rows); | ||
1557 | - } | ||
1558 | -}); | ||
1559 | -//添加一条 | ||
1560 | -$(document).on("click",".addBtn",function(){ | ||
1561 | - var _index = $(this).data("index")+""; | ||
1562 | - var indexList = _index.split("_"); | ||
1563 | - | ||
1564 | - if(indexList.length > 1){ | ||
1565 | - g.__rows[indexList[0]].data.push($.extend({},ENUM[curDialogId])); | ||
1566 | - if(curDialogId == "editor-largePic" || curDialogId == "editor-smallPic" || curDialogId == "editor-signboard"){ | ||
1567 | - (g.__rows[indexList[0]].data)[(parseInt(indexList[1]) + 1)].startTime = (g.__rows[indexList[0]].data)[indexList[1]].endTime; | ||
1568 | - } | ||
1569 | - }else{ | ||
1570 | - g.__rows.push($.extend({},ENUM[curDialogId])); | ||
1571 | - } | ||
1572 | - g.init(g.__rows); | ||
1573 | - untilEditorEvent(curDialogId); | ||
1574 | -}); | ||
1575 | -//资源位大图,水牌添加一条资源位 | ||
1576 | -$(document).on("click",".addBtn2",function(){ | ||
1577 | - if( curDialogId == "editor-largePic" && g.__rows.length > 4){ | ||
1578 | - $(".largePicAddTip").text("* 最多只能添加5个资源位大图!").css("color","#ff0000"); | ||
1579 | - return; | ||
1580 | - }else{ | ||
1581 | - $(".largePicAddTip").empty(); | ||
1582 | - g.__rows.push($.extend(true,{},ENUM["editor-largePic2"])); | ||
1583 | - g.init(g.__rows); | ||
1584 | - untilEditorEvent(curDialogId); | ||
1585 | - } | ||
1586 | -}); | ||
1587 | -//input change同时更新json | ||
1588 | -$(document).on("change",".inputChange",function(){ | ||
1589 | - var _index = $(this).attr("data-index"); | ||
1590 | - var indexList = _index.split("_"); | ||
1591 | - var _name = $(this).attr("name"); | ||
1592 | - | ||
1593 | - if(indexList.length > 1){ | ||
1594 | - (g.__rows[indexList[0]].data)[indexList[1]][_name] = $(this).val(); | ||
1595 | - }else{ | ||
1596 | - g.__rows[indexList[0]][_name] = $(this).val(); | ||
1597 | - } | ||
1598 | - if(curDialogId == "editor-largePic" || curDialogId == "editor-smallPic" || curDialogId == "editor-signboard"){ | ||
1599 | - if($(this).attr("name") == "endTime"){ | ||
1600 | - if(g.__rows[indexList[0]].data.length - 1 > indexList[1]){ | ||
1601 | - (g.__rows[indexList[0]].data)[(parseInt(indexList[1]) + 1)].startTime = $(this).val(); | ||
1602 | - $(this).parents(".row").next().children().find("input[name='startTime']").val($(this).val()); | ||
1603 | - | ||
1604 | - var endDate = $(this).parents(".row").next().children().find("input[name='endTime']").val(); | ||
1605 | - $(this).parents(".row").next().children().find(".publishStatus").html(checkdate($(this).val(),endDate)); | ||
1606 | - } | ||
1607 | - var startDate = $(this).parents(".row").find("input[name='startTime']").val(); | ||
1608 | - $(this).parents(".row").find(".publishStatus").html(checkdate(startDate,$(this).val())); | ||
1609 | - } | ||
1610 | - if($(this).attr("name") == "startTime"){ | ||
1611 | - var endDate = $(this).parents(".row").find("input[name='endTime']").val(); | ||
1612 | - $(this).parents(".row").find(".publishStatus").html(checkdate($(this).val(),endDate)); | ||
1613 | - } | ||
1614 | - } | ||
1615 | - $(this).removeClass("error"); | ||
1616 | -}); | ||
1617 | -//选择Top20 | ||
1618 | -$(document).on("click",".topAdd",function(){ | ||
1619 | - if($(this).hasClass("selected")){ | ||
1620 | - $(this).removeClass("selected"); | ||
1621 | - var cutProductId = $(this).attr("data-productId"); | ||
1622 | - for(var i=0; i<g.__rows.length; i++){ | ||
1623 | - if(g.__rows[i].productId == cutProductId){ | ||
1624 | - [].splice.call(g.__rows,i,1); | ||
1625 | - break; | ||
1626 | - } | ||
1627 | - } | ||
1628 | - g.init(g.__rows); | ||
1629 | - untilEditorEvent(curDialogId); | ||
1630 | - productTopDataLink(g.__rows); | ||
1631 | - }else{ | ||
1632 | - if(g.__rows.length < 8){ | ||
1633 | - $(this).addClass("selected"); | ||
1634 | - var item = $.extend({},ENUM[curDialogId]); | ||
1635 | - item.src = $(this).find('img').attr("src"); | ||
1636 | - item.productId = $(this).attr("data-productId"); | ||
1637 | - item.productName = $(this).attr("data-productName"); | ||
1638 | - item.salesPrice = $(this).attr("data-productPrice"); | ||
1639 | - item.productSkn = $(this).attr("data-productSkn"); | ||
1640 | - item.goodsId = $(this).attr("data-goodsId"); | ||
1641 | - item.cnAlphabet = $(this).attr("data-cnAlphabet"); | ||
1642 | - g.__rows.push(item); | ||
1643 | - | ||
1644 | - g.init(g.__rows); | ||
1645 | - untilEditorEvent(curDialogId); | ||
1646 | - productTopDataLink(g.__rows); | ||
1647 | - }else{ | ||
1648 | - $(".topTip span").text("商品数量已满8个,无法继续添加商品!"); | ||
1649 | - } | ||
1650 | - } | ||
1651 | -}); |
-
Please register or login to post a comment