...
|
...
|
@@ -11,9 +11,9 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
/**
|
|
|
* 首页数据
|
|
|
*/
|
|
|
shareIndex(activityId, isApp, uid, isStudent, protocol) {
|
|
|
shareIndex(activityId, isApp, uid) {
|
|
|
|
|
|
return api.all([this._CouponInfo(activityId, uid, isStudent), this._redeatList(),
|
|
|
return api.all([this._CouponInfo(activityId, uid), this._redeatList(),
|
|
|
this._banner()]).then(result => {
|
|
|
|
|
|
const indexData = {
|
...
|
...
|
@@ -23,8 +23,6 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
|
|
|
strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
|
|
|
|
|
|
indexData.isStudent = isStudent;
|
|
|
|
|
|
if (result[0] && result[0].data && result[0].data.userCouponBoList) {
|
|
|
_.forEach(result[0].data.userCouponBoList, function(val) {
|
|
|
|
...
|
...
|
@@ -36,22 +34,8 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
val.couponDescribe = '任意商品使用';
|
|
|
} else if (val.shopNames) {
|
|
|
val.couponDescribe = '限' + val.shopNames + '使用';
|
|
|
}
|
|
|
|
|
|
val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
|
|
|
couponId: val.couponId,
|
|
|
couponCode: val.couponCode
|
|
|
});
|
|
|
|
|
|
if (isApp) {
|
|
|
val.detailUrl = protocol + val.detailUrl +
|
|
|
'&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + protocol +
|
|
|
val.detailUrl + '","params":{"couponId":"' + val.couponId + '","couponCode":"' +
|
|
|
val.couponCode + '"}}}';
|
|
|
}
|
|
|
|
|
|
if (!indexData.isStudent) {
|
|
|
val.detailUrl = '';
|
|
|
} else if (val.shareCoupon === '商品券') {
|
|
|
val.couponDescribe = '指定商品可用';
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -102,12 +86,11 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
/**
|
|
|
* 首页获取优惠券信息
|
|
|
*/
|
|
|
_CouponInfo(activityId, uid, isStudent) {
|
|
|
_CouponInfo(activityId, uid) {
|
|
|
return api.get('', {
|
|
|
method: 'app.activity.getActivityCouponInfo',
|
|
|
activity_id: activityId,
|
|
|
uid: uid,
|
|
|
isStudent: isStudent
|
|
|
uid: uid
|
|
|
}, {
|
|
|
code: 200
|
|
|
}).then((result) => {
|
...
|
...
|
@@ -145,7 +128,8 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
code: 200
|
|
|
}).then((result) => {
|
|
|
let moreUrl,
|
|
|
detailData;
|
|
|
detailData,
|
|
|
couponDetail = _.get(result, 'data.userCouponBoList[0]', {});
|
|
|
|
|
|
if (result && result.code === 200 && result.data) {
|
|
|
detailData = _.assign(detailData, param);
|
...
|
...
|
@@ -166,14 +150,17 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
detailData.finish = parseInt(result.data.expiredTime, 10) > 0 ? false : true;
|
|
|
|
|
|
if (result.data.userCouponBoList[0].sortNames) {
|
|
|
if (couponDetail.sortNames) {
|
|
|
detailData.detailDes = '限品类: ' + result.data.userCouponBoList[0].sortNames;
|
|
|
} else if (result.data.userCouponBoList[0].brandNames) {
|
|
|
} else if (couponDetail.brandNames) {
|
|
|
detailData.detailDes = '限品牌: ' + result.data.userCouponBoList[0].brandNames;
|
|
|
} else if (result.data.userCouponBoList[0].shareCoupon === '全场通用') {
|
|
|
} else if (couponDetail.shareCoupon === '全场通用') {
|
|
|
detailData.detailDes = result.data.userCouponBoList[0].shareCoupon;
|
|
|
} else if (result.data.userCouponBoList[0].shopNames) {
|
|
|
detailData.detailDes = result.data.userCouponBoList[0].shopNames;
|
|
|
} else if (couponDetail.shopNames) {
|
|
|
detailData.detailDes = '限店铺:' + result.data.userCouponBoList[0].shopNames;
|
|
|
} else if (couponDetail.shareCoupon === '商品券') {
|
|
|
detailData.detailDes = '限商品:指定商品可用';
|
|
|
detailData.goodsCoupon = true;
|
|
|
}
|
|
|
|
|
|
detailData = _.assign(detailData, {
|
...
|
...
|
@@ -191,23 +178,24 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断是不是学生
|
|
|
/**
|
|
|
* 获取分享码
|
|
|
*/
|
|
|
checkStudent(uid) {
|
|
|
getCouponCode(uid, couponId, protocol) {
|
|
|
return api.get('', {
|
|
|
method: 'app.student.checkIsStudent',
|
|
|
uid: uid
|
|
|
method: 'app.activity.getActivityCouponCode',
|
|
|
uid: uid,
|
|
|
coupon_id: couponId
|
|
|
}).then(result => {
|
|
|
|
|
|
let isStudent;
|
|
|
|
|
|
if (result && result.data && result.code === 200) {
|
|
|
isStudent = parseInt(result.data.isStudent, 10) === 1 ? true : false;
|
|
|
if (result && result.code === 200 && result.data) {
|
|
|
result.data.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
|
|
|
couponId: couponId,
|
|
|
couponCode: result.data.couponCode
|
|
|
});
|
|
|
result.data.protocol = protocol;
|
|
|
}
|
|
|
|
|
|
return isStudent;
|
|
|
|
|
|
return result;
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
|