Authored by zhangxiaoru

链接

'use strict';
const shareBuyModel = require('../models/share-buy');
const shareBuyModel = require('../models/share-buy'),
headerModel = require('../../../doraemon/models/header');
exports.index = (req, res, next) => {
let activityId = req.query.activity_id || 488;
let activityId = req.query.activity_id || 2023,
isApp = req.yoho.isApp;
req.ctx(shareBuyModel).shareIndex(activityId).then(data => {
req.ctx(shareBuyModel).shareIndex(activityId, isApp).then(data => {
res.render('share-buy/share-buy', {
pageHeader: headerModel.setNav({
navTitle: '分享购'
}),
isApp: isApp,
localCss: true,
width750: true,
title: '分享购',
userCouponBoList: data.userCouponBoList,
newsFlash: data.newsFlash
newsFlash: data.newsFlash,
rebeatUrl: data.rebeatUrl,
strategyUrl: data.strategyUrl
});
}).catch(next);
... ... @@ -24,11 +32,16 @@ exports.detail = (req, res, next) => {
couponType: req.query.couponType,
detailDes: req.query.detailDes,
couponId: 12301 // req.query.couponId;
};
},
isApp = req.yoho.isApp;
req.ctx(shareBuyModel).shareDetail(uid, param).then(data => {
req.ctx(shareBuyModel).shareDetail(uid, param, isApp).then(data => {
res.render('share-buy/share-detail', {
pageHeader: headerModel.setNav({
navTitle: '分享购'
}),
isApp: isApp,
localCss: true,
width750: true,
title: '分享购',
... ... @@ -39,10 +52,15 @@ exports.detail = (req, res, next) => {
};
exports.myRebeat = (req, res, next) => {
let uid = req.user.uid;
let uid = req.user.uid,
isApp = req.yoho.isApp;
req.ctx(shareBuyModel).myRebeat(uid).then(data => {
req.ctx(shareBuyModel).myRebeat(uid, isApp).then(data => {
res.render('share-buy/my-rebeat', {
pageHeader: headerModel.setNav({
navTitle: '我的返利收益'
}),
isApp: isApp,
localCss: true,
width750: true,
title: '我的返利收益',
... ...
... ... @@ -10,13 +10,16 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 首页数据
*/
shareIndex(activityId) {
shareIndex(activityId, isApp) {
return api.all([this._CouponInfo(activityId), this._redeatList()]).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) {
... ... @@ -34,12 +37,20 @@ module.exports = class extends global.yoho.BaseModel {
val.detailDes = val.shareCoupon;
}
val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
counum: val.couponValue,
couponType: val.shareCouponType,
detailDes: val.detailDes,
couponId: val.couponId
});
if (isApp) {
val.detailUrl = val.detailUrl +
'?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http://m.yohobuy.com/activity/share-buy/detail","params":{"counum":"' +
val.couponValue + '","couponType":"' + val.shareCouponType + '","detailDes":"' +
val.detailDes + '","couponId":"' + val.couponId + '"}}}';
}
});
indexData.userCouponBoList = result[0].data.userCouponBoList;
... ... @@ -53,6 +64,12 @@ module.exports = class extends global.yoho.BaseModel {
});
}
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;
return indexData;
});
}
... ... @@ -92,7 +109,7 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 优惠详情页数据
*/
shareDetail(uid, param) {
shareDetail(uid, param, isApp) {
return api.get('', {
method: 'app.activity.getActivityCouponCode',
uid: uid,
... ... @@ -110,6 +127,12 @@ module.exports = class extends global.yoho.BaseModel {
title: '优惠活动商品'
}, 'list');
result.data = _.assign(result.data, {
isApp: isApp ? true : false
});
result.data.finish = parseInt(result.data.expiredTime, 10) > 0 ? false : true;
return result.data;
} else {
return {};
... ... @@ -121,13 +144,15 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 我的返利页数据
*/
myRebeat(uid) {
myRebeat(uid, isApp) {
return api.get('', {
method: 'app.yohocoinrebeat.detail',
uid: uid
}, {
code: 200
}).then((result) => {
let currencyUrl = 'http://m.yohobuy.com/home/helpDetail?code=20151230-102233&caption=有货币介绍&name=有货币介绍';
let shareUrl = 'http://m.yohobuy.com/activity/share-buy';
if (result && result.code === 200 && result.data) {
let dateTime;
... ... @@ -142,6 +167,14 @@ module.exports = class extends global.yoho.BaseModel {
'.' + dateTime.getDate();
});
result.data.currencyUrl = isApp ? currencyUrl +
'?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' +
currencyUrl + '"}}' : currencyUrl;
result.data.shareUrl = isApp ? shareUrl +
'?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' +
shareUrl + '"}}' : shareUrl;
return result.data;
} else {
return {};
... ...
... ... @@ -42,11 +42,11 @@
<p>友情提示:返利订单确认收货后7天无退货,对应金额的有货币将
会发放至您的有货账户!
</p>
<p>有货币是什么?<a>了解详情</a></p>
<p>有货币是什么?<a href="{{currencyUrl}}">了解详情</a></p>
</div>
{{else}}
<a class="no-rebeat" href="//m.yohobuy.com/activity/share-buy">暂时没有相关返利信息,立即参与分享赢返利<i class="iconfont">&#xe614;</i></a>
<a class="no-rebeat" href="{{shareUrl}}">暂时没有相关返利信息,立即参与分享赢返利<i class="iconfont">&#xe614;</i></a>
{{/if}}
{{/ rebeatData}}
... ...
... ... @@ -30,8 +30,8 @@
</div>
<div class="tab">
<a>我的返利收益</a>
<a href="http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略">分享购攻略</a>
<a href="{{rebeatUrl}}">我的返利收益</a>
<a href="{{strategyUrl}}">分享购攻略</a>
</div>
</div>
... ...
... ... @@ -3,6 +3,9 @@
<div class="coupon-detail">
<div class="countdown">
<div class="title">距离活动时间还剩:</div>
{{#if finish}}
<span class="finish">活动已结束!</span>
{{else}}
<div class="activity-time" data-id="{{expiredTime}}">
<span></span>
<span></span>
... ... @@ -13,6 +16,7 @@
<span></span>
<span></span>
</div>
{{/if}}
</div>
<div class="coupon-info" data-id="{{couponId}}">
... ... @@ -22,8 +26,15 @@
<span>{{counum}}</span>
</div>
<span class="coupon-code">{{couponCode}}</span>
<span class="copy">复制</span>
<p class="share-way">(券码可直接分享给好友)
{{#if isApp}}
<a href='//m.yohobuy.com/?openby:yohobuy={"action":"go.copy","params":{"text":"{{couponCode}}"}}' class="copy">复制</a>
{{/if}}
<p class="share-way">
{{#if finish}}
<span class="failure">(劵码已失效)</span>
{{else}}
(券码可直接分享给好友)
{{/if}}
<span class="coupon-type">{{couponType}}<span>
</p>
</div>
... ...
... ... @@ -29,7 +29,7 @@ let shareData = {
imgUrl: 'http://img11.static.yhbimg.com/yhb-img01/2017/05/10/16/011568a808f9b10e098b6542d3a8cb3d6b.png'
};
require('common/share');
require('common/share')(shareData);
yoho.invokeMethod('set.shareInfo', shareData);
... ...
... ... @@ -25,6 +25,10 @@
background-color: #bb0218;
}
}
.finish {
font-size: 35px;
}
}
.coupon-info {
... ... @@ -77,6 +81,10 @@
font-size: 24px;
display: inline-block;
.failure {
color: #d0021b;
}
.coupon-type {
float: right;
}
... ...