marketing.CouponSend.Send.js
2.67 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
webpackJsonp([81],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/5/23.
*/
'use strict';
var $ = __webpack_require__(1),
common=__webpack_require__(2);
var couponId = location.href.substring(location.href.lastIndexOf("/") + 1);
common.util.__ajax({
url: "/coupon/querySendCouponList",
data: {couponId:couponId},
async: false
}, function (res) {
$("#title").text(res.data.list[0].couponName);
},true);
var Bll = {
getListByCouponId: function () {
common.util.__ajax({
url: "/couponSendInfo/getListByCouponId",
data: {couponId:couponId},
async: false
}, function (res) {
$("#list-content").html(common.util.__template2($("#template-list").html(), res));
},true);
}
};
Bll.getListByCouponId();
//发放优惠券事件
$(document).on("click", "#sendCoupon", function() {
var uids = $("#handworkSend").val();
if(uids) {
common.util.__ajax({
url: "/coupon/sendCoupon",
data: {
couponId:couponId,
uids:uids
}
}, function (res) {
var msg1=[],msg2=[];
res.data.forEach(function (result) {
if(result.flag==false){
msg1.push('<p>'+result.uid+':'+result.errMsg + '。</p>');
}else{
msg2.push('<p>'+result.uid+':发放成功。</p>');
}
});
if(msg1.length>0){
common.util.__tip(msg1.join(""), 'warning');
}
if(msg2.length>0){
common.util.__tip(msg2.join(""), 'success');
}
},true);
} else {
common.util.__tip("请输入UID", "warning");
}
});
//批量导入
$(document).on("click", "#batch-import", function() {
$("#picfile").click();
common.edit.ajaxfileupload(".picfile", {
params: {
__type: "import-txt",
couponId:parseInt(couponId)
},
valid_extensions: ['txt'],
onComplete: function (response) {
if (response.status && response.code == 200) {
//todo
Bll.getListByCouponId();
}
else {
common.util.__tip(response.message, 'warning');
}
}
});
});
//重新发放
$(document).on("click", ".reSend", function() {
var id = $(this).data("index");
common.util.__ajax({
url: "/couponSendInfo/sendAgainById",
data: {id: id}
}, function () {
Bll.getListByCouponId();
});
});
/***/ }
]);