netsale-ty.js
4.98 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
var $ = require('jquery'),
common = require('../../common/common');
if(window.NETSALEDATA) {
{//商品参数
var baseProduct = window.NETSALEDATA.baseProductInfo.baseProduct;
var specialAttrBo = {productSkn:baseProduct.productSkn,washTipsList:[],materialList:[]};
if(window.NETSALEDATA.specialAttrBo) {
specialAttrBo = window.NETSALEDATA.specialAttrBo;
}
var washTipsList = specialAttrBo.washTipsList || [];
var materialList = specialAttrBo.materialList || [];
var e=new common.edit("#taoyu1");
//材质初始化
common.util.__ajax({
url:'/netSale/queryAllBySortId4Select',
data:{param:baseProduct.maxSortId}
},function(res) {
$("#material-group").html(common.util.__template2($("#material-params").html(),res||{}));
var materials = [];
for (var i = 0; i < materialList.length; i++) {
materials[i] = materialList[i].id;
}
$("#material").val(materials.join("|"));
e.init();
});
//洗涤提示初始化
common.util.__ajax({
url:'/netSale/getAll4Select',
data:{}
},function(res) {
$("#washTip-group").html(common.util.__template2($("#washTip-params").html(),res||{}));
var washTips = [];
for (var i = 0; i < washTipsList.length; i++) {
washTips[i] = washTipsList[i].sortId;
}
$("#washTips").val(washTips.join("|"));
e.init();
});
$(document).on('change','.material', function() {
var items = $("#material").val().split("|");
for (var i = 0; i < items.length; i++) {
materialList[i] = {"id":parseInt(items[i])};
}
});
$(document).on('change','.washTips', function() {
var items = $("#washTips").val().split("|");
for (var i = 0; i < items.length; i++) {
washTipsList[i] = {"sortId":parseInt(items[i])};
}
});
$(document).on('click', "#propertySave", function() {
var washTips = $("#washTips").val() || "";
var productMaterial = $("#material").val() || "";
common.util.__ajax({
url:'/netSale/saveProductParam',
data:{
productSkn:specialAttrBo.productSkn,
washTips:washTips.replace(/\|/g, ","),
productMaterial:productMaterial.replace(/\|/g, ",")
}
},function() {
// body...
});
});
}
{//搜索关键词
var searchKeys = "";
if(window.NETSALEDATA.productExtBo) {
searchKeys = window.NETSALEDATA.productExtBo.searchKeys || "";
}
$("#searchKeys").val(searchKeys);
var g = new common.grid({
el: "#search-key",
columns: [
{display: "ID", name: "id"},
{display: "内容", name: "content"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info add" data-index="' + item.__index + '">添加</a>';
}
}
]
});
g.init('/netSale/queryHotSearchTerms');
$("#searchKeys").on('change',function() {
searchKeys = $("#searchKeys").val();
});
$(document).on('click', '.add', function() {
var item = g.rows[$(this).data("index")];
var value = $("#searchKeys").val();
if(value) value+=",";
$("#searchKeys").val(value + item.content);
searchKeys = $("#searchKeys").val();
});
$("#save-searchKey").on('click', function() {
common.util.__ajax({
url:'/netSale/saveNetSaleSearchKeys',
data:{
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
searchKeys: searchKeys
}
},function(res) {
});
});
}
{//尺寸信息
var sizeInfo = {};
if(window.NETSALEDATA.sizeInfo) {
sizeInfo = window.NETSALEDATA.sizeInfo;
}
$("#body").html(common.util.__template2($("#sizeifo-template").html(),sizeInfo));
}
{//搜索优先级
var searchSortList = [];
if(window.NETSALEDATA.searchSortList) {
searchSortList = window.NETSALEDATA.searchSortList;
}
for(var i = 0; i < searchSortList.length; i++) {
if(searchSortList[i].modelId == 1)
$("#sort0").val(searchSortList[i].intValue);
else if(searchSortList[i].modelId == 2)
$("#sort1").val(searchSortList[i].intValue);
else if(searchSortList[i].modelId == 3)
$("#sort2").val(searchSortList[i].intValue);
}
var item = [];
for (var i = 0; i < 3; i++) {
item[i] = {
productSkn:window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
modelId:i + 1,
projectId:1,
intValue:parseInt($("#sort" + i).val())
};
}
for(var i = 0; i < 3; i++) {
for (var j = 0; j < searchSortList.length; j++) {
if(searchSortList[j].modelId == item[i].modelId) {
item[i].id = searchSortList[j].id;
break;
}
}
}
window.NETSALEDATA.searchSortList = item;
$('#sort-save').on('click', function () {
common.util.__ajax({
url:'/netSale/saveSearchSort',
data:{searchSortList:JSON.stringify(window.NETSALEDATA.searchSortList)}
},function() {
});
});
$("#sort0").on('change', function() {
window.NETSALEDATA.searchSortList[0].intValue = parseInt($("#sort0").val());
});
$("#sort1").on('change', function() {
window.NETSALEDATA.searchSortList[1].intValue = parseInt($("#sort1").val());
});
$("#sort2").on('change', function() {
window.NETSALEDATA.searchSortList[2].intValue = parseInt($("#sort2").val());
});
}
}