...
|
...
|
@@ -3,21 +3,63 @@ |
|
|
var api = global.yoho.API;
|
|
|
|
|
|
const camelCase = global.yoho.camelCase;
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
/**
|
|
|
* 分享页面基础参数
|
|
|
* 查询品牌店铺优惠券结果处理
|
|
|
* @param {object} sizeInfo [接口原始数据]
|
|
|
* @return {object} [description]
|
|
|
*/
|
|
|
// const getPreferenceData = (data) => {
|
|
|
// var dest = {};
|
|
|
const processBrandCouponData = (data) => {
|
|
|
var dest = {},
|
|
|
list = data.data || {},
|
|
|
distCoupons = [];
|
|
|
|
|
|
// let list = data.data || {};
|
|
|
list = camelCase(list);
|
|
|
dest.code = data.code;
|
|
|
_.forEach(list.coupons, function(value) {
|
|
|
|
|
|
// list = camelCase(list);
|
|
|
if (!value.status) {
|
|
|
return;
|
|
|
}
|
|
|
let coupon = value;
|
|
|
|
|
|
// return dest;
|
|
|
// };
|
|
|
coupon.money = parseInt(value.money);
|
|
|
if (coupon.status === 1) {
|
|
|
coupon.cooponStateMessage = '可以领取';
|
|
|
} else if (coupon.status === 2) {
|
|
|
coupon.cooponStateMessage = '已抢光';
|
|
|
} else if (coupon.status === 3) {
|
|
|
coupon.cooponStateMessage = '已领取';
|
|
|
}
|
|
|
|
|
|
distCoupons.push(coupon);
|
|
|
distCoupons.push(coupon);
|
|
|
|
|
|
});
|
|
|
|
|
|
if (distCoupons.length > 1) {
|
|
|
dest.mutilCoupon = true;
|
|
|
}
|
|
|
dest.coupons = distCoupons;
|
|
|
dest.message = list.message;
|
|
|
return dest;
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 领取品牌店铺优惠券
|
|
|
* @param {object} sizeInfo [接口原始数据]
|
|
|
* @return {object} [description]
|
|
|
*/
|
|
|
const getBrandCouponStatus = (data) => {
|
|
|
var dest = {};
|
|
|
|
|
|
dest.code = data.code;
|
|
|
dest.message = data.message;
|
|
|
dest.logIn = true;
|
|
|
return dest;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品牌信息及其优惠券
|
...
|
...
|
@@ -29,7 +71,7 @@ exports.getBrandIntro = (data) => { |
|
|
infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端
|
|
|
|
|
|
return api.get('', infoData).then(result => {
|
|
|
return camelCase(result);
|
|
|
return processBrandCouponData(result);
|
|
|
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
|
|
|
};
|
|
|
|
...
|
...
|
@@ -44,6 +86,6 @@ exports.getCoupon = (data) => { |
|
|
infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端
|
|
|
|
|
|
return api.get('', infoData).then(result => {
|
|
|
return camelCase(result);
|
|
|
return getBrandCouponStatus(result);
|
|
|
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
|
|
|
}; |
...
|
...
|
|