Authored by 毕凯

Merge remote-tracking branch 'origin/feature/shareBuy3'

... ... @@ -7,13 +7,9 @@ const shareBuyModel = require('../models/share-buy'),
exports.index = (req, res, next) => {
let activityId = req.query.act_id || 2023,
isApp = req.yoho.isApp,
uid = req.user.uid,
protocol = req.app.locals.isProduction ? 'https:' : 'http:';
co(function* () {
let isStudent = yield req.ctx(shareBuyModel).checkStudent(uid);
let indexData = yield req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid, isStudent, protocol);
uid = req.user.uid;
req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid).then(indexData => {
res.render('share-buy/share-buy', {
pageHeader: headerModel.setNav({
navTitle: '分享购'
... ... @@ -29,7 +25,7 @@ exports.index = (req, res, next) => {
banner: indexData.banner,
isStudent: indexData.isStudent
});
})().catch(next);
}).catch(next);
};
exports.detail = (req, res, next) => {
... ... @@ -73,3 +69,13 @@ exports.myRebeat = (req, res, next) => {
});
}).catch(next);
};
exports.getCouponCode = (req, res, next) => {
let uid = req.user.uid,
couponId = req.query.couponId,
protocol = req.app.locals.isProduction ? 'https:' : 'http:';
req.ctx(shareBuyModel).getCouponCode(uid, couponId, protocol).then(result => {
res.json(result);
})
};
... ...
... ... @@ -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) {
... ... @@ -39,22 +37,6 @@ module.exports = class extends global.yoho.BaseModel {
} else if (val.shareCoupon === '商品券') {
val.couponDescribe = '指定商品可用';
}
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 = '';
}
});
indexData.userCouponBoList = result[0].data.userCouponBoList;
... ... @@ -104,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) => {
... ... @@ -197,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;
});
}
... ...
... ... @@ -257,7 +257,7 @@ router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态
router.get('/share-buy', update('5.7.0'), auth, shareBuy.index); // 分享购首页
router.get('/share-buy/detail', update('5.7.0'), shareBuy.detail); // 分享购详情页
router.get('/share-buy/my-rebeat', update('5.7.0'), auth, shareBuy.myRebeat); // 我的返利
router.get('/share-buy/get-coupon-code', auth, shareBuy.getCouponCode); // 获取分享购券码
router.get('/user-recommend', userRecommend.index); // 广点通投放落地页
router.get('/user-recommend/moreGoods', userRecommend.moreGoods); // 获取商品分页
... ...
... ... @@ -16,11 +16,7 @@
<p class="coupon-type">{{shareCouponType}}</p>
</div>
<div class="coupon-right">
{{#if detailUrl}}
<a href="{{detailUrl}}" class="join">立即参与</a>
{{else}}
<span class="join">立即参与</span>
{{/if}}
<span class="join" data-id="{{couponId}}">立即参与</span>
<p class="coupon-mold">{{shareCoupon}}</p>
<p class="coupon-limit">{{couponDescribe}}</p>
</div>
... ...
... ... @@ -45,9 +45,9 @@ router.get('/index/new/jitDetail', authMW, order.jitDetail); // JIT 拆单配送
router.post('/index/add', indexController.add); // 加入购物车
router.get('/index/index', authMW, indexController.index); // 购物车 TODO: 删除
router.get('/index/index', indexController.index); // 购物车 TODO: 删除
router.get('/index/new', authMW, indexController.index); // 购物车(新版接口)
router.get('/index/new', indexController.index); // 购物车(新版接口)
router.post('/index/new/data', indexController.indexData); // 购物车
router.post('/index/new/select', indexController.select); // 选择取消购物车商品
router.post('/index/new/del', indexController.del); // 删除购物车商品
... ...
{
"name": "m-yohobuy-node",
"version": "5.9.12",
"version": "5.9.13",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -2,8 +2,8 @@
require('activity/share-buy.page.css');
let $ = require('yoho-jquery'),
dialog = require('plugin/dialog'),
yoho = require('yoho-app');
yoho = require('yoho-app'),
tip = require('plugin/tip');
let $news = $('.news'),
newsLiL = $news.find('li').length,
... ... @@ -58,17 +58,27 @@ if (newsLiL > 1) {
}
$('.join').click(function() {
if ($('.coupon-list').data('student') === false) {
dialog.showDialog({
dialogText: '完成学生认证即可参与活动哦~',
fast: true,
hasFooter: {
rightBtnText: '去认证'
$.ajax({
type: 'GET',
url: '/activity/share-buy/get-coupon-code',
data: {
couponId: $(this).data('id')
},
success: function(result) {
if (result.code === 200) {
let link = result.data.detailUrl;
if (yoho.isApp) {
link = result.data.protocol + link;
yoho.goH5(link);
} else {
window.location.href = link;
}
} else {
tip.show(result.message);
}
}, function() {
yoho.goH5('http://m.yohobuy.com/activity/student/register', '{"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}');
}, null, true);
}
}
});
});
... ...