netsale-ty.js
12.1 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
var $ = require('jquery'),
common = require('../../../../common/common'),
util = require('../../../../common/util');
if (window.NETSALEDATA) {
{ //搜索关键词
var searchKeys = "";
if (window.NETSALEDATA.productExtBo) {
searchKeys = window.NETSALEDATA.productExtBo.searchKeys || "";
}
$("#searchKeys").val(searchKeys);
var g = new common.grid({
el: "#search-key",
hash: false,
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.indexOf(item.content) == -1) {
if (value) value += ",";
$("#searchKeys").val(value + item.content);
searchKeys = $("#searchKeys").val();
} else {
util.__tip("商品关键词不能重复");
}
});
$("#save-searchKey").on('click', function () {
common.util.__ajax({
url: '/netSale/saveNetSaleSearchKeys',
data: {
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
searchKeys: searchKeys
}
});
return false;
});
var oldtaobaoUrl = taobaoUrl = window.NETSALEDATA.productUrlBo.taobaoUrl || "";
var oldtmallUrl = tmallUrl = window.NETSALEDATA.productUrlBo.tmallUrl || "";
var oldjdUrl = jdUrl = window.NETSALEDATA.productUrlBo.jdUrl || "";
$("#taobaoUrl").val(taobaoUrl);
$("#tmallUrl").val(tmallUrl);
$("#jdUrl").val(jdUrl);
var linkExistFlag = window.NETSALEDATA.productUrlBo.linkExistFlag;
$(":radio[name=linkExistFlag]").each(function(){
if(linkExistFlag == $(this).val()){
$(this).prop("checked",true);
}
});
$(document).on("change",":radio[name=linkExistFlag]",function(){
$("#linkExistFlag").val($(this).val());
});
$('input[name=linkExistFlag]').on('change', function() { linkExistFlag = $("#taobaoUrl").val(); });
$("#taobaoUrl").on('change', function() { taobaoUrl = $("#taobaoUrl").val(); });
$("#tmallUrl").on('change', function() { tmallUrl = $("#tmallUrl").val(); });
$("#jdUrl").on('change', function() { jdUrl = $("#jdUrl").val(); });
$("#save-urlList").on('click', function() {
if(taobaoUrl!="")
if(taobaoUrl.indexOf("item.taobao.com")!=0 && taobaoUrl.indexOf("http://item.taobao.com")!=0 && taobaoUrl.indexOf("https://item.taobao.com")!=0) {util.__tip("淘宝URL不正确!");return false;}
if(tmallUrl!="")
if(tmallUrl.indexOf("detail.tmall.com")!=0 && tmallUrl.indexOf("http://detail.tmall.com")!=0 && tmallUrl.indexOf("https://detail.tmall.com")!=0 && tmallUrl.indexOf("item.tmall.com")!=0 && tmallUrl.indexOf("http://item.tmall.com")!=0 && tmallUrl.indexOf("https://item.tmall.com")!=0) {util.__tip("天猫URL不正确!");return false;}
if(jdUrl!="")
if(jdUrl.indexOf("item.jd.com")!=0 && jdUrl.indexOf("http://item.jd.com")!=0 && jdUrl.indexOf("https://item.jd.com")!=0) {util.__tip("京东URL不正确!");return false;}
common.util.__ajax({
url: '/netSale/saveProductUrlList',
data: {
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
taobaoUrl: taobaoUrl,
tmallUrl : tmallUrl,
jdUrl : jdUrl,
linkExistFlag : $("#linkExistFlag").val()
}
});
if (common.util.__sknOperateLog(window.NETSALEDATA.baseProductInfo.baseProduct.productSkn, taobaoUrl, oldtaobaoUrl, 7)) {
oldtaobaoUrl = taobaoUrl;
}
if (common.util.__sknOperateLog(window.NETSALEDATA.baseProductInfo.baseProduct.productSkn, tmallUrl, oldtmallUrl, 8)) {
oldtmallUrl = tmallUrl;
}
if (common.util.__sknOperateLog(window.NETSALEDATA.baseProductInfo.baseProduct.productSkn, jdUrl, oldjdUrl, 9)) {
oldjdUrl = jdUrl;
}
return false;
});
$("#save-jdUrl").on('click', function(){
common.util.__ajax({
url: '/ChannelProductController/synChannelProduct',
data: {
skn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
url : $("#jdUrl").val(),
type : 3 //类型(1-天猫;2-淘宝;3-京东)
}
});
return false;
});
$("#save-tmallUrl").on('click', function(){
common.util.__ajax({
url: '/ChannelProductController/synChannelProduct',
data: {
skn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
url : $("#tmallUrl").val(),
type : 1 //类型(1-天猫;2-淘宝;3-京东)
}
});
return false;
});
$("#save-taobaoUrl").on('click', function(){
common.util.__ajax({
url: '/ChannelProductController/synChannelProduct',
data: {
skn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
url : $("#taobaoUrl").val(),
type : 2 //类型(1-天猫;2-淘宝;3-京东)
}
});
return false;
});
// window.GOLABDATA.on('TYsearchKey', function () {
// var washTips = $("#washTips").val() || "";
// var productMaterial = $("#material").val() || "";
// return {
// "searchKeys": searchKeys
// };
// });
}
{ //尺寸信息
var productSkn = window.NETSALEDATA.baseProductInfo.baseProduct.productSkn;
var dataList;
if (productSkn) {
common.util.__ajax({
url: '/meterManage/productSize/queryProdSizeList',
data: {
productSkn: productSkn
}
}, function (res) {
if (res.data.list && res.data.list.length > 0) {
var e = new common.edit("#add-list");
dataList = res.data.list[0];
common.sizeInfo.list(dataList);
$("#noMeasureIds").val(dataList.noMeasureIds ? dataList.noMeasureIds.join("|") : "");
e.init();
$(document).on('click', '#add-saveBtn', function () {
var noMeasureIds = JSON.stringify($("#noMeasureIds").val() ? $("#noMeasureIds").val().split("|") : []);//无需测量的列
//尺码信息列表
var sizeInfoList = [];
for (var i = 0; i < $(".sizeInfo").length; i++) {
var info = $($(".sizeInfo")[i]);//当前尺码input对象
var prdList = dataList.sizeRelationsList[info.data("index")].prdSizeAttributeBoList;//当前列的对象的尺码列表
var attrIndex = parseInt(i % prdList.length);//在当前列的索引
sizeInfoList[i] = ({
productSkn: dataList.productSkn,
sizeId: dataList.sizeRelationsList[info.data("index")].sizeId,
sizeAttributeId: prdList[attrIndex].sizeAttributeId,
sizeValue: info.val()
});
}
//商品参考尺码
var productSizeReferList = [];
for (var i = 0; i < $(".refInfo").length / 2; i++) {
var ref1 = $($(".refInfo1")[i]);
var ref2 = $($(".refInfo2")[i]);
productSizeReferList.push({
sizeId: dataList.sizeRelationsList[ref1.data("index")].sizeId,
gender: dataList.gender,
referenceName: ref1.val() + '/' + ref2.val()
});
}
var data = {
productSkn: dataList.productSkn,
noMeasureIds: noMeasureIds,
sizeInfoList: JSON.stringify(sizeInfoList),
productSizeReferList: JSON.stringify(productSizeReferList)
};
common.util.__ajax({
url: "/meterManage/productSize/saveProdSizeInfo",
data: data
}, function () {
});
return false;
});
}
}, true);
}
}
{ //搜索优先级
var searchSortList = [];
if (window.NETSALEDATA.searchSortList) {
searchSortList = window.NETSALEDATA.searchSortList;
}
for (var i = 0; i < searchSortList.length; i++) {
if (searchSortList[i].modelId == 1 && searchSortList[i].projectId == 1 ){
$("#sort0").val(searchSortList[i].intValue);
}
if (searchSortList[i].modelId == 1 && searchSortList[i].projectId == 5 ){
$("#sort3").val(searchSortList[i].intValue);
}
}
var item = [];
var item_brand = {
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
modelId: 1,
projectId: 1,
intValue: parseInt($("#sort0").val())
};
item.push(item_brand);
var item_shops = {
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
modelId: 5,
projectId: 1,
intValue: parseInt($("#sort3").val())
};
item.push(item_shops);
for (var i = 0; i < item.length; i++) {
for (var j = 0; j < searchSortList.length; j++) {
if (searchSortList[j].modelId == item[i].modelId) {
item[i].id = searchSortList[j].id;
break;
}
}
}
searchSortList = item;
$('#sort-save').on('click', function () {
common.util.__ajax({
url: '/netSale/saveSearchSort',
data: {
searchSortList: JSON.stringify(searchSortList)
}
});
return false;
});
$("#sort0").on('change', function () {
searchSortList[0].intValue = parseInt($("#sort0").val());
});
$("#sort3").on('change', function () {
searchSortList[1].intValue = parseInt($("#sort3").val());
});
$("#sort0").keyup(function () {
$(this).val($(this).val().replace(/\D/g, ""));
});
$("#sort3").keyup(function () {
$(this).val($(this).val().replace(/\D/g, ""));
});
// window.GOLABDATA.on('TYsearchSort', function () {
// if (!searchSortList[0] || !searchSortList[1] || !searchSortList[2])
// return "请将搜索排序填写完整!";
// return {
// "searchSortList": JSON.stringify(searchSortList)
// };
// });
}
}
//当点击“无需测量”,该列输入框不可编辑
common.sizeInfo.check();