...
|
...
|
@@ -6,10 +6,9 @@ var Validate = require('./partials/Validate1'); |
|
|
var addObj = require('./partials/addObj');
|
|
|
|
|
|
/*获取数据*/
|
|
|
//var resources = [];
|
|
|
//var times = [];
|
|
|
//var currIndex = 0;
|
|
|
var ViewModel = {};
|
|
|
var resources = [];
|
|
|
var times = [];
|
|
|
var currIndex = 0;
|
|
|
//资源id
|
|
|
var param = location.href.substring(location.href.lastIndexOf("/") + 1);
|
|
|
common.util.__ajax({
|
...
|
...
|
@@ -17,9 +16,8 @@ common.util.__ajax({ |
|
|
data: {id: param},
|
|
|
async: false
|
|
|
}, function (res) {
|
|
|
//resources = res.data;
|
|
|
ViewModel = res.data;
|
|
|
//console.log(resources);
|
|
|
resources = res.data;
|
|
|
console.log(resources);
|
|
|
}, true);
|
|
|
|
|
|
/*配置模块*/
|
...
|
...
|
@@ -59,10 +57,8 @@ var Bll = { |
|
|
if (resourceObj[module.contentData.template_name]) {
|
|
|
resourceObj[module.contentData.template_name](module.contentData.data);
|
|
|
}
|
|
|
//!!~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});
|
|
|
!!~index ? Bll.contentDatas[currIndex][index] = module : Bll.contentDatas[currIndex].push(module);
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
d.close();
|
|
|
}
|
|
|
return false;
|
...
|
...
|
@@ -182,16 +178,17 @@ var Bll = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
////初始化时间
|
|
|
//var statusArr = ["已过期", "进行中", "未发布"];
|
|
|
//for(var i = 0; i < resources.length; i++) {
|
|
|
// //status 0:已过期;1:进行中;2:未发布
|
|
|
// var time = resources[i].resource.publishTime==0?"":Bll.getLocalTime(resources[i].resource.publishTime);
|
|
|
// times[i] = {
|
|
|
// time:time,
|
|
|
// status:statusArr[resources[i].status]
|
|
|
// }
|
|
|
//}
|
|
|
//初始化时间
|
|
|
var statusArr = ["已过期", "进行中", "未发布"];
|
|
|
for(var i = 0; i < resources.length; i++) {
|
|
|
//status 0:已过期;1:进行中;2:未发布
|
|
|
var t = new Date(resources[i].resource.publishTime*1000);
|
|
|
var time = resources[i].resource.publishTime==0?"":common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
|
|
|
times[i] = {
|
|
|
time:time,
|
|
|
status:statusArr[resources[i].status]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 过滤函数
|
...
|
...
|
@@ -212,79 +209,57 @@ function Unique(Array,key) { |
|
|
}
|
|
|
|
|
|
/*第一步,基础模板*/
|
|
|
//Bll.__render("#content-list", "content-template", resources[currIndex]);
|
|
|
Bll.__render("#content-list", "content-template", ViewModel);
|
|
|
Bll.__render("#content-list", "content-template", resources[currIndex]);
|
|
|
Bll.__render(".contents", "template_content_btns", {btns: Button});
|
|
|
//Bll.__render("#times-list", "times-template", {times:times, selected:0});
|
|
|
Bll.__render("#times-list", "times-template", {times:times, selected:0});
|
|
|
|
|
|
/*第二部,把楼层数据转化成数组*/
|
|
|
//for(var i = 0; i < resources.length; i++) {
|
|
|
// Bll.contentDatas[i] = [];
|
|
|
// resources[i].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[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 || "";
|
|
|
}
|
|
|
//推荐品牌默认加一张图片
|
|
|
if (item.contentData.template_name == 'appHotBrands') {
|
|
|
if (!item.contentData.data.image) {
|
|
|
item.contentData.data.image = {};
|
|
|
item.contentData.data.image = {
|
|
|
"src": "",
|
|
|
"alt": "",
|
|
|
"url": {
|
|
|
"action": "",
|
|
|
"url": ""
|
|
|
for(var i = 0; i < resources.length; i++) {
|
|
|
Bll.contentDatas[i] = [];
|
|
|
resources[i].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 || "";
|
|
|
}
|
|
|
//推荐品牌默认加一张图片
|
|
|
if (item.contentData.template_name == 'appHotBrands') {
|
|
|
if (!item.contentData.data.image) {
|
|
|
item.contentData.data.image = {};
|
|
|
item.contentData.data.image = {
|
|
|
"src": "",
|
|
|
"alt": "",
|
|
|
"url": {
|
|
|
"action": "",
|
|
|
"url": ""
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//默认图标一行4个
|
|
|
if (item.contentData.template_name == 'appIconList') {
|
|
|
if (!item.contentData.number) {
|
|
|
item.contentData.number = 4;
|
|
|
//默认图标一行4个
|
|
|
if (item.contentData.template_name == 'appIconList') {
|
|
|
if (!item.contentData.number) {
|
|
|
item.contentData.number = 4;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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);
|
|
|
});
|
|
|
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[i].push(item);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/*第三部解析楼层*/
|
|
|
//Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
|
|
|
/*第四部 操作按钮 添加 删除 修改*/
|
|
|
$(document).on("click", ".add_btn", function () {
|
...
|
...
|
@@ -311,45 +286,26 @@ $(document).on("change", ".observe", function () { |
|
|
});
|
|
|
|
|
|
/*删除*/
|
|
|
//$(document).on("click", ".del", function () {//删除
|
|
|
// var index = $(this).data("index");
|
|
|
// common.dialog.confirm("警告",
|
|
|
// common.util.__template2("是否确认删除?", {}),
|
|
|
// function () {
|
|
|
// if (Bll.contentDatas[currIndex][index].id) {
|
|
|
// common.util.__ajax({
|
|
|
// url: "/resources/delResContent",
|
|
|
// data: {id: Bll.contentDatas[currIndex][index].id}
|
|
|
// });
|
|
|
// }
|
|
|
// Bll.contentDatas[currIndex].splice(index, 1);
|
|
|
// Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
// });
|
|
|
//});
|
|
|
|
|
|
$(document).on("click", ".del", function () {//删除
|
|
|
var index = $(this).data("index");
|
|
|
common.dialog.confirm("警告",
|
|
|
common.util.__template2("是否确认删除?", {}),
|
|
|
function () {
|
|
|
if (Bll.contentDatas[index].id) {
|
|
|
if (Bll.contentDatas[currIndex][index].id) {
|
|
|
common.util.__ajax({
|
|
|
url: "/resources/delResContent",
|
|
|
data: {id: Bll.contentDatas[index].id}
|
|
|
data: {id: Bll.contentDatas[currIndex][index].id}
|
|
|
});
|
|
|
}
|
|
|
Bll.contentDatas.splice(index, 1);
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
Bll.contentDatas[currIndex].splice(index, 1);
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
});
|
|
|
|
|
|
//$("#index_" + index).remove();
|
|
|
});
|
|
|
|
|
|
/*编辑*/
|
|
|
$(document).on("click", ".edit", function () {
|
|
|
var index = $(this).data("index");
|
|
|
//var item = Bll.contentDatas[currIndex][index];
|
|
|
var item = Bll.contentDatas[index];
|
|
|
var item = Bll.contentDatas[currIndex][index];
|
|
|
Bll.module = $.extend(true, {}, item);
|
|
|
Bll.toast(index, Bll.module);
|
|
|
});
|
...
|
...
|
@@ -545,7 +501,6 @@ $(document).on("click", "#delTab", function() { |
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
/*保存事件*/
|
|
|
$(document).on("click", "#sub_btn", function () {
|
|
|
var data = {
|
...
|
...
|
@@ -553,10 +508,8 @@ $(document).on("click", "#sub_btn", function () { |
|
|
"data_id": {},
|
|
|
"rId": ""
|
|
|
};
|
|
|
//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;
|
|
|
for (var i = 0; i < Bll.contentDatas[currIndex].length; i++) {
|
|
|
var contentData = Bll.contentDatas[currIndex][i].contentData;
|
|
|
var action;
|
|
|
var url;
|
|
|
var goodsSrc = "imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90";
|
...
|
...
|
@@ -600,16 +553,12 @@ $(document).on("click", "#sub_btn", function () { |
|
|
}
|
|
|
}
|
|
|
data.content[i] = JSON.stringify(common.util.__ArrayToObj(contentData));
|
|
|
//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.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.rId = resources[currIndex].resource.id;
|
|
|
data.rId = param;
|
|
|
data.rId = resources[currIndex].resource.id;
|
|
|
data.content = JSON.stringify(data.content);
|
|
|
data.data_id = JSON.stringify(data.data_id);
|
|
|
common.util.__ajax({
|
...
|
...
|
@@ -802,20 +751,14 @@ $(document).on("click", ".removepic", function () { |
|
|
datas: isg ? Bll.module.contentData.data[i].list : Bll.module.contentData.data
|
|
|
}));
|
|
|
});
|
|
|
//$(document).on("mouseover", "#add-content .dragItem", function () {
|
|
|
// var drag = new common.drag("#add-content", Bll.contentDatas[currIndex], function (data) {
|
|
|
// Bll.contentDatas[currIndex] = data;
|
|
|
// Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
// })
|
|
|
// 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});
|
|
|
var drag = new common.drag("#add-content", Bll.contentDatas[currIndex], function (data) {
|
|
|
Bll.contentDatas[currIndex] = data;
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
|
|
|
})
|
|
|
drag.Initialize();
|
|
|
});
|
|
|
|
|
|
$(document).on("mouseleave", "#add-content .dragItem", function () {
|
|
|
new common.drag("#add-content").destroy();
|
|
|
});
|
...
|
...
|
|