...
|
...
|
@@ -9,7 +9,6 @@ var addObj = require('./partials/addObj'); |
|
|
var resources = [];
|
|
|
var times = [];
|
|
|
var currIndex = 0;
|
|
|
//var ViewModel = {};
|
|
|
//资源id
|
|
|
var param = location.href.substring(location.href.lastIndexOf("/") + 1);
|
|
|
common.util.__ajax({
|
...
|
...
|
@@ -18,7 +17,6 @@ common.util.__ajax({ |
|
|
async: false
|
|
|
}, function (res) {
|
|
|
resources = res.data;
|
|
|
//ViewModel = res.data;
|
|
|
console.log(resources);
|
|
|
}, true);
|
|
|
|
...
|
...
|
@@ -43,8 +41,7 @@ var Bll = { |
|
|
//console.log("打开的数据module",module);
|
|
|
var d = new common.dialog({
|
|
|
title: (!!~index ? "修改" : "添加") + btn[0].button_name,
|
|
|
content: common.util.__template2($("#" + module.contentData.dialog).html(), module),
|
|
|
//content: common.util.__template2($("#" + btn[0].dialog).html(), module),
|
|
|
content: common.util.__template2($("#" + btn[0].dialog).html(), module),
|
|
|
width: '50%',
|
|
|
button: [{
|
|
|
value: "保存",
|
...
|
...
|
@@ -62,8 +59,6 @@ var Bll = { |
|
|
}
|
|
|
!!~index ? Bll.contentDatas[currIndex][index] = module : Bll.contentDatas[currIndex].push(module);
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
//!!~index ? Bll.contentDatas[index] = module : Bll.contentDatas.push(module);
|
|
|
//Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
d.close();
|
|
|
}
|
|
|
return false;
|
...
|
...
|
@@ -189,7 +184,6 @@ for(var i = 0; i < resources.length; i++) { |
|
|
|
|
|
/*第一步,基础模板*/
|
|
|
Bll.__render("#content-list", "content-template", resources[currIndex]);
|
|
|
//Bll.__render("#content-list", "content-template", ViewModel);
|
|
|
Bll.__render(".contents", "template_content_btns", {btns: Button});
|
|
|
Bll.__render("#times-list", "times-template", {times:times, selected:0});
|
|
|
|
...
|
...
|
@@ -217,30 +211,9 @@ for(var i = 0; i < resources.length; i++) { |
|
|
Bll.contentDatas[i].push(item);
|
|
|
});
|
|
|
}
|
|
|
//ViewModel.contentData.forEach(function (item, index) {
|
|
|
// item.contentData = JSON.parse(item.contentData);
|
|
|
// var temp;
|
|
|
// if (item.contentData.template_name == "kidsBrands") {
|
|
|
// temp = item.contentData.data.params.more_url;
|
|
|
// item.contentData.data.params.more_url = {};
|
|
|
// item.contentData.data.params.more_url.action = JSON.parse(temp).action || "";
|
|
|
// item.contentData.data.params.more_url.url = JSON.parse(temp).url || "";
|
|
|
// }
|
|
|
// if (item.contentData.template_name == 'title') {
|
|
|
// temp = item.contentData.data.more_link;
|
|
|
// item.contentData.data.more_link = {};
|
|
|
// item.contentData.data.more_link.action = JSON.parse(temp).action || "";
|
|
|
// item.contentData.data.more_link.url = JSON.parse(temp).url || "";
|
|
|
// }
|
|
|
// item.contentData = JSON.stringify(item.contentData);
|
|
|
// item.contentData = item.contentData.replace(/(gif|png|jpg|jpeg)\?[^"]*/g, '$1');
|
|
|
// item.contentData = common.util.__ObjToArray(JSON.parse(item.contentData));
|
|
|
// Bll.contentDatas.push(item);
|
|
|
//});
|
|
|
|
|
|
/*第三部解析楼层*/
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
//Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
|
|
|
/*第四部 操作按钮 添加 删除 修改*/
|
|
|
$(document).on("click", ".add_btn", function () {
|
...
|
...
|
@@ -269,6 +242,7 @@ $(document).on("change", ".observe", function () { |
|
|
/*删除*/
|
|
|
$(document).on("click", ".del", function () {//删除
|
|
|
var index = $(this).data("index");
|
|
|
console.log(Bll.contentDatas[currIndex][index]);
|
|
|
common.dialog.confirm("警告",
|
|
|
common.util.__template2("是否确认删除?", {}),
|
|
|
function () {
|
...
|
...
|
@@ -283,30 +257,12 @@ $(document).on("click", ".del", function () {//删除 |
|
|
});
|
|
|
});
|
|
|
|
|
|
$(document).on("click", ".del", function () {//删除
|
|
|
var index = $(this).data("index");
|
|
|
common.dialog.confirm("警告",
|
|
|
common.util.__template2("是否确认删除?", {}),
|
|
|
function () {
|
|
|
if (Bll.contentDatas[index].id) {
|
|
|
common.util.__ajax({
|
|
|
url: "/resources/delResContent",
|
|
|
data: {id: Bll.contentDatas[index].id}
|
|
|
});
|
|
|
}
|
|
|
Bll.contentDatas.splice(index, 1);
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
});
|
|
|
|
|
|
//$("#index_" + index).remove();
|
|
|
});
|
|
|
|
|
|
/*编辑*/
|
|
|
$(document).on("click", ".edit", function () {
|
|
|
var index = $(this).data("index");
|
|
|
var item = Bll.contentDatas[currIndex][index];
|
|
|
//var item = Bll.contentDatas[index];
|
|
|
Bll.module = $.extend(true, {}, item);
|
|
|
console.log(Bll.module);
|
|
|
Bll.toast(index, Bll.module);
|
|
|
});
|
|
|
|
...
|
...
|
@@ -425,9 +381,7 @@ $(document).on("click", "#copyTab", function() { |
|
|
url: "/resources/copyResContent",
|
|
|
data: {rId:resources[currIndex].resource.id}
|
|
|
}, function (res) {
|
|
|
//setTimeout(function() {
|
|
|
window.location.href = window.location.href;
|
|
|
//}, 2000);
|
|
|
});
|
|
|
});
|
|
|
//保存时间
|
...
|
...
|
@@ -447,9 +401,7 @@ $(document).on("click", "#saveTime", function() { |
|
|
time:times[currIndex].time
|
|
|
}
|
|
|
}, function (res) {
|
|
|
//setTimeout(function() {
|
|
|
window.location.href = window.location.href;
|
|
|
//}, 2000);
|
|
|
});
|
|
|
});
|
|
|
new common.edit2("#times-list").init();
|
...
|
...
|
@@ -483,9 +435,7 @@ $(document).on("click", "#delTab", function() { |
|
|
id: resources[currIndex].resource.id
|
|
|
}
|
|
|
}, function (res) {
|
|
|
//setTimeout(function() {
|
|
|
window.location.href = window.location.href;
|
|
|
//}, 2000);
|
|
|
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -500,8 +450,6 @@ $(document).on("click", "#sub_btn", function () { |
|
|
};
|
|
|
for (var i = 0; i < Bll.contentDatas[currIndex].length; i++) {
|
|
|
var contentData = Bll.contentDatas[currIndex][i].contentData;
|
|
|
//for (var i = 0; i < Bll.contentDatas.length; i++) {
|
|
|
// var contentData = Bll.contentDatas[i].contentData;
|
|
|
var action;
|
|
|
var url;
|
|
|
var goodsSrc = "imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90";
|
...
|
...
|
@@ -547,13 +495,9 @@ $(document).on("click", "#sub_btn", function () { |
|
|
data.content[i] = JSON.stringify(common.util.__ArrayToObj(Bll.contentDatas[currIndex][i].contentData));
|
|
|
if (Bll.contentDatas[currIndex][i].id) {
|
|
|
data.data_id[i] = "id_" + Bll.contentDatas[currIndex][i].id;
|
|
|
//data.content[i] = JSON.stringify(common.util.__ArrayToObj(Bll.contentDatas[i].contentData));
|
|
|
//if (Bll.contentDatas[i].id) {
|
|
|
// data.data_id[i] = "id_" + Bll.contentDatas[i].id;
|
|
|
}
|
|
|
}
|
|
|
data.rId = resources[currIndex].resource.id;
|
|
|
//data.rId = param;
|
|
|
data.content = JSON.stringify(data.content);
|
|
|
data.data_id = JSON.stringify(data.data_id);
|
|
|
common.util.__ajax({
|
...
|
...
|
@@ -744,13 +688,7 @@ $(document).on("mouseover", "#add-content .dragItem", function () { |
|
|
})
|
|
|
drag.Initialize();
|
|
|
});
|
|
|
//$(document).on("mouseover", "#add-content .dragItem", function () {
|
|
|
// var drag = new common.drag("#add-content", Bll.contentDatas, function (data) {
|
|
|
// Bll.contentDatas = data;
|
|
|
// Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
// })
|
|
|
// drag.Initialize();
|
|
|
//});
|
|
|
|
|
|
$(document).on("mouseleave", "#add-content .dragItem", function () {
|
|
|
new common.drag("#add-content").destroy();
|
|
|
});
|
...
|
...
|
|