Merge branch 'develop' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into develop
Showing
4 changed files
with
54 additions
and
20 deletions
@@ -306,23 +306,44 @@ var util = { | @@ -306,23 +306,44 @@ var util = { | ||
306 | } | 306 | } |
307 | return obj; | 307 | return obj; |
308 | }, | 308 | }, |
309 | - __ArrayToObj:function(data){ | ||
310 | - var result={}; | ||
311 | - if($.isArray(data)){ | ||
312 | - data.forEach(function(item,index){ | ||
313 | - result[index]=item; | ||
314 | - }); | ||
315 | - }else if(typeof data=="string"){ | ||
316 | - result=data; | ||
317 | - } | ||
318 | - else{ | ||
319 | - for(var i in data){ | ||
320 | - if(data.hasOwnProperty(i)){ | ||
321 | - result[i]=util.__ArrayToObj(data[i]) | 309 | + __ArrayToObj:function(data){ |
310 | + var result={}; | ||
311 | + if($.isArray(data)){ | ||
312 | + data.forEach(function(item,index){ | ||
313 | + result[index]=item; | ||
314 | + }); | ||
315 | + }else if(typeof data=="string"){ | ||
316 | + result=data; | ||
317 | + } | ||
318 | + else{ | ||
319 | + for(var i in data){ | ||
320 | + if(data.hasOwnProperty(i)){ | ||
321 | + result[i]=util.__ArrayToObj(data[i]) | ||
322 | + } | ||
322 | } | 323 | } |
323 | } | 324 | } |
325 | + return result; | ||
326 | + }, | ||
327 | + __ObjToArray:function(data){ | ||
328 | + var result={}; | ||
329 | + if([].toString.call(data)=="[object Object]"){ | ||
330 | + for(var name in data){ | ||
331 | + if(data.hasOwnProperty(name)&&/^\d+$/.test(name)){ | ||
332 | + result=$.isArray(result)?result:[]; | ||
333 | + result.push(util.__ObjToArray(data[name])); | ||
334 | + }else{ | ||
335 | + result[name]=util.__ObjToArray(data[name]); | ||
336 | + } | ||
337 | + } | ||
338 | + data=result; | ||
339 | + }else if(typeof data=="string"){ | ||
340 | + result=data; | ||
341 | + }else{ | ||
342 | + /*基本不会被运行到,需要优化*/ | ||
343 | + result=$.isArray(result)?result:[]; | ||
344 | + result=data; | ||
345 | + } | ||
346 | + return result; | ||
324 | } | 347 | } |
325 | - return result; | ||
326 | -} | ||
327 | } | 348 | } |
328 | module.exports = util; | 349 | module.exports = util; |
@@ -195,7 +195,7 @@ $(document).on("click", "#addBrands", function() { | @@ -195,7 +195,7 @@ $(document).on("click", "#addBrands", function() { | ||
195 | Bll.Brdata = $("#brandCheckBox").val().split('|'); | 195 | Bll.Brdata = $("#brandCheckBox").val().split('|'); |
196 | Bll.Brdata = Bll.Brdata.map(function(item, index) { | 196 | Bll.Brdata = Bll.Brdata.map(function(item, index) { |
197 | return { | 197 | return { |
198 | - "brandCategory": "2", | 198 | + "brandCategory": "1", |
199 | "id": item | 199 | "id": item |
200 | } | 200 | } |
201 | }); | 201 | }); |
@@ -433,6 +433,7 @@ e.init(); | @@ -433,6 +433,7 @@ e.init(); | ||
433 | 433 | ||
434 | $(document).on("click", "#submit", function() { | 434 | $(document).on("click", "#submit", function() { |
435 | e.submit($("#panel-body").attr("action"), function(option) { | 435 | e.submit($("#panel-body").attr("action"), function(option) { |
436 | + option.data.minSortId=option.data.minSortId=="-1"?"":option.data.minSortId; | ||
436 | 437 | ||
437 | option.data.contentData = []; | 438 | option.data.contentData = []; |
438 | Bll.contentDatas.forEach(function(item, index) { | 439 | Bll.contentDatas.forEach(function(item, index) { |
@@ -18,7 +18,8 @@ common.util.__ajax({ | @@ -18,7 +18,8 @@ common.util.__ajax({ | ||
18 | var Bll={ | 18 | var Bll={ |
19 | __render:function(selecter,templater,data){ | 19 | __render:function(selecter,templater,data){ |
20 | $(selecter).html(common.util.__template2($("#"+templater).html(),data) ); | 20 | $(selecter).html(common.util.__template2($("#"+templater).html(),data) ); |
21 | - } | 21 | + }, |
22 | + contentData:[] | ||
22 | } | 23 | } |
23 | 24 | ||
24 | 25 | ||
@@ -27,9 +28,18 @@ var Bll={ | @@ -27,9 +28,18 @@ var Bll={ | ||
27 | Bll.__render("#content-list","content-template",ViewModel); | 28 | Bll.__render("#content-list","content-template",ViewModel); |
28 | Bll.__render(".contents","template_content_btns",{btns:Button}); | 29 | Bll.__render(".contents","template_content_btns",{btns:Button}); |
29 | 30 | ||
30 | - | ||
31 | /*第二部,把楼层数据转化成数组*/ | 31 | /*第二部,把楼层数据转化成数组*/ |
32 | -ViewModel.contentData=ViewModel.contentData; | 32 | +ViewModel.contentData.forEach(function(item,index){ |
33 | + Bll.contentData.push(common.util.__ObjToArray(JSON.parse(item.contentData))); | ||
34 | +}); | ||
35 | +console.log(Bll.contentData); | ||
36 | + | ||
37 | +/*第三部解析楼层*/ | ||
38 | +Bll.__render("#add-content","template_content",{modules:Bll.contentData}); | ||
39 | + | ||
40 | + | ||
41 | + | ||
42 | + | ||
33 | 43 | ||
34 | 44 | ||
35 | var obj2Arr = function(obj) { | 45 | var obj2Arr = function(obj) { |
@@ -264,7 +264,6 @@ | @@ -264,7 +264,6 @@ | ||
264 | 264 | ||
265 | 265 | ||
266 | <script type="text/template" id="template_content"> | 266 | <script type="text/template" id="template_content"> |
267 | - | ||
268 | <!-- 文本内容 --> | 267 | <!-- 文本内容 --> |
269 | [[each modules as module index]] | 268 | [[each modules as module index]] |
270 | <li class="custom-group text" data-index="[[index]]"> | 269 | <li class="custom-group text" data-index="[[index]]"> |
@@ -311,6 +310,9 @@ | @@ -311,6 +310,9 @@ | ||
311 | 310 | ||
312 | </ul> | 311 | </ul> |
313 | </div> | 312 | </div> |
313 | + | ||
314 | + {{> resource/taoyu2}} | ||
315 | + | ||
314 | [[/if]] | 316 | [[/if]] |
315 | <div class="actions-box"> | 317 | <div class="actions-box"> |
316 | <div class="actions-wrap"> | 318 | <div class="actions-wrap"> |
-
Please register or login to post a comment