info.js
2.54 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
/**
* Created by JiangMin on 2016/3/24
* 试穿详情.
*/
var $ = require('jquery');
var common = require('../common/common');
var param = location.href.match(/(info)\/(\d+)/);
//尺码列表
var modelLists = [];
common.util.__ajax({url: '/meterManage/tryInfo/info1', data: {productSkn: param[2]}}, function (data) {
var feelIds = {
1: "合适",
2: "偏大",
3: "偏小"
};
var infoLists = data.data || {};
modelLists = infoLists.tryModelList || [];
//如果存在试穿信息
if (infoLists.tryInfoBoMap) {
var tryInfo = infoLists.tryInfoBoMap;
for (var i = 0; i < modelLists.length; i++) {
if (tryInfo[modelLists[i].id]) {
modelLists[i].tryInfo = {};
tryInfo[modelLists[i].id].feel_id = feelIds[tryInfo[modelLists[i].id].feel_id];
modelLists[i].tryInfo = tryInfo[modelLists[i].id];
}
else {
modelLists[i].tryInfo = {};
modelLists[i].tryInfo.fit_size = "";
modelLists[i].tryInfo.feel_id = "";
modelLists[i].tryInfo.fit_remark = "";
}
}
}
//不存在
else {
for (var j = 0; j < modelLists.length; j++) {
modelLists[j].tryInfo = {};
}
}
var a = common.util.__template2($("#template").html(), {modelLists: modelLists});
$(".contentpanel1").html(a);
new common.dropDown({
el: '.fit_size',
ajax: 'sortsize'
});
}, true);
$(document).on("change", ".tryInfo1", function () {
var _index = $(this).data("index");
var item = modelLists[_index].tryInfo;
var name = $(this).data('name');
item[name] = $(this).val();
console.log("item", item);
});
$(document).on("click", "#addInfo", function () {
console.log("modelLists", modelLists);
//var newList = [];
//for (var i = 0; i < modelLists.length; i++) {
// console.log("modelLists");
// console.log(modelLists[i]);
// newList[i]={};
// newList[i].model_id = modelLists[i].id;
// newList[i].feel_id = modelLists[i].tryInfo.feel_id;
// newList[i].fit_size = modelLists[i].tryInfo.fit_size;
// newList[i].fit_remark = modelLists[i].tryInfo.fit_remark;
//}
//console.log("newList");
//console.log(newList);
common.util.__ajax({
url: '/meterManage/tryInfo/add',
data: {
productSkn: param[2],
productModelTry: JSON.stringify(modelLists)
}
}, function () {
console.log("成功")
});
})