...
|
...
|
@@ -369,13 +369,13 @@ var Bll = { |
|
|
initRecommendProduct: function(selector) {
|
|
|
|
|
|
// 手动选择商品
|
|
|
if(Bll.recommendProductDisplayType === 1) {
|
|
|
if(Bll.recommendProduct.displayType === 1) {
|
|
|
$('.editor-dialog').show();
|
|
|
|
|
|
$('.editorTitle').html(common.util.__template2($("#recommend-product-filter").html()));
|
|
|
var tabTree = new common.tabTree("#sortTree");
|
|
|
tabTree.init();
|
|
|
$('.selectedProductsNum').text(Bll.recommendProductList.length);
|
|
|
$('.selectedProductsNum').text(Bll.recommendProduct.sknList.length);
|
|
|
// 设置dialog边框
|
|
|
$('.editor-dialog').css({padding: "20px 20px 60px", border: "1px solid #ddd", background: "#FFFFFF"});
|
|
|
Bll.moduleGrid = new grid({
|
...
|
...
|
@@ -393,9 +393,9 @@ var Bll = { |
|
|
size: 12
|
|
|
};
|
|
|
if(Bll.recommendProductTab === 1) {
|
|
|
// 注意:如果recommendProductList为空数组,不能直接传递Bll.recommendProductList.toString(),因为接口框架会忽略空字符。
|
|
|
// 注意:如果Bll.recommendProduct.sknList为空数组,不能直接传递Bll.recommendProduct.sknList.toString(),因为接口框架会忽略空字符。
|
|
|
// 这时,在传递至后台接口时,映射的参数会是null,而非空字符串
|
|
|
params.productSKNList = Bll.recommendProductList.length === 0 ? " " : Bll.recommendProductList.toString();
|
|
|
params.productSKNList = Bll.recommendProduct.sknList.length === 0 ? " " : Bll.recommendProduct.sknList.toString();
|
|
|
}
|
|
|
|
|
|
return params;
|
...
|
...
|
@@ -443,7 +443,7 @@ var Bll = { |
|
|
display: '操作',
|
|
|
render: function(item) {
|
|
|
// 当前SKN在选中列表中
|
|
|
if($.inArray(item.productSKN, Bll.recommendProductList) > -1) {
|
|
|
if($.inArray(item.productSKN, Bll.recommendProduct.sknList) > -1) {
|
|
|
return '<a href="javascript:;" data-product-skn="' + item.productSKN + '" class="btn btn-xs unselect-product">取消选择</a>';
|
|
|
}
|
|
|
return '<a href="javascript:;" data-product-skn="' + item.productSKN + '" class="btn btn-xs select-product">选择</a>';
|
...
|
...
|
@@ -454,7 +454,9 @@ var Bll = { |
|
|
Bll.moduleGrid.init("/shop/selectAllProduct");
|
|
|
} else {
|
|
|
$('.editor-dialog').hide();
|
|
|
$('.editorTitle').html(common.util.__template2($('#autoselect-recommend-product').html()));
|
|
|
$('.editorTitle').html(common.util.__template2($('#autoselect-recommend-product').html(), {data: Bll.recommendProduct}));
|
|
|
let edit = new common.edit('.editorTitle');
|
|
|
edit.init();
|
|
|
}
|
|
|
},
|
|
|
|
...
|
...
|
@@ -895,9 +897,8 @@ var Bll = { |
|
|
break;
|
|
|
case "RecommendProduct":
|
|
|
// 渲染 "展示类型" 选择组件
|
|
|
Bll.recommendProductDisplayType = Bll.getRecommendProductDisplayType(module);
|
|
|
Bll.recommendProductList = Bll.getModuleData(module); // 临时保存选中的SKN
|
|
|
$('.editor-header').html(common.util.__template2($('#recommend-product-display-type').html(), {displayType: Bll.recommendProductDisplayType}));
|
|
|
Bll.recommendProduct = Bll.getRecommendProductData(module); // 临时保存装修数据
|
|
|
$('.editor-header').html(common.util.__template2($('#recommend-product-display-type').html(), {displayType: Bll.recommendProduct.displayType}));
|
|
|
Bll.initRecommendProduct(selector);
|
|
|
break;
|
|
|
};
|
...
|
...
|
@@ -932,13 +933,52 @@ var Bll = { |
|
|
return 1;
|
|
|
},
|
|
|
|
|
|
getRecommendProductDisplayType: function(module) {
|
|
|
if(module.moduleData && module.moduleData.properties) {
|
|
|
let isModuleMargin = module.moduleData.properties.isModuleMargin;
|
|
|
return +isModuleMargin;
|
|
|
/**
|
|
|
* 获取 推荐商品 模块数据,数据格式为: {data: [{sknList: [], lineNumber: 2, sortType: 1, sortPattern: 2}], properties: {displayType: 0}}
|
|
|
*/
|
|
|
getRecommendProductData: function(module) {
|
|
|
let recommendProduct = {};
|
|
|
if(module.moduleData) {
|
|
|
if(module.moduleData.data) {
|
|
|
recommendProduct = module.moduleData.data[0];
|
|
|
}
|
|
|
|
|
|
if(module.moduleData.properties) {
|
|
|
recommendProduct.displayType = module.moduleData.properties.displayType;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(recommendProduct.sknList === undefined) {
|
|
|
recommendProduct.sknList = [];
|
|
|
}
|
|
|
|
|
|
if(recommendProduct.displayType === undefined) {
|
|
|
recommendProduct.displayType = 0;
|
|
|
}
|
|
|
|
|
|
return recommendProduct;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 保存 推荐商品 模块数据,装修数据临时保存在 Bll.recommendProduct中
|
|
|
* @param index 当前模块在装修模块列表中的索引
|
|
|
*/
|
|
|
saveRecommendProduct: function(index) {
|
|
|
let displayType = Bll.recommendProduct.displayType;
|
|
|
let data = {};
|
|
|
|
|
|
// 自动选品
|
|
|
if(displayType === 0) {
|
|
|
data.lineNumber = Bll.recommendProduct.lineNumber;
|
|
|
data.sortType = Bll.recommendProduct.sortType;
|
|
|
data.sortPattern = Bll.recommendProduct.sortPattern;
|
|
|
} else {
|
|
|
data.sknList = Bll.recommendProduct.sknList;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
Bll.moduleDataList[index].moduleData.data = [];
|
|
|
Bll.moduleDataList[index].moduleData.data.push(data);
|
|
|
Bll.moduleDataList[index].moduleData.properties.displayType = displayType;
|
|
|
},
|
|
|
|
|
|
// 初始化编辑弹出框底部Tips,selector: 选择器标识,index:模块索引
|
...
|
...
|
@@ -976,7 +1016,14 @@ var Bll = { |
|
|
value: '确认',
|
|
|
css: 'btn-info',
|
|
|
callback: function() {
|
|
|
var validation = Bll.validator.validateModule(Bll.moduleDataList[index].moduleType, Bll.moduleGrid.__rows);
|
|
|
let validation = false;
|
|
|
let moduleType = Bll.moduleDataList[index].moduleType;
|
|
|
if(moduleType == 'RecommendProduct') {
|
|
|
validation = Bll.validator.validateModule(moduleType, Bll.recommendProduct);
|
|
|
} else {
|
|
|
validation = Bll.validator.validateModule(moduleType, Bll.moduleGrid.__rows);
|
|
|
}
|
|
|
|
|
|
if(! validation) {
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -992,7 +1039,11 @@ var Bll = { |
|
|
Bll.moduleDataList[index].moduleData.properties = {};
|
|
|
}
|
|
|
|
|
|
Bll.moduleDataList[index].moduleData.data = Bll.moduleGrid.__rows;
|
|
|
if(moduleType == 'RecommendProduct') {
|
|
|
Bll.saveRecommendProduct(index);
|
|
|
} else {
|
|
|
Bll.moduleDataList[index].moduleData.data = Bll.moduleGrid.__rows;
|
|
|
}
|
|
|
|
|
|
// 处理模块数据,增加资源位标识,用于热点分析
|
|
|
$.each(Bll.moduleDataList[index].moduleData.data, function(index, item) {
|
...
|
...
|
@@ -1896,7 +1947,7 @@ $(document).on('click', '.display-type-radio', function() { |
|
|
|
|
|
$(document).on('change', '.recommend-product-radio', function() {
|
|
|
let displayType = $(this).val();
|
|
|
Bll.recommendProductDisplayType = +displayType;
|
|
|
Bll.recommendProduct.displayType = +displayType;
|
|
|
|
|
|
Bll.initRecommendProduct('.editor-dialog');
|
|
|
});
|
...
|
...
|
@@ -2002,8 +2053,8 @@ $(document).on('click', '.select-product', function() { |
|
|
let skn = +$(this).data('product-skn');
|
|
|
|
|
|
// 临时维护
|
|
|
if($.inArray(skn, Bll.recommendProductList) == -1) {
|
|
|
Bll.recommendProductList.push(skn);
|
|
|
if($.inArray(skn, Bll.recommendProduct.sknList) == -1) {
|
|
|
Bll.recommendProduct.sknList.push(skn);
|
|
|
}
|
|
|
|
|
|
// 将 "选择" 改为 "取消选择"
|
...
|
...
|
@@ -2012,30 +2063,30 @@ $(document).on('click', '.select-product', function() { |
|
|
$(this).addClass('unselect-product');
|
|
|
|
|
|
// 重置TAB页数字
|
|
|
$('.selectedProductsNum').text(Bll.recommendProductList.length);
|
|
|
$('.selectedProductsNum').text(Bll.recommendProduct.sknList.length);
|
|
|
});
|
|
|
|
|
|
// 取消选择SKN
|
|
|
$(document).on('click', '.unselect-product', function() {
|
|
|
let skn = +$(this).data('product-skn');
|
|
|
// 将SKN从临时数据中移除
|
|
|
Bll.recommendProductList.splice($.inArray(skn, Bll.recommendProductList), 1);
|
|
|
Bll.recommendProduct.sknList.splice($.inArray(skn, Bll.recommendProduct.sknList), 1);
|
|
|
|
|
|
$(this).text("选择");
|
|
|
$(this).removeClass('unselect-product');
|
|
|
$(this).addClass('select-product');
|
|
|
|
|
|
// 重置TAB页数字
|
|
|
$('.selectedProductsNum').text(Bll.recommendProductList.length);
|
|
|
$('.selectedProductsNum').text(Bll.recommendProduct.sknList.length);
|
|
|
});
|
|
|
|
|
|
// 全部取消选择SKN
|
|
|
$(document).on('click', '.clear-btn', function() {
|
|
|
// 清空临时保存数据
|
|
|
Bll.recommendProductList = [];
|
|
|
Bll.recommendProduct.sknList = [];
|
|
|
|
|
|
// 重置TAB页数字
|
|
|
$('.selectedProductsNum').text(Bll.recommendProductList.length);
|
|
|
$('.selectedProductsNum').text(Bll.recommendProduct.sknList.length);
|
|
|
|
|
|
// 重新加载页面,更改"选择"按钮
|
|
|
Bll.moduleGrid.reload(1);
|
...
|
...
|
|