notify.js
1.3 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
var $ = require('yoho-jquery');
function statusAsync(sku) {
var uid = getUid();
if (!uid) {
return $.Deferred().reject({}).promise(); // eslint-disable-line
}
if (!sku) {
return $.Deferred().reject({ // eslint-disable-line
code: 403,
message: '商品错误'
}).promise();
}
return $.getJSON('/product/detail/notify/status', {sku: sku})
.then(function(result) {
if (result.code === 200) {
result.data.sku = sku;
return result;
} else {
return $.Deferred().reject(result).promise(); // eslint-disable-line
}
});
}
function addAsync(skn, sku) {
var uid = getUid();
if (!uid) {
return $.Deferred().reject({ // eslint-disable-line
code: 400,
data: {
refer: window.signinUrl()
}
}).promise();
}
if (skn && sku) {
return $.post('/product/detail/notify/add', {skn: skn, sku: sku});
} else {
return $.Deferred().reject({ // eslint-disable-line
code: 403,
message: '商品错误'
}).promise();
}
}
module.exports = {
statusAsync,
addAsync
};