StoreService.js
4.7 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
"use strict";
var StoreService = angular.module('StoreService',[]);
StoreService.service("StoreService", [
'$rootScope',
'BaseService',
function ($rootScope,BaseService) {
var _service = {
stores:[],
store:[],
storeRefundAddressList:[],
storeRefundAddress:[],
storePager:function(){
BaseService.request({
url:BaseService.url.storePager_url,
method:'post',
mark:true,
fn:function(response) {
if(response.code == 0) {
_service.stores = response.data;
$rootScope.$broadcast('store.list');
}
}
});
},
getStoreDetail:function(callback){
BaseService.request({
url:BaseService.url.getStoreDetail_url,
method:'GET',
mark:true,
fn:function(response) {
if(callback) {
callback.call(this, response);
}
}
});
},
editStore:function(editStoreInfo){
BaseService.request({
url:BaseService.url.updateStore_url,
method:'post',
data:editStoreInfo,
mark:false,
fn:function(data){
if(data.code == 0) {
window.history.go(-1);
}
BaseService.updateAlert(data.message,data.code);
}
});
},
storeRefundAddressPager:function(query){
BaseService.request({
url:BaseService.url.storeRefundAddressPager_url,
method:'post',
mark:true,
data:query,
fn:function(response) {
if(response.code == 0) {
_service.storeRefundAddressList = response.data;
$rootScope.$broadcast('storeRefundAddress.list');
}
}
});
},
deleteStoreRefundAddress:function(id,callback) {
BaseService.request({
url: BaseService.url.deleteStoreRefundAddress_url + "/" + id,
method: 'get',
mark: true,
fn: function (response) {
if (response.code == 0) {
callback.call();
} else {
BaseService.updateAlert(response.message, response.code);
}
}
});
},
getStoreRefundAddressDetail:function(id,callback){
BaseService.request({
url:BaseService.url.getStoreRefundAddressDetail_url+id,
method:'GET',
mark:true,
fn:function(response) {
if(callback) {
callback.call(this, response);
}
}
});
},
editStoreRefundAddress:function(editStoreRefundAddressInfo){
var url ;
if(editStoreRefundAddressInfo.id !== ''){
url = BaseService.url.updateStoreRefundAddress_url;
}else {
url = BaseService.url.addStoreRefundAddress_url;
}
BaseService.request({
url:url,
method:'post',
data:editStoreRefundAddressInfo,
mark:false,
fn:function(data){
if(data.code == 0) {
window.history.go(-1);
}
BaseService.updateAlert(data.message,data.code);
}
});
},
listStore:function() {
BaseService.request({
url:BaseService.url.listStore_url,
method:'POST',
mark:true,
fn:function(response) {
if(response.code == 0) {
_service.stores = response.data;
$rootScope.$broadcast('store.list');
}
}
});
},
}
return _service;
}]);