Authored by 陶雨

Merge branch 'develop' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into develop

... ... @@ -306,23 +306,44 @@ var util = {
}
return obj;
},
__ArrayToObj:function(data){
var result={};
if($.isArray(data)){
data.forEach(function(item,index){
result[index]=item;
});
}else if(typeof data=="string"){
result=data;
}
else{
for(var i in data){
if(data.hasOwnProperty(i)){
result[i]=util.__ArrayToObj(data[i])
__ArrayToObj:function(data){
var result={};
if($.isArray(data)){
data.forEach(function(item,index){
result[index]=item;
});
}else if(typeof data=="string"){
result=data;
}
else{
for(var i in data){
if(data.hasOwnProperty(i)){
result[i]=util.__ArrayToObj(data[i])
}
}
}
return result;
},
__ObjToArray:function(data){
var result={};
if([].toString.call(data)=="[object Object]"){
for(var name in data){
if(data.hasOwnProperty(name)&&/^\d+$/.test(name)){
result=$.isArray(result)?result:[];
result.push(util.__ObjToArray(data[name]));
}else{
result[name]=util.__ObjToArray(data[name]);
}
}
data=result;
}else if(typeof data=="string"){
result=data;
}else{
/*基本不会被运行到,需要优化*/
result=$.isArray(result)?result:[];
result=data;
}
return result;
}
return result;
}
}
module.exports = util;
\ No newline at end of file
... ...
... ... @@ -195,7 +195,7 @@ $(document).on("click", "#addBrands", function() {
Bll.Brdata = $("#brandCheckBox").val().split('|');
Bll.Brdata = Bll.Brdata.map(function(item, index) {
return {
"brandCategory": "2",
"brandCategory": "1",
"id": item
}
});
... ... @@ -433,6 +433,7 @@ e.init();
$(document).on("click", "#submit", function() {
e.submit($("#panel-body").attr("action"), function(option) {
option.data.minSortId=option.data.minSortId=="-1"?"":option.data.minSortId;
option.data.contentData = [];
Bll.contentDatas.forEach(function(item, index) {
... ...
... ... @@ -18,7 +18,8 @@ common.util.__ajax({
var Bll={
__render:function(selecter,templater,data){
$(selecter).html(common.util.__template2($("#"+templater).html(),data) );
}
},
contentData:[]
}
... ... @@ -27,9 +28,18 @@ var Bll={
Bll.__render("#content-list","content-template",ViewModel);
Bll.__render(".contents","template_content_btns",{btns:Button});
/*第二部,把楼层数据转化成数组*/
ViewModel.contentData=ViewModel.contentData;
ViewModel.contentData.forEach(function(item,index){
Bll.contentData.push(common.util.__ObjToArray(JSON.parse(item.contentData)));
});
console.log(Bll.contentData);
/*第三部解析楼层*/
Bll.__render("#add-content","template_content",{modules:Bll.contentData});
var obj2Arr = function(obj) {
... ...
... ... @@ -264,7 +264,6 @@
<script type="text/template" id="template_content">
<!-- 文本内容 -->
[[each modules as module index]]
<li class="custom-group text" data-index="[[index]]">
... ... @@ -311,6 +310,9 @@
</ul>
</div>
{{> resource/taoyu2}}
[[/if]]
<div class="actions-box">
<div class="actions-wrap">
... ...