...
|
...
|
@@ -11,72 +11,84 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
/**
|
|
|
* 首页数据
|
|
|
*/
|
|
|
shareIndex(activityId, isApp) {
|
|
|
|
|
|
return api.all([this._CouponInfo(activityId), this._redeatList(), this._banner()]).then(result => {
|
|
|
const indexData = {
|
|
|
newsFlash: []
|
|
|
};
|
|
|
|
|
|
const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
|
|
|
strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
|
|
|
|
|
|
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
|
|
|
shareIndex(activityId, isApp, uid) {
|
|
|
|
|
|
return api.all([this._CouponInfo(activityId), this._redeatList(), this._banner(),
|
|
|
this._checkStudent(uid)]).then(result => {
|
|
|
|
|
|
const indexData = {
|
|
|
newsFlash: []
|
|
|
};
|
|
|
|
|
|
const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
|
|
|
strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
|
|
|
|
|
|
if (result[3]) {
|
|
|
indexData.isStudent = parseInt(result[3].isStudent, 10) === 1 ? true : false;
|
|
|
}
|
|
|
|
|
|
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,
|
|
|
useCode: uid.toString()
|
|
|
});
|
|
|
|
|
|
if (isApp) {
|
|
|
val.detailUrl = val.detailUrl +
|
|
|
'&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + val.detailUrl +
|
|
|
'","params":{"counum":"' + val.couponValue + '","couponType":"' + val.shareCouponType +
|
|
|
'","detailDes":"' + val.detailDes + '","couponId":"' + val.couponId + '","useCode":"' +
|
|
|
uid + '"}}}';
|
|
|
}
|
|
|
|
|
|
if (!indexData.isStudent) {
|
|
|
val.detailUrl = '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (isApp) {
|
|
|
val.detailUrl = val.detailUrl +
|
|
|
'&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + val.detailUrl +
|
|
|
'","params":{"counum":"' + val.couponValue + '","couponType":"' + val.shareCouponType +
|
|
|
'","detailDes":"' + val.detailDes + '","couponId":"' + val.couponId + '"}}}';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
indexData.userCouponBoList = result[0].data.userCouponBoList;
|
|
|
}
|
|
|
indexData.userCouponBoList = result[0].data.userCouponBoList;
|
|
|
}
|
|
|
|
|
|
if (result[1] && result[1].data && result[1].data.detail) {
|
|
|
_.forEach(result[1].data.detail, function(data) {
|
|
|
indexData.newsFlash.push({
|
|
|
flashDetail: '用户' + data.nickName + ' 今日返利' + data.coinNum + '个有货币'
|
|
|
if (result[1] && result[1].data && result[1].data.detail) {
|
|
|
_.forEach(result[1].data.detail, function(data) {
|
|
|
indexData.newsFlash.push({
|
|
|
flashDetail: '用户' + data.nickName + ' 今日返利' + data.coinNum + '个有货币'
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result[2]) {
|
|
|
indexData.banner = result[2].data[0].src;
|
|
|
}
|
|
|
if (result[2]) {
|
|
|
indexData.banner = result[2].data[0].src;
|
|
|
}
|
|
|
|
|
|
indexData.rebeatUrl = isApp ? rebeatUrl +
|
|
|
'?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + rebeatUrl + '"}}' : rebeatUrl;
|
|
|
indexData.rebeatUrl = isApp ? rebeatUrl +
|
|
|
'?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + rebeatUrl + '"}}' :
|
|
|
rebeatUrl;
|
|
|
|
|
|
indexData.strategyUrl = isApp ? strategyUrl +
|
|
|
'&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + strategyUrl + '"}}' : strategyUrl;
|
|
|
indexData.strategyUrl = isApp ? strategyUrl +
|
|
|
'&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + strategyUrl + '"}}' : strategyUrl;
|
|
|
|
|
|
return indexData;
|
|
|
});
|
|
|
return indexData;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -129,35 +141,13 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
shareDetail(uid, param, isApp) {
|
|
|
return api.all([this._couponDetail(uid, param, isApp), this._checkStudent(uid)]).then(result => {
|
|
|
let finalData;
|
|
|
|
|
|
if (result[0]) {
|
|
|
finalData = _.assign(finalData, result[0]);
|
|
|
}
|
|
|
|
|
|
if (result[1]) {
|
|
|
finalData = _.assign(finalData, {
|
|
|
isStudent: parseInt(result[1].isStudent, 10) === 1 ? true : false
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (!finalData.isStudent) {
|
|
|
finalData.couponCode = '*******';
|
|
|
}
|
|
|
|
|
|
return finalData;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 优惠劵详情数据
|
|
|
*/
|
|
|
_couponDetail(uid, param, isApp) {
|
|
|
shareDetail(param, isApp) {
|
|
|
return api.get('', {
|
|
|
method: 'app.activity.getActivityCouponCode',
|
|
|
uid: uid,
|
|
|
uid: param.useCode,
|
|
|
coupon_id: param.couponId
|
|
|
}, {
|
|
|
code: 200
|
...
|
...
|
@@ -200,7 +190,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
let resu = {};
|
|
|
|
|
|
if (result && result.data) {
|
|
|
if (result && result.data && result.code === 200) {
|
|
|
resu = result.data;
|
|
|
}
|
|
|
|
...
|
...
|
|