bannerEdit.js
3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
require('../../../common/umeditor.config');
require('../../../common/umeditor');
require('../../../common/zh-cn');
var edit = require('../../../common/edit');
var UMdescriptioner = UM.getEditor('banner');
UMdescriptioner.setContent($("#searchBanner").val());
var mainData = window.ViewModel;
console.log(mainData);
var e = new edit("#basicForm", {bucket: "goodsimg"});
e.on("validate", function () {
if ($.trim($('#caption').val()) === ''){
return "名称不能为空";
}
if ($.trim(UMdescriptioner.getContent()) === ''){
return "内容不能为空";
}
return true;
});
e.init();
$(document).on('click','#save_banner',function () {
e.submit($("#basicForm").attr("action"), function (option) {
option.data.data = UMdescriptioner.getContent();
option.success = function (res) {
if (res.code == "200") {
e.$tip("提交成功", function () {
location.href = "/search/bannerIndex"
}, 'growl-success');
} else {
e.$tip(res.message);
}
return false;
};
option.error = function (res) {
e.$tip(res.message);
};
console.log(option.data);
});
return false;
});
// 初始化品类
/*品类初始化*/
var SORTDATA={
url:"/goods/query/querySortBySmallSort",
datas:[
{id:mainData.maxSortId, sortName:mainData.maxSortName},
{id:mainData.middleSortId, sortName:mainData.middleSortName},
{id:mainData.smallSortId, sortName:mainData.smallSortName},
{id:mainData.sortId, sortName:mainData.sortName}
],
otherParam:function(){
return {}
},
complete:function(data, bool){
if(!bool){
/*if(data.length>2){
Bll.productNameArr[2]=data[data.length-1].sortName;
Bll.setProductName();
}
if(data[0]&&data[0].text&&data[0].text.indexOf("潮童")>-1){
$("#ageLevel").val("2|3|4|5");
}else{
$("#ageLevel").val("1");
}
$(":checkbox[name=ageLevel]").prop("checked",false);
$(":checkbox[name=ageLevel]").each(function(){
var name=$("#ageLevel").val();
if(name.indexOf($(this).val())>-1){
$(this).prop("checked",true)
}
});*/
}
},
};
var tabTree=new common.tabTree("#sortTree",SORTDATA);
tabTree.isfeeze=true;
tabTree.init(SORTDATA.datas);
new common.dropDown({el:"#postionId", ajax:"searchPostion", params:function(){
return {postionId:$("#postionId").val()};
}});
new common.dropDown({el:"#templetId",ajax:"searchTemplet",params:function(){
return {templetId:$("#templetId").val()};
}});
new common.dropDown({el:"#sizeId",ajax:"sortsize",params:function(){
return {sizeId:$("#sizeId").val()};
}});
// 初始化风格的多选框
common.util.__ajax({
url: '/operations/search/queryAllStyle',
data: {
//categoryId: basicInfo.smallSortId
}
},function(res){
var data = res;
data.selectStyle = mainData.style;
$('#styleDiv').html(common.util.__template2($('#templateStyle').html(), data));
},true);
// 初始化颜色单选选项列表
common.util.__ajax({
url: '/basegoods/queryProductColors',
data: {
}
},function(res){
var colorList = res.data;
colorList.selectColor = mainData.color;
$('#colorDiv').html(common.util.__template2($('#templateColor').html(), colorList));
},true);