PromotionService.js
4.0 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
"use strict";
var PromotionService = angular.module('PromotionService',[]);
PromotionService.service("PromotionService", [
'$rootScope',
'BaseService',
function ($rootScope,BaseService) {
var _service = {
promotions:[],
promotion:{},
promotionTypes:{},
moneyGiftList:[],
productGiftList:[],
promotionList:function(queryParam){
BaseService.request({
url:BaseService.url.promotionList_url,
method:'post',
mark:true,
data:queryParam,
fn:function(response) {
if(response.code == 0) {
_service.promotions = response.data;
$rootScope.$broadcast('promotion.list');
}
}
});
},
promotionDetail:function(id){
BaseService.request({
url:BaseService.url.promotionDetail_url+id,
method:'get',
mark:true,
fn:function(response) {
if(response.code == 0) {
_service.promotion = response.data;
$rootScope.$broadcast('promotion.detail');
}
}
});
},
listMoneyGift:function(id){
BaseService.request({
url:BaseService.url.listMoneyGift_url+id,
method:'get',
mark:true,
fn:function(response) {
if(response.code == 0) {
_service.moneyGiftList = response.data;
$rootScope.$broadcast('moneyGift:list');
}
}
});
},
listProductGift:function(id){
BaseService.request({
url:BaseService.url.listProductGift_url+id,
method:'get',
mark:true,
fn:function(response) {
if(response.code == 0) {
_service.productGiftList = response.data;
$rootScope.$broadcast('productGift:list');
}
}
});
},
saveOrUpdate:function(obj) {
BaseService.request({
url:BaseService.url.promotionSaveOrUpdate_url,
method:'post',
data:obj,
mark:false,
fn:function(data){
if(data.code == 0) {
window.history.go(-1);
}
BaseService.updateAlert(data.message,data.code);
}
});
},
addMoneyGiftPromotion:function(obj) {
BaseService.request({
url:BaseService.url.saveMoneyGift_url,
method:'post',
data:obj,
mark:false,
fn:function(data){
if(data.code == 0) {
window.history.go(-1);
}
BaseService.updateAlert(data.message,data.code);
}
});
},
addProductGiftPromotion:function(obj) {
BaseService.request({
url:BaseService.url.saveProductGift_url,
method:'post',
data:obj,
mark:false,
fn:function(data){
if(data.code == 0) {
window.history.go(-1);
}
BaseService.updateAlert(data.message,data.code);
}
});
},
promotionDelete:function(id){
BaseService.request({
url:BaseService.url.promotionDelete_url+id,
method:'get',
mark:true,
fn:function(response) {
if(response.code == 0) {
window.location.reload();
}else{
BaseService.updateAlert(response.message,response.code);
}
}
});
},
promotionTypesList:function(){
BaseService.request({
url:BaseService.url.promotionTypes_url,
method:'post',
mark:true,
fn:function(response) {
if(response.code == 0) {
_service.promotionTypes = response.data;
$rootScope.$broadcast('promotion.types');
}
}
});
},
deleteMoneyGift:function(id) {
BaseService.request({
url:BaseService.url.deleteMoneyGift_url+id,
method:'get',
mark:false,
fn:function(data){
if(data.code == 0) {
window.location.reload(true);
}
BaseService.updateAlert(data.message,data.code);
}
});
},
deleteProductGift:function(id) {
BaseService.request({
url:BaseService.url.deleteProductGift_url+id,
method:'get',
mark:false,
fn:function(data){
if(data.code == 0) {
window.location.reload(true);
}
BaseService.updateAlert(data.message,data.code);
}
});
}
}
return _service;
}]);