Authored by 郭成尧

buynow-ctx

... ... @@ -3,7 +3,6 @@
* @Date: 2017-06-21 10:15:45
* @Last Modified by: Targaryen
*/
const api = global.yoho.API;
class BuyNowModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -15,13 +14,18 @@ class BuyNowModel extends global.yoho.BaseModel {
* @param {*} params
*/
countUsableCoupon(params) {
return api.post('', {
return this.post({
data: {
method: 'app.Buynow.countUsableCoupon',
uid: params.uid,
product_sku: params.product_sku,
sku_type: params.sku_type || 'I',
buy_number: params.buy_number
}, {cache: false});
},
param: {
cache: false
}
});
}
/**
... ... @@ -29,7 +33,8 @@ class BuyNowModel extends global.yoho.BaseModel {
* @param {*} params
*/
listCoupon(params) {
return api.post('', {
return this.post({
data: {
method: 'app.Buynow.listCoupon',
uid: params.uid,
product_sku: params.product_sku,
... ... @@ -37,7 +42,9 @@ class BuyNowModel extends global.yoho.BaseModel {
buy_number: params.buy_number,
is_group_frees: params.is_group_frees,
delivery_way: params.delivery_way
}, {cache: false});
},
param: {cache: false}
});
}
/**
... ... @@ -46,6 +53,7 @@ class BuyNowModel extends global.yoho.BaseModel {
*/
payment(params) {
let finalParams = {
data: {
method: 'app.Buynow.payment',
uid: params.uid,
product_sku: params.product_sku,
... ... @@ -56,9 +64,13 @@ class BuyNowModel extends global.yoho.BaseModel {
is_support_apple_pay: 'N', // H5 不支持 APPLE PAY
activity_id: params.activity_id || 0,
enable_red_envelopes: 0 // H5 不支持使用红包
},
param: {
cache: false
}
};
return api.post('', finalParams, { cache: false });
return this.post(finalParams);
}
/**
... ... @@ -95,7 +107,12 @@ class BuyNowModel extends global.yoho.BaseModel {
finalParams.coupon_code = params.coupon_code;
}
return api.post('', finalParams, {cache: false});
return this.post({
data: finalParams,
param: {
cache: false
}
});
}
/**
... ... @@ -182,11 +199,14 @@ class BuyNowModel extends global.yoho.BaseModel {
finalParams.qhy_union = params.qhy_union;
}
return api.post('', finalParams, {
return this.post({
data: finalParams,
param: {
headers: {
'X-Forwarded-For': params.ip || '',
'User-Agent': params.userAgent
}
}
});
}
... ... @@ -206,7 +226,10 @@ class BuyNowModel extends global.yoho.BaseModel {
if (params.coupon_code) {
finalParams.coupon_code = params.coupon_code;
}
return api.post('', finalParams, {cache: false});
return this.post({
data: finalParams,
param: {cache: false}
});
}
/**
... ... @@ -226,7 +249,12 @@ class BuyNowModel extends global.yoho.BaseModel {
finalParams.promotion_code = params.promotion_code;
}
return api.post('', finalParams, {cache: false});
return this.post({
data: finalParams,
param: {
cache: false
}
});
}
}
... ...