|
|
const api = global.yoho.API;
|
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
module.exports = class extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 首页数据
|
|
|
*/
|
|
|
shareIndex(activityId) {
|
|
|
|
|
|
return api.all([this._CouponInfo(activityId), this._redeatList()]).then(result => {
|
...
|
...
|
@@ -15,13 +19,27 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
if (result[0] && result[0].data && result[0].data.userCouponBoList) {
|
|
|
_.forEach(result[0].data.userCouponBoList, function(val) {
|
|
|
|
|
|
if (val.sortNames) {
|
|
|
val.couponDescribe = '限' + val.sortNames + '使用';
|
|
|
val.detailDes = '限品类: ' + val.sortNames;
|
|
|
} else if (val.brandNames) {
|
|
|
val.couponDescribe = '限' + val.brandNames + '使用';
|
|
|
val.detailDes = '限品牌: ' + val.brandNames;
|
|
|
} else if (val.shareCoupon === '全场通用') {
|
|
|
val.couponDescribe = '任意商品使用';
|
|
|
val.detailDes = val.shareCoupon;
|
|
|
} else if (val.shopNames) {
|
|
|
val.couponDescribe = '限' + val.shopNames + '使用';
|
|
|
val.detailDes = val.shareCoupon;
|
|
|
}
|
|
|
|
|
|
val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
|
|
|
counum: val.couponValue,
|
|
|
couponType: val.shareCouponType,
|
|
|
detailDes: val.detailDes,
|
|
|
couponId: val.couponId
|
|
|
});
|
|
|
});
|
|
|
|
|
|
indexData.userCouponBoList = result[0].data.userCouponBoList;
|
...
|
...
|
@@ -49,7 +67,9 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
}, {
|
|
|
code: 200
|
|
|
}).then((result) => {
|
|
|
return result;
|
|
|
if (result && result.code === 200 && result.data) {
|
|
|
return result;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -60,9 +80,62 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
return api.get('', {
|
|
|
method: 'app.yohocoinrebeat.lastedlist'
|
|
|
}, {
|
|
|
code: 200,
|
|
|
cache: true
|
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200 && result.data) {
|
|
|
return result;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 优惠详情页数据
|
|
|
*/
|
|
|
shareDetail(uid, param) {
|
|
|
return api.get('', {
|
|
|
method: 'app.activity.getActivityCouponCode',
|
|
|
uid: uid,
|
|
|
coupon_id: param.couponId
|
|
|
}, {
|
|
|
code: 200
|
|
|
}).then((result) => {
|
|
|
return result;
|
|
|
|
|
|
if (result && result.code === 200 && result.data) {
|
|
|
result.data = _.assign(result.data, param);
|
|
|
|
|
|
result.data.moreUrl = helpers.urlFormat('', {
|
|
|
coupon_code: result.data.couponCode,
|
|
|
coupon_id: param.couponId,
|
|
|
title: '优惠活动商品'
|
|
|
}, 'list');
|
|
|
|
|
|
return result.data;
|
|
|
} else {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的返利页数据
|
|
|
*/
|
|
|
// myRebeat(uid) {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.yohocoinrebeat.detail',
|
|
|
// uid: uid
|
|
|
// }, {
|
|
|
// code: 200
|
|
|
// }).then((result) => {
|
|
|
|
|
|
// if (result && result.code === 200 && result.data) {
|
|
|
|
|
|
// return result.data;
|
|
|
// } else {
|
|
|
// return {};
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
// }
|
|
|
}; |
...
|
...
|
|