operations.webshare.Edit.js
3.31 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
webpackJsonp([133],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/7/6.
* 活动分享编辑
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var id = $("#edit-content").data("id"),
url = $("#edit-content").attr("url"),
module = {},
edit = new common.edit2("#edit-content",{bucket: "taobaocms"});
var startTimeObj;
var endTimeObj;
//通用对象
var Bll = {
//渲染界面
render: function () {
$("#edit-content").html(common.util.__template2($("#edit-template").html(), module));
Bll.__editRender();
},
//转换时间格式
getTime: function (time) {
var t = new Date(time * 1000);
return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
},
//验证
__editRender: function () {
edit.init();
$("#choose-status").show();
new common.dropDown({el: "#status"});
startTimeObj = $("#couponStartTime").datetimepicker({
timeFormat: 'HH:mm:ss',
showSecond: true
}).data("datepicker");
endTimeObj = $("#couponEndTime").datetimepicker({
timeFormat: 'HH:mm:ss',
showSecond: true
}).data("datepicker");
edit.on("file_onComplete", function (obj) {
var names = obj.field;
module = common.util.__buildobj(names, '.', module, function (o, name) {
o[name] = obj.data;
});
});
}
};
if(id){
common.util.__ajax({
async: false,
url: "/webShare/selectWebShare",
data: {id: id}
}, function (res) {
module = res.data;
if(module.couponId === 0){
module.couponId = null;
}
if(module.couponStartTime === 0){
module.couponStartTime = null;
}
if(module.couponEndTime === 0){
module.couponEndTime = null;
}
if(module.couponStartTime){
module.couponStartTime=Bll.getTime(module.couponStartTime);
}
if(module.couponEndTime){
module.couponEndTime=Bll.getTime(module.couponEndTime);
}
},true);
}
Bll.render();
function checkCouponId() {
var value = $('input[name="coupon_id"]').val();
if(isNaN(value)){
common.util.__tip("劵ID必须为数字!");
return false;
}else{
return true;
}
}
//保存数据
$(document).on("click", "#save_btn", function () {
module.couponStartTime = ((new Date(module.couponStartTime).getTime())) / 1000 || "";
module.couponEndTime = ((new Date(module.couponEndTime).getTime())) / 1000 || "";
if(edit.validate()) {
if(checkCouponId()){
common.util.__ajax({
url: url,
data: module
}, function () {
setTimeout(function () {
location.href = "/operations/webshare/index";
},600);
});
}
}
});
/**
* 监听输入值的变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
module = common.util.__buildobj(name, '.', module, function (obj, name) {
obj[name] = $this.val();
});
});
/***/ }
]);