...
|
...
|
@@ -6,9 +6,8 @@ require('../common/zh-cn'); |
|
|
|
|
|
var baidu;
|
|
|
|
|
|
|
|
|
/*获取数据ViewModel*/
|
|
|
var ViewModel = {articleGender:"3"};
|
|
|
var ViewModel = {articleGender: "3"};
|
|
|
var param = location.href.slice(location.href.indexOf("contentEdit")).match(/\/\d+/g);
|
|
|
if (param && param.length == 1) {
|
|
|
param[0] = param[0].replace(/\//, '');
|
...
|
...
|
@@ -22,11 +21,16 @@ if (param && param.length == 1) { |
|
|
ViewModel = res.data;
|
|
|
}, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证
|
|
|
* @type {common.components}
|
|
|
*/
|
|
|
var components = new common.components(".modal-body", {
|
|
|
bucket: "goodsimg"
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 通用
|
|
|
*/
|
|
|
var Bll = {
|
|
|
d: null,
|
|
|
moduleimgs: [],
|
...
|
...
|
@@ -36,24 +40,24 @@ var Bll = { |
|
|
getBrands: function () {
|
|
|
var Brand = {};
|
|
|
$.get("/ajax/yohosearch", function (res) {
|
|
|
if(!res.data||!res.data.brands){
|
|
|
if (!res.data || !res.data.brands) {
|
|
|
return;
|
|
|
}
|
|
|
for(var key in res.data.brands){
|
|
|
var name=key;
|
|
|
if (/^[0-9]$/.test(name)) {
|
|
|
name = "0-9";
|
|
|
}
|
|
|
if (name==="") {
|
|
|
name = "#";
|
|
|
}
|
|
|
for(var key2 in res.data.brands[key]){
|
|
|
var item=res.data.brands[key][key2];
|
|
|
Brand[name] = Brand[name] || [];
|
|
|
Brand[name].push(item);
|
|
|
Bll.Brands1[item.id] = item;
|
|
|
}
|
|
|
}
|
|
|
for (var key in res.data.brands) {
|
|
|
var name = key;
|
|
|
if (/^[0-9]$/.test(name)) {
|
|
|
name = "0-9";
|
|
|
}
|
|
|
if (name === "") {
|
|
|
name = "#";
|
|
|
}
|
|
|
for (var key2 in res.data.brands[key]) {
|
|
|
var item = res.data.brands[key][key2];
|
|
|
Brand[name] = Brand[name] || [];
|
|
|
Brand[name].push(item);
|
|
|
Bll.Brands1[item.id] = item;
|
|
|
}
|
|
|
}
|
|
|
for (var i in Brand) {
|
|
|
Brand[i].sort(function (a, b) {
|
|
|
var aName = a.brand_name.toLowerCase(),
|
...
|
...
|
@@ -78,7 +82,6 @@ var Bll = { |
|
|
for (var key in map2) {
|
|
|
Brdata.push(map2[key]);
|
|
|
}
|
|
|
|
|
|
var Brands2 = [];
|
|
|
Brdata.forEach(function (item, index) {
|
|
|
if (!item.brandIco) {
|
...
|
...
|
@@ -100,24 +103,24 @@ var Bll = { |
|
|
contentDatas: [],
|
|
|
module: null,
|
|
|
toast: function (index, module) {
|
|
|
if (!module.contentData.dialog||!module.contentData.template_intro) {
|
|
|
if (!module.contentData.dialog || !module.contentData.template_intro) {
|
|
|
Button.forEach(function (item, index) {
|
|
|
if (module.contentData.template_name == item.template_name) {
|
|
|
module.contentData.dialog = item.dialog;
|
|
|
module.contentData.template_intro=item.template_intro;
|
|
|
module.contentData.template_intro = item.template_intro;
|
|
|
return;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
Bll.d = new common.dialog({
|
|
|
title: (!!~index ? "修改" : "添加") + module.contentData.template_intro.replace("添加",''),
|
|
|
title: (!!~index ? "修改" : "添加") + module.contentData.template_intro.replace("添加", ''),
|
|
|
content: common.util.__template2($("#" + module.contentData.dialog).html(), module),
|
|
|
width: '70%',
|
|
|
button: [{
|
|
|
value: "保存",
|
|
|
callback: function () {
|
|
|
if(module.contentData.dialog=="template_dialog_text"){
|
|
|
module.contentData.data.text=baidu.getContent();
|
|
|
if (module.contentData.dialog == "template_dialog_text") {
|
|
|
module.contentData.data.text = baidu.getContent();
|
|
|
}
|
|
|
if (components.validate()) {
|
|
|
//TODO
|
...
|
...
|
@@ -131,13 +134,11 @@ var Bll = { |
|
|
}]
|
|
|
});
|
|
|
Bll.__editRender();
|
|
|
if(module.contentData.dialog=="template_dialog_text"){
|
|
|
baidu&&baidu.destroy();
|
|
|
baidu=UM.getEditor('baidueditor');
|
|
|
if (module.contentData.dialog == "template_dialog_text") {
|
|
|
baidu && baidu.destroy();
|
|
|
baidu = UM.getEditor('baidueditor');
|
|
|
baidu.setContent(module.contentData.data.text);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
},
|
|
|
renderDialog: function (templater) {
|
|
|
Bll.__render(".modal-body", templater, Bll.module);
|
...
|
...
|
@@ -150,23 +151,6 @@ var Bll = { |
|
|
Bll.module.contentData.data = common.util.__buildobj(names, '.', Bll.module.contentData.data, function (o, name) {
|
|
|
o[name] = obj.data;
|
|
|
});
|
|
|
|
|
|
// var names=obj.field;
|
|
|
// if(obj.datas.length>0){
|
|
|
// for(var i in obj.datas){
|
|
|
// names=names.replace(/^\d+/,i);
|
|
|
// if(i>0){
|
|
|
// Bll.module.contentData.data.push(Bll.module.contentData.data[0]);
|
|
|
// }
|
|
|
// 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",Bll.module.contentData.data);
|
|
|
// Bll.renderDialog(Bll.module.contentData.dialog);
|
|
|
|
|
|
});
|
|
|
},
|
|
|
rendContent: function () {
|
...
|
...
|
@@ -176,8 +160,6 @@ var Bll = { |
|
|
},
|
|
|
__render: function (selecter, templater, data) {
|
|
|
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
|
|
|
|
|
|
|
|
|
},
|
|
|
Tags: []
|
|
|
};
|
...
|
...
|
@@ -193,21 +175,18 @@ Bll.renderBrandPic(Bll.Brdata); |
|
|
/*渲染标签*/
|
|
|
Bll.Tags = ViewModel.tag ? ViewModel.tag.split(',') : [];
|
|
|
Bll.__render("#taglist", "template4", {tags: Bll.Tags});
|
|
|
/*内容渲染->对象转数组*/
|
|
|
// Bll.contentDatas=ENUM.articleContent;
|
|
|
|
|
|
if (ViewModel.articleContent) {
|
|
|
ViewModel.articleContent.forEach(function (item, index) {
|
|
|
item.contentData = item.contentData.replace(/(gif|png|jpg|jpeg)\?[^"]*/g, '$1');
|
|
|
item.contentData = common.util.__ObjToArray(JSON.parse(item.contentData));
|
|
|
console.log(item);
|
|
|
//console.log(item);
|
|
|
Bll.contentDatas.push(item);
|
|
|
});
|
|
|
}
|
|
|
/*第三部解析楼层*/
|
|
|
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
|
|
|
|
|
|
|
|
|
new common.dropDown({
|
|
|
el: "#authorId",
|
|
|
ajax: "guangGetAuthorList"
|
...
|
...
|
@@ -272,7 +251,6 @@ $(document).on("click", ".tag a", function () { |
|
|
});
|
|
|
|
|
|
$(document).on("click", "#addBrands", function () {
|
|
|
///goods/brands/queryBrandsByStatus
|
|
|
var e = new common.edit("#brandForm");
|
|
|
common.dialog.confirm("选择品牌", common.util.__template2($("#template5").html(), {
|
|
|
Brands: Bll.Brands,
|
...
|
...
|
@@ -353,12 +331,7 @@ var Button = [ |
|
|
template_intro: "添加商品",
|
|
|
dialog: "template_dialog_goods",
|
|
|
template_name: "goods",
|
|
|
data: [
|
|
|
// {
|
|
|
// src:"",
|
|
|
// id:""
|
|
|
// }
|
|
|
]
|
|
|
data: []
|
|
|
},
|
|
|
{
|
|
|
template_intro: "推荐商品组",
|
...
|
...
|
@@ -369,13 +342,7 @@ var Button = [ |
|
|
cover: "",
|
|
|
maxSortId: ""
|
|
|
},
|
|
|
list: [
|
|
|
// {
|
|
|
// src:"",
|
|
|
// id:"",
|
|
|
// maxSortId:""
|
|
|
// }
|
|
|
]
|
|
|
list: []
|
|
|
}]
|
|
|
},
|
|
|
{
|
...
|
...
|
@@ -394,7 +361,6 @@ $("#content_btns").html(common.util.__template2($("#template_content_btns").html |
|
|
btns: Button
|
|
|
}));
|
|
|
|
|
|
|
|
|
$(document).on("click", ".add_btn", function () {
|
|
|
var item = Button[$(this).data("index")];
|
|
|
Bll.module = {templateKey: item.template_name};
|
...
|
...
|
@@ -424,181 +390,10 @@ $(document).on("click", ".edit", function () { |
|
|
Bll.toast(index, Bll.module);
|
|
|
});
|
|
|
|
|
|
$(document).on("dblclick","#add-content>li.custom-group",function(){
|
|
|
$(document).on("dblclick", "#add-content>li.custom-group", function () {
|
|
|
$(this).find(".edit").click();
|
|
|
});
|
|
|
|
|
|
/*选择商品表格*/
|
|
|
var goodsgird = new common.grid({
|
|
|
el: '#goodsgird',
|
|
|
parms: function () {
|
|
|
var price = "";
|
|
|
if (common.util.__input('beginPrice')&&common.util.__input('endPrice')) {
|
|
|
price = common.util.__input('beginPrice')+","+common.util.__input('endPrice');
|
|
|
}
|
|
|
return {
|
|
|
status:1,
|
|
|
sales:"Y",
|
|
|
stocknumber:"1",
|
|
|
attribute_not:"2",
|
|
|
query: common.util.__input('skns'),
|
|
|
price: price
|
|
|
};
|
|
|
},
|
|
|
columns: [
|
|
|
{
|
|
|
display: "选择",
|
|
|
type: "checkbox"
|
|
|
}, {
|
|
|
display: "产品图片",
|
|
|
render: function (item) {
|
|
|
console.log("item",item);
|
|
|
if (item.images_url) {
|
|
|
item.images_url = common.util.__joinImg("goodsimg", item.images_url);
|
|
|
}
|
|
|
else {
|
|
|
if(item.default_images){
|
|
|
item.images_url = common.util.__joinImg("goodsimg", item.default_images);
|
|
|
}
|
|
|
else{
|
|
|
item.images_url=""
|
|
|
}
|
|
|
}
|
|
|
if(item.images_url){
|
|
|
return "<img width=120 height=60 src='" + item.images_url + "?imageMogr2/thumbnail/320x320/extent/320x320/background/d2hpdGU=/position/center/quality/90'/>";
|
|
|
}else{
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}, {
|
|
|
display: "产品名称",
|
|
|
name: "product_name"
|
|
|
}, {
|
|
|
display: "品牌",
|
|
|
name: "brand_name"
|
|
|
}, {
|
|
|
display: "现价",
|
|
|
name: "sales_price"
|
|
|
}, {
|
|
|
display: "吊牌价",
|
|
|
name: "market_price"
|
|
|
}, {
|
|
|
display: "预售",
|
|
|
name: "stock_number"
|
|
|
}, {
|
|
|
display: "库存",
|
|
|
name: "storage_num"
|
|
|
}]
|
|
|
});
|
|
|
//搜索按钮
|
|
|
$(document).on("click", "#search", function () {
|
|
|
if($.trim($("#skns").val()).length<5){
|
|
|
common.util.__tip("请输入超过5个字符后再搜索","warning");
|
|
|
return;
|
|
|
}
|
|
|
if(goodsgird.grid){
|
|
|
goodsgird.reload(1);
|
|
|
}else{
|
|
|
goodsgird.init('/yohosearch/search');
|
|
|
}
|
|
|
});
|
|
|
//点击“选择标签”按钮(添加商品)
|
|
|
$(document).on("click", "#goodsSelectBtn", function () {
|
|
|
new common.dialog({
|
|
|
title: "选择商品",
|
|
|
content: $("#template_dialog_goodsgird").html(),
|
|
|
width: '80%',
|
|
|
button: [{
|
|
|
value: "确定",
|
|
|
callback: function () {
|
|
|
var gs=goodsgird.selected.map(function (item, index) {
|
|
|
return {
|
|
|
src: item.images_url,
|
|
|
id: item.product_skn,
|
|
|
product_skc: item.product_skc
|
|
|
}
|
|
|
})
|
|
|
Bll.module.contentData.data=Bll.module.contentData.data.concat(gs);
|
|
|
Bll.module.contentData.data=Unique(Bll.module.contentData.data)
|
|
|
Bll.__render("#goodspic", "template_dialog_goodsimgs", {
|
|
|
datas: Bll.module.contentData.data
|
|
|
});
|
|
|
},
|
|
|
css: "btn-primary"
|
|
|
}]
|
|
|
});
|
|
|
goodsgird.grid=null;
|
|
|
//goodsgird.init('/yohosearch/search');
|
|
|
});
|
|
|
//点击“添加组”按钮(添加商品组)
|
|
|
$(document).on("click", "#goodsaddBtn", function () {
|
|
|
var item = $.extend(true, {}, Button[4].data[0]);
|
|
|
if (Bll.module.contentData.data[0].list.length) {
|
|
|
Bll.module.contentData.data.push(item);
|
|
|
}
|
|
|
Bll.__render("#groupsgoods", "template_dialog_remgoodsgroup", Bll.module);
|
|
|
});
|
|
|
//点击“选择标签”按钮(添加商品组)
|
|
|
$(document).on("click", ".goodsSelectBtn", function () {
|
|
|
var index = $(this).data("index");
|
|
|
new common.dialog({
|
|
|
title: "选择商品",
|
|
|
content: $("#template_dialog_goodsgird").html(),
|
|
|
width: '80%',
|
|
|
button: [{
|
|
|
value: "确定",
|
|
|
callback: function () {
|
|
|
if(goodsgird.selected){
|
|
|
goodsgird.selected.forEach(function (item, i) {
|
|
|
Bll.module.contentData.data[index].list.push({
|
|
|
src: item.images_url,//+'?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90'
|
|
|
id: item.product_skn,
|
|
|
product_skc: item.product_skc,
|
|
|
maxSortId: item.max_sort_id
|
|
|
});
|
|
|
});
|
|
|
Bll.module.contentData.data[index].list=Unique(Bll.module.contentData.data[index].list);
|
|
|
Bll.module.contentData.data[index].cover = {
|
|
|
cover: Bll.module.contentData.data[index].list[0].src,
|
|
|
maxSortId: Bll.module.contentData.data[index].list[0].maxSortId
|
|
|
};
|
|
|
}
|
|
|
Bll.__render("#groupsgoods", "template_dialog_remgoodsgroup", Bll.module);
|
|
|
},
|
|
|
css: "btn-primary"
|
|
|
}]
|
|
|
});
|
|
|
//goodsgird.init('/yohosearch/search');
|
|
|
goodsgird.grid=null;
|
|
|
});
|
|
|
//删除图片按钮
|
|
|
$(document).on("click", ".removepic", function () {
|
|
|
var $parent = $(this).parents("ul.imagegroup");
|
|
|
var i = $parent.data("i");//组标志
|
|
|
var isg = typeof(i) === "number" ? true : false;
|
|
|
//推荐商品组
|
|
|
if (isg) {
|
|
|
Bll.module.contentData.data[i].list.splice($(this).data("index"), 1);
|
|
|
Bll.module.contentData.data[i].cover = {};
|
|
|
if (Bll.module.contentData.data[i].list.length == 0) {
|
|
|
Bll.module.contentData.data[i].cover.cover = "";
|
|
|
Bll.module.contentData.data[i].cover.maxSortId = "";
|
|
|
}
|
|
|
else {
|
|
|
Bll.module.contentData.data[i].cover.cover = Bll.module.contentData.data[i].list[0].src;
|
|
|
Bll.module.contentData.data[i].cover.maxSortId = Bll.module.contentData.data[i].list[0].maxSortId;
|
|
|
}
|
|
|
}
|
|
|
//商品
|
|
|
else {
|
|
|
Bll.module.contentData.data.splice($(this).data("index"), 1);
|
|
|
}
|
|
|
$parent.html(common.util.__template2($("#template_dialog_goodsimgs").html(), {
|
|
|
datas: isg ? Bll.module.contentData.data[i].list : Bll.module.contentData.data
|
|
|
}));
|
|
|
});
|
|
|
|
|
|
|
|
|
/********************************/
|
|
|
var e = new common.edit("#panel-body", {
|
...
|
...
|
@@ -610,7 +405,7 @@ e.on("validate", function () { |
|
|
return "链接和内容不能同时为空";
|
|
|
}
|
|
|
});
|
|
|
var imgsTem="?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90";
|
|
|
var imgsTem = "?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90";
|
|
|
$(document).on("click", "#submit", function () {
|
|
|
e.submit($("#panel-body").attr("action"), function (option) {
|
|
|
if (param && param.length == 1) {
|
...
|
...
|
@@ -618,15 +413,15 @@ $(document).on("click", "#submit", function () { |
|
|
}
|
|
|
option.data.minSortId = option.data.minSortId == "-1" ? "" : option.data.minSortId;
|
|
|
|
|
|
option.data.contentData =Bll.contentDatas.concat();
|
|
|
option.data.contentData=option.data.contentData.map(function (item, index) {
|
|
|
var item=$.extend(true,{},item);
|
|
|
option.data.contentData = Bll.contentDatas.concat();
|
|
|
option.data.contentData = option.data.contentData.map(function (item, index) {
|
|
|
var item = $.extend(true, {}, item);
|
|
|
if ({}.toString.call(item.contentData.data) == "[object Array]") {
|
|
|
item.contentData.data.map(function (item1) {
|
|
|
if (item1.src) {
|
|
|
if(item.contentData.template_name==="goods"){
|
|
|
if (item.contentData.template_name === "goods") {
|
|
|
item1.src = item1.src + imgsTem;
|
|
|
}else{
|
|
|
} else {
|
|
|
item1.src = item1.src + "?imageView/{mode}/w/{width}/h/{height}";
|
|
|
}
|
|
|
|
...
|
...
|
@@ -634,9 +429,9 @@ $(document).on("click", "#submit", function () { |
|
|
if (item1.cover) {
|
|
|
item1.cover.cover = item1.cover.cover + imgsTem;
|
|
|
}
|
|
|
if (item1.list&&{}.toString.call(item1.list) == "[object Array]"){
|
|
|
item1.list.map(function(item2){
|
|
|
item2.src=item2.src+imgsTem;
|
|
|
if (item1.list && {}.toString.call(item1.list) == "[object Array]") {
|
|
|
item1.list.map(function (item2) {
|
|
|
item2.src = item2.src + imgsTem;
|
|
|
return item2;
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -657,14 +452,14 @@ $(document).on("click", "#submit", function () { |
|
|
res = res.data;
|
|
|
if (res.code == "200") {
|
|
|
e.$tip("提交成功", function () {
|
|
|
location.href="/guang/article/index";
|
|
|
location.href = "/guang/article/index";
|
|
|
}, 'growl-success');
|
|
|
} else {
|
|
|
e.$tip(res.message);
|
|
|
}
|
|
|
},
|
|
|
option.error = function (res) {
|
|
|
e.$tip(res.message||"接口异常报错");
|
|
|
e.$tip(res.message || "接口异常报错");
|
|
|
}
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -692,19 +487,19 @@ $(document).on("change", "#maxSortId", function () { |
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
function Unique(Array) {
|
|
|
var res = [], hash = {};
|
|
|
for(var i=0, elem; (elem = Array[i]) != null; i++) {
|
|
|
if (!hash[elem.id])
|
|
|
{
|
|
|
for (var i = 0, elem; (elem = Array[i]) != null; i++) {
|
|
|
if (!hash[elem.id]) {
|
|
|
res.push(elem);
|
|
|
hash[elem.id] = true;
|
|
|
}
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 自动获取品牌
|
|
|
*/
|
|
|
$(document).on("click", "#brandAutoBtn", function () {
|
|
|
var product_skc = [];
|
|
|
Bll.contentDatas.forEach(function (item, index) {
|
...
|
...
|
@@ -749,17 +544,8 @@ $(document).on("click", "#brandAutoBtn", function () { |
|
|
b.push(map[item]);
|
|
|
}
|
|
|
});
|
|
|
Bll.Brdata = (Bll.Brdata||ViewModel.brandList || []).concat(b);
|
|
|
Bll.Brdata=Unique(Bll.Brdata);
|
|
|
// Bll.Brdata=Bll.Brdata.unique5()
|
|
|
// var map2={};
|
|
|
// Bll.Brdata.forEach(function(item){
|
|
|
// map2[item.id]=item;
|
|
|
// });
|
|
|
// Bll.Brdata=[];
|
|
|
// for(var key in map2){
|
|
|
// Bll.Brdata.push(map2[key]);
|
|
|
// }
|
|
|
Bll.Brdata = (Bll.Brdata || ViewModel.brandList || []).concat(b);
|
|
|
Bll.Brdata = Unique(Bll.Brdata);
|
|
|
Bll.Brdata = Bll.renderBrandPic(Bll.Brdata);
|
|
|
}
|
|
|
}, true);
|
...
|
...
|
@@ -865,4 +651,348 @@ $(document).on("mouseover", ".dragItem", function () { |
|
|
$(document).on("mouseleave", ".dragItem", function () {
|
|
|
new common.drag("#add-content").destroy();
|
|
|
});
|
|
|
/************************************商品相关****************************************************/
|
|
|
/**
|
|
|
* 选择商品表格
|
|
|
*/
|
|
|
var goodsgird = new common.grid({
|
|
|
el: '#goodsgird',
|
|
|
parms: function () {
|
|
|
var price = "";
|
|
|
if (common.util.__input('min-price') && common.util.__input('max-price')) {
|
|
|
price = common.util.__input('min-price') + "," + common.util.__input('max-price');
|
|
|
}
|
|
|
return {
|
|
|
status: 1,
|
|
|
sales: "Y",
|
|
|
stocknumber: "1",
|
|
|
attribute_not: "2",
|
|
|
query: common.util.__input('skns') || common.util.__input('skns2'),
|
|
|
price: price,
|
|
|
color: colorArray.join(','),
|
|
|
//style: styleArray.join(','),//风格先不管
|
|
|
msort: typeArray.join(','),
|
|
|
brand: brandArray.join(','),
|
|
|
gender: genderArray.join(',')
|
|
|
};
|
|
|
},
|
|
|
columns: [
|
|
|
{
|
|
|
display: "选择",
|
|
|
type: "checkbox"
|
|
|
}, {
|
|
|
display: "产品图片",
|
|
|
render: function (item) {
|
|
|
if (item.images_url) {
|
|
|
item.images_url = common.util.__joinImg("goodsimg", item.images_url);
|
|
|
}
|
|
|
else {
|
|
|
if (item.default_images) {
|
|
|
item.images_url = common.util.__joinImg("goodsimg", item.default_images);
|
|
|
}
|
|
|
else {
|
|
|
item.images_url = ""
|
|
|
}
|
|
|
}
|
|
|
if (item.images_url) {
|
|
|
return "<img width=120 height=60 src='" + item.images_url + "?imageMogr2/thumbnail/320x320/extent/320x320/background/d2hpdGU=/position/center/quality/90'/>";
|
|
|
} else {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}, {
|
|
|
display: "产品名称",
|
|
|
name: "product_name"
|
|
|
}, {
|
|
|
display: "品牌",
|
|
|
name: "brand_name"
|
|
|
}, {
|
|
|
display: "现价",
|
|
|
name: "sales_price"
|
|
|
}, {
|
|
|
display: "吊牌价",
|
|
|
name: "market_price"
|
|
|
}, {
|
|
|
display: "预售",
|
|
|
name: "stock_number"
|
|
|
}, {
|
|
|
display: "库存",
|
|
|
name: "storage_num"
|
|
|
}]
|
|
|
});
|
|
|
/**
|
|
|
* 手动输入
|
|
|
*/
|
|
|
$(document).on("click", ".hand", function () {
|
|
|
$(this).css("color", 'red');
|
|
|
$("#skns").val("");
|
|
|
$(".tag").css("color", 'black');
|
|
|
$(".search-con1").show();
|
|
|
$(".search-con2").hide();
|
|
|
$(".tag-con").hide();
|
|
|
$(".goods-list").hide();
|
|
|
});
|
|
|
/**
|
|
|
* 手动输入中“搜索商品”按钮
|
|
|
*/
|
|
|
|
|
|
$(document).on("click", "#search", function () {
|
|
|
if ($.trim($("#skns").val()).length < 5) {
|
|
|
common.util.__tip("请输入超过5个字符后再搜索", "warning");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
$(".goods-list").show();
|
|
|
if (goodsgird.grid) {
|
|
|
goodsgird.reload(1);
|
|
|
} else {
|
|
|
goodsgird.init('/yohosearch/search');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
});
|
|
|
/**
|
|
|
* 标签搜索
|
|
|
*/
|
|
|
$(document).on("click", ".tag", function () {
|
|
|
|
|
|
$(this).css("color", 'red');
|
|
|
$(".hand").css("color", 'black');
|
|
|
$(".search-con1").hide();
|
|
|
$(".search-con2").show();
|
|
|
$(".tag-con").hide();
|
|
|
$(".goods-list").hide();
|
|
|
});
|
|
|
/**
|
|
|
* 标签搜索中 “搜索商品”按钮
|
|
|
*/
|
|
|
$(document).on("click", "#search2", function () {
|
|
|
$(".goods-list").show();
|
|
|
goodsgird.init('/yohosearch/search');
|
|
|
});
|
|
|
/**
|
|
|
* 标签搜索中“搜索标签”按钮
|
|
|
* @type {Array}
|
|
|
*/
|
|
|
var sorts = [];//所选分类
|
|
|
var colors = [], colorArray = [];//颜色
|
|
|
var styles = [{stylename: "街头"}, {stylename: "趣味"}, {stylename: "运动"}], styleArray = [];//风格
|
|
|
var types = [], typeArray = [];//品类
|
|
|
var brands = [], brandArray = [];//品牌
|
|
|
var genders = [{id: 1, gendername: "男"}, {id: 2, gendername: "女"}, {id: 3, gendername: "通用"}], genderArray = [];//性别
|
|
|
common.util.__ajax({
|
|
|
url: "/erpproduct/product/colorList"
|
|
|
}, function (res) {
|
|
|
colors = res.data.list;
|
|
|
}, true);
|
|
|
common.util.__ajax({
|
|
|
url: "/product/class/queryAllProductSortList",
|
|
|
data: {
|
|
|
booleanStatus: true
|
|
|
}
|
|
|
}, function (res) {
|
|
|
types = res.data;
|
|
|
}, true);
|
|
|
|
|
|
$(document).on("click", "#search-tag", function () {
|
|
|
$(".tag-con").show();
|
|
|
$(".sort").html(common.util.__template2($("#tag-template").html(), {
|
|
|
sorts: sorts
|
|
|
}));
|
|
|
$(".orther").html(common.util.__template2($("#sorts-template").html(), {
|
|
|
colors: colors,
|
|
|
styles: styles,
|
|
|
types: types,
|
|
|
brands: Bll.Brands,
|
|
|
genders: genders
|
|
|
}));
|
|
|
if($("#skns2").val()!=''){
|
|
|
$(".goods-list").show();
|
|
|
if (goodsgird.grid) {
|
|
|
goodsgird.reload(1);
|
|
|
} else {
|
|
|
goodsgird.init('/yohosearch/search');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
});
|
|
|
/**
|
|
|
* 价格筛选
|
|
|
*/
|
|
|
$(document).on("click", "#price-search", function () {
|
|
|
if (goodsgird.grid) {
|
|
|
goodsgird.reload(1);
|
|
|
} else {
|
|
|
goodsgird.init('/yohosearch/search');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
//点击“选择标签”按钮(添加商品)
|
|
|
$(document).on("click", "#goodsSelectBtn", function () {
|
|
|
new common.dialog({
|
|
|
title: "选择商品",
|
|
|
content: $("#template_dialog_goodsgird").html(),
|
|
|
width: '80%',
|
|
|
button: [{
|
|
|
value: "确定",
|
|
|
callback: function () {
|
|
|
var gs = goodsgird.selected.map(function (item, index) {
|
|
|
return {
|
|
|
src: item.images_url,
|
|
|
id: item.product_skn,
|
|
|
product_skc: item.product_skc
|
|
|
}
|
|
|
})
|
|
|
Bll.module.contentData.data = Bll.module.contentData.data.concat(gs);
|
|
|
Bll.module.contentData.data = Unique(Bll.module.contentData.data)
|
|
|
Bll.__render("#goodspic", "template_dialog_goodsimgs", {
|
|
|
datas: Bll.module.contentData.data
|
|
|
});
|
|
|
},
|
|
|
css: "btn-primary"
|
|
|
}]
|
|
|
});
|
|
|
goodsgird.grid = null;
|
|
|
//goodsgird.init('/yohosearch/search');
|
|
|
});
|
|
|
//点击“添加组”按钮(添加商品组)
|
|
|
$(document).on("click", "#goodsaddBtn", function () {
|
|
|
var item = $.extend(true, {}, Button[4].data[0]);
|
|
|
if (Bll.module.contentData.data[0].list.length) {
|
|
|
Bll.module.contentData.data.push(item);
|
|
|
}
|
|
|
Bll.__render("#groupsgoods", "template_dialog_remgoodsgroup", Bll.module);
|
|
|
});
|
|
|
//点击“选择标签”按钮(添加商品组)
|
|
|
$(document).on("click", ".goodsSelectBtn", function () {
|
|
|
var index = $(this).data("index");
|
|
|
new common.dialog({
|
|
|
title: "选择商品",
|
|
|
content: $("#template_dialog_goodsgird").html(),
|
|
|
width: '80%',
|
|
|
button: [{
|
|
|
value: "确定",
|
|
|
callback: function () {
|
|
|
if (goodsgird.selected) {
|
|
|
goodsgird.selected.forEach(function (item, i) {
|
|
|
Bll.module.contentData.data[index].list.push({
|
|
|
src: item.images_url,//+'?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90'
|
|
|
id: item.product_skn,
|
|
|
product_skc: item.product_skc,
|
|
|
maxSortId: item.max_sort_id
|
|
|
});
|
|
|
});
|
|
|
Bll.module.contentData.data[index].list = Unique(Bll.module.contentData.data[index].list);
|
|
|
Bll.module.contentData.data[index].cover = {
|
|
|
cover: Bll.module.contentData.data[index].list[0].src,
|
|
|
maxSortId: Bll.module.contentData.data[index].list[0].maxSortId
|
|
|
};
|
|
|
}
|
|
|
Bll.__render("#groupsgoods", "template_dialog_remgoodsgroup", Bll.module);
|
|
|
},
|
|
|
css: "btn-primary"
|
|
|
}]
|
|
|
});
|
|
|
//goodsgird.init('/yohosearch/search');
|
|
|
goodsgird.grid = null;
|
|
|
});
|
|
|
//删除图片按钮
|
|
|
$(document).on("click", ".removepic", function () {
|
|
|
var $parent = $(this).parents("ul.imagegroup");
|
|
|
var i = $parent.data("i");//组标志
|
|
|
var isg = typeof(i) === "number" ? true : false;
|
|
|
//推荐商品组
|
|
|
if (isg) {
|
|
|
Bll.module.contentData.data[i].list.splice($(this).data("index"), 1);
|
|
|
Bll.module.contentData.data[i].cover = {};
|
|
|
if (Bll.module.contentData.data[i].list.length == 0) {
|
|
|
Bll.module.contentData.data[i].cover.cover = "";
|
|
|
Bll.module.contentData.data[i].cover.maxSortId = "";
|
|
|
}
|
|
|
else {
|
|
|
Bll.module.contentData.data[i].cover.cover = Bll.module.contentData.data[i].list[0].src;
|
|
|
Bll.module.contentData.data[i].cover.maxSortId = Bll.module.contentData.data[i].list[0].maxSortId;
|
|
|
}
|
|
|
}
|
|
|
//商品
|
|
|
else {
|
|
|
Bll.module.contentData.data.splice($(this).data("index"), 1);
|
|
|
}
|
|
|
$parent.html(common.util.__template2($("#template_dialog_goodsimgs").html(), {
|
|
|
datas: isg ? Bll.module.contentData.data[i].list : Bll.module.contentData.data
|
|
|
}));
|
|
|
});
|
|
|
//勾选标签
|
|
|
var checkSort = function (name, array) {
|
|
|
$(document).on("click", "input[name='" + name + "']", function () {
|
|
|
if ($(this).is(':checked')) {
|
|
|
array.push($(this).val());
|
|
|
}
|
|
|
else {
|
|
|
var i = array.indexOf($(this).val());
|
|
|
if (i > -1) {
|
|
|
array.splice(i, 1);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
checkSort("color", colorArray);
|
|
|
checkSort("style", styleArray);
|
|
|
checkSort("type", typeArray);
|
|
|
checkSort("brand", brandArray);
|
|
|
checkSort("gender", genderArray);
|
|
|
Array.prototype.indexOf = function (val) {
|
|
|
for (var i = 0; i < this.length; i++) {
|
|
|
if (this[i] == val) return i;
|
|
|
}
|
|
|
return -1;
|
|
|
};
|
|
|
//$(document).on("click", "#search-tag", function () {
|
|
|
// $(".tag-con").show();
|
|
|
// var txt = $("#tags").val();
|
|
|
// var regex = new RegExp(txt);
|
|
|
// var bs = [];
|
|
|
// var colors1=[],types1=[],genders1=[];
|
|
|
// colors.forEach(function(color){
|
|
|
// if (regex.test(color.colorName)) {
|
|
|
// colors1.push(color);
|
|
|
// }
|
|
|
// });
|
|
|
// types.forEach(function(type){
|
|
|
// if (regex.test(type.sortName)) {
|
|
|
// types1.push(type);
|
|
|
// }
|
|
|
// });
|
|
|
// genders.forEach(function(gender){
|
|
|
// if (regex.test(gender.gendername)) {
|
|
|
// genders1.push(gender);
|
|
|
// }
|
|
|
// });
|
|
|
// //Bll.Brands.forEach(function (brands) {
|
|
|
// // brands.items.forEach(function (item) {
|
|
|
// // if (regex.test(item.brand_name)) {
|
|
|
// // console.log(item.brand_name);
|
|
|
// // bs.push(' <input type="checkbox" name="brand" value="'+item.id+'">'+item.brand_name+'');
|
|
|
// // }
|
|
|
// // });
|
|
|
// //});
|
|
|
// $(".orther").html(common.util.__template2($("#sorts-template").html(), {
|
|
|
// colors: colors1,
|
|
|
// //styles: styles1,
|
|
|
// types: types1,
|
|
|
// //brands: Bll.Brands,
|
|
|
// genders: genders1
|
|
|
// }));
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|