sendCoupon.js
1.9 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
/**
* Created by ty on 2016/5/23.
*/
'use strict';
var $ = require('jquery'),
common=require('../common/common');
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 () {
location.href = location.href;
});
} else {
common.util.__tip("请输入UID", "warning");
}
});
//批量导入
$(document).on("click", "#batch-import", function() {
$("#importFile").click();
});
//重新发放
$(document).on("click", ".reSend", function() {
var id = $(this).data("id");
common.util.__ajax({
url: "/couponSendInfo/sendAgainById",
data: {id: id}
}, function () {
Bll.getListByCouponId();
});
});
//导入
common.edit.ajaxfileupload("#importFile",{
params: {
type: "drawlineUserQueue",
__type: "batch-import"
},
onComplete:function(res){
if(res.code == 200) {
common.util.__tip(res.message, 'success');
Bll.getListByCouponId();
} else {
common.util.__tip(res.message);
}
}
});