...
|
...
|
@@ -21,18 +21,6 @@ common.util.__ajax({ |
|
|
var edit = new common.edit2(".modal-body", {
|
|
|
bucket: "yhb-img01"
|
|
|
});
|
|
|
//输入领券码验证
|
|
|
$(document).on("change", "#couponID", function () {
|
|
|
var couponID = $(this).val();
|
|
|
common.util.__ajax({
|
|
|
url: "/coupon/batchCheckCoupons",
|
|
|
async:false,
|
|
|
data: {
|
|
|
params: couponID
|
|
|
}
|
|
|
}, function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
var Bll = {
|
|
|
Brands: [],
|
...
|
...
|
@@ -55,12 +43,13 @@ var Bll = { |
|
|
button: [{
|
|
|
value: "保存",
|
|
|
callback: function () {
|
|
|
var couponFlag = true;
|
|
|
if (Validate[module.contentData.template_name]) {
|
|
|
Validate[module.contentData.template_name].forEach(function (item) {
|
|
|
edit.on("validate", item.fn(module.contentData))
|
|
|
couponFlag = item.fn(module.contentData);
|
|
|
})
|
|
|
}
|
|
|
if (edit.validate()) {
|
|
|
if (edit.validate() && couponFlag) {
|
|
|
//TODO
|
|
|
if (resourceObj[module.contentData.template_name]) {
|
|
|
resourceObj[module.contentData.template_name](module.contentData.data);
|
...
|
...
|
@@ -81,18 +70,18 @@ var Bll = { |
|
|
Bll.__editRender();
|
|
|
},
|
|
|
__editRender: function () {
|
|
|
$('.draggable').each(function() {
|
|
|
if($(this).children().length) {
|
|
|
$(this).sortable().bind('sortupdate', function() {
|
|
|
var fn = new Function("Bll","return Bll.module.contentData." + $(this).data("array"));
|
|
|
$('.draggable').each(function () {
|
|
|
if ($(this).children().length) {
|
|
|
$(this).sortable().bind('sortupdate', function () {
|
|
|
var fn = new Function("Bll", "return Bll.module.contentData." + $(this).data("array"));
|
|
|
var arr = fn(Bll);
|
|
|
var arr2 = [];//拖拽后顺序
|
|
|
var itemsUpdate = $(this).children();
|
|
|
if(itemsUpdate.length == arr.length) {
|
|
|
if (itemsUpdate.length == arr.length) {
|
|
|
for (var i = 0; i < itemsUpdate.length; i++) {
|
|
|
arr2.push($(itemsUpdate[i]).attr("drag-index"));
|
|
|
}
|
|
|
for(var i = 0; i < arr.length; i++) {
|
|
|
for (var i = 0; i < arr.length; i++) {
|
|
|
arr2[i] = arr[arr2[i]];
|
|
|
}
|
|
|
arr = arr2;
|
...
|
...
|
@@ -107,7 +96,7 @@ var Bll = { |
|
|
Bll.module.contentData.data = common.util.__buildobj(names, '.', Bll.module.contentData.data, function (o, name) {
|
|
|
o[name] = obj.data;
|
|
|
});
|
|
|
console.log( Bll.module.contentData.data );
|
|
|
console.log(Bll.module.contentData.data);
|
|
|
});
|
|
|
},
|
|
|
//获取品牌
|
...
|
...
|
@@ -181,7 +170,6 @@ var Bll = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
/*第一步,基础模板*/
|
|
|
Bll.__render("#content-list", "content-template", ViewModel);
|
|
|
Bll.__render(".contents", "template_content_btns", {btns: Button});
|
...
|
...
|
@@ -211,7 +199,6 @@ ViewModel.contentData.forEach(function (item, index) { |
|
|
/*第三部解析楼层*/
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
|
|
|
|
|
|
/*第四部 操作按钮 添加 删除 修改*/
|
|
|
$(document).on("click", ".add_btn", function () {
|
|
|
var item = Button[$(this).data("index")];
|
...
|
...
|
@@ -220,6 +207,23 @@ $(document).on("click", ".add_btn", function () { |
|
|
Bll.toast(-1, Bll.module);
|
|
|
});
|
|
|
|
|
|
/*第五步 绑定监听事件*/
|
|
|
$(document).on("change", ".observe", function () {
|
|
|
var $this = $(this);
|
|
|
var name = $this.data("field");
|
|
|
Bll.module.contentData.data = common.util.__buildobj(name, '.', Bll.module.contentData.data, function (obj, name) {
|
|
|
obj[name] = $this.val();
|
|
|
if (name == "image_style") {
|
|
|
delete obj["default"];
|
|
|
delete obj["T1F2"];
|
|
|
delete obj["L1R2"];
|
|
|
delete obj["imageList"];
|
|
|
obj[obj[name]] = true;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/*删除*/
|
|
|
$(document).on("click", ".del", function () {//删除
|
|
|
var index = $(this).data("index");
|
|
|
common.dialog.confirm("警告",
|
...
|
...
|
@@ -237,6 +241,8 @@ $(document).on("click", ".del", function () {//删除 |
|
|
|
|
|
//$("#index_" + index).remove();
|
|
|
});
|
|
|
|
|
|
/*编辑*/
|
|
|
$(document).on("click", ".edit", function () {
|
|
|
var index = $(this).data("index");
|
|
|
var item = Bll.contentDatas[index];
|
...
|
...
|
@@ -244,34 +250,19 @@ $(document).on("click", ".edit", function () { |
|
|
Bll.toast(index, Bll.module);
|
|
|
});
|
|
|
|
|
|
/*第五步 绑定监听事件*/
|
|
|
$(document).on("change", ".observe", function () {
|
|
|
var $this = $(this);
|
|
|
var name = $this.data("field");
|
|
|
Bll.module.contentData.data = common.util.__buildobj(name, '.', Bll.module.contentData.data, function (obj, name) {
|
|
|
obj[name] = $this.val();
|
|
|
if (name == "image_style") {
|
|
|
delete obj["default"];
|
|
|
delete obj["T1F2"];
|
|
|
delete obj["L1R2"];
|
|
|
delete obj["imageList"];
|
|
|
obj[obj[name]] = true;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
/*根据limit判断最多添加条数, 根据event判断添加的类型, data-event:template_name + "-template"*/
|
|
|
$(document).on("click", ".addBtn", function() {
|
|
|
$(document).on("click", ".addBtn", function () {
|
|
|
var length = $(this).data("limit");
|
|
|
var arr = $(this).data("event").split(".");
|
|
|
if (arr[1] == "data") {
|
|
|
if (Bll.module.contentData.data.length >= length) {
|
|
|
common.util.__tip("最多"+ length +"条!","warning");
|
|
|
common.util.__tip("最多" + length + "条!", "warning");
|
|
|
return;
|
|
|
}
|
|
|
Bll.module.contentData.data.push(addObj[arr.join("_")]);
|
|
|
} else {
|
|
|
if (Bll.module.contentData.data[arr[1]].length >= length) {
|
|
|
common.util.__tip("最多"+ length +"条!","warning");
|
|
|
common.util.__tip("最多" + length + "条!", "warning");
|
|
|
return;
|
|
|
}
|
|
|
Bll.module.contentData.data[arr[1]].push(addObj[arr.join("_")]);
|
...
|
...
|
@@ -283,7 +274,7 @@ $(document).on("click", ".addBtn", function() { |
|
|
$(document).on("click", ".delBtn", function () {
|
|
|
var arr = $(this).data("event").split(".");
|
|
|
var index = $(this).data("index");
|
|
|
if(arr[1] == "data") {
|
|
|
if (arr[1] == "data") {
|
|
|
Bll.module.contentData.data.splice(index, 1);
|
|
|
} else {
|
|
|
Bll.module.contentData.data[arr[1]].splice(index, 1);
|
...
|
...
|
@@ -291,8 +282,19 @@ $(document).on("click", ".delBtn", function () { |
|
|
Bll.renderDialog(arr[0] + "-template");
|
|
|
});
|
|
|
|
|
|
|
|
|
$(document).on("change", ".chkbox", function() {
|
|
|
//输入领券码验证
|
|
|
$(document).on("change", "#couponID", function () {
|
|
|
var couponID = $(this).val();
|
|
|
common.util.__ajax({
|
|
|
url: "/coupon/batchCheckCoupons",
|
|
|
async: false,
|
|
|
data: {
|
|
|
params: couponID
|
|
|
}
|
|
|
}, function () {
|
|
|
});
|
|
|
});
|
|
|
$(document).on("change", ".chkbox", function () {
|
|
|
|
|
|
});
|
|
|
|
...
|
...
|
@@ -362,6 +364,7 @@ $(document).on("click", '.is_show_name_brand', function () { |
|
|
Bll.renderDialog("brands-template");
|
|
|
});
|
|
|
|
|
|
/*保存事件*/
|
|
|
$(document).on("click", "#sub_btn", function () {
|
|
|
var data = {
|
|
|
"content": {},
|
...
|
...
|
@@ -372,7 +375,7 @@ $(document).on("click", "#sub_btn", function () { |
|
|
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";
|
|
|
var goodsSrc = "imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90";
|
|
|
addSuffix(contentData);
|
|
|
delete contentData.button_name;
|
|
|
delete contentData.dialog;
|
...
|
...
|
@@ -390,22 +393,22 @@ $(document).on("click", "#sub_btn", function () { |
|
|
}
|
|
|
//商品
|
|
|
if (contentData.template_name == "goods") {
|
|
|
for(var j=0;j<contentData.data.length;j++){
|
|
|
if(contentData.data[j].src){
|
|
|
var a=contentData.data[j].src.split("?");
|
|
|
a[1]=goodsSrc;
|
|
|
contentData.data[j].src= a.join("?");
|
|
|
for (var j = 0; j < contentData.data.length; j++) {
|
|
|
if (contentData.data[j].src) {
|
|
|
var a = contentData.data[j].src.split("?");
|
|
|
a[1] = goodsSrc;
|
|
|
contentData.data[j].src = a.join("?");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//商品组
|
|
|
if (contentData.template_name == "goodsGroup") {
|
|
|
for(var m=0;m<contentData.data.length;m++){
|
|
|
if(contentData.data[m].list){
|
|
|
for(var n=0;n<contentData.data[m].list.length;n++){
|
|
|
var b=contentData.data[m].list[n].src.split("?");
|
|
|
b[1]=goodsSrc;
|
|
|
contentData.data[m].list[n].src= b.join("?");
|
|
|
for (var m = 0; m < contentData.data.length; m++) {
|
|
|
if (contentData.data[m].list) {
|
|
|
for (var n = 0; n < contentData.data[m].list.length; n++) {
|
|
|
var b = contentData.data[m].list[n].src.split("?");
|
|
|
b[1] = goodsSrc;
|
|
|
contentData.data[m].list[n].src = b.join("?");
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -440,9 +443,7 @@ var addSuffix = function (contentData) { |
|
|
}
|
|
|
}
|
|
|
return contentData;
|
|
|
}
|
|
|
|
|
|
|
|
|
};
|
|
|
/****************************************************************************************************/
|
|
|
/*商品,商品组*/
|
|
|
|
...
|
...
|
@@ -566,7 +567,7 @@ $(document).on("click", ".goodsSelectBtn", function () { |
|
|
//删除图片按钮
|
|
|
$(document).on("click", ".removepic", function () {
|
|
|
Bll.module.contentData.data.splice($(this).data("index"), 1);
|
|
|
console.log("Bll.module.contentData.data",Bll.module.contentData.data);
|
|
|
console.log("Bll.module.contentData.data", Bll.module.contentData.data);
|
|
|
$("#goodspic").html(common.util.__template2($("#template_dialog_goodsimgs").html(), {
|
|
|
datas: Bll.module.contentData.data
|
|
|
}));
|
...
|
...
|
|