Authored by zhangxiaoru

逻辑修改

... ... @@ -5,9 +5,10 @@ const shareBuyModel = require('../models/share-buy'),
exports.index = (req, res, next) => {
let activityId = req.query.activity_id || 2023,
isApp = req.yoho.isApp;
isApp = req.yoho.isApp,
uid = req.user.uid;
req.ctx(shareBuyModel).shareIndex(activityId, isApp).then(data => {
req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid).then(data => {
res.render('share-buy/share-buy', {
pageHeader: headerModel.setNav({
navTitle: '分享购'
... ... @@ -20,30 +21,25 @@ exports.index = (req, res, next) => {
newsFlash: data.newsFlash,
rebeatUrl: data.rebeatUrl,
strategyUrl: data.strategyUrl,
banner: data.banner
banner: data.banner,
isStudent: data.isStudent
});
}).catch(next);
};
exports.detail = (req, res, next) => {
let uid = req.user.uid,
param = {
let param = {
counum: req.query.counum,
couponType: req.query.couponType,
detailDes: req.query.detailDes,
couponId: req.query.couponId
couponId: req.query.couponId,
useCode: req.query.useCode
},
isApp = req.yoho.isApp,
registerUrl;
if (isApp) {
registerUrl = 'http://m.yohobuy.com/activity/student/register?sharebuy=openbuy:yohobuy={"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}';
} else {
registerUrl = 'http://m.yohobuy.com/activity/student/register';
}
req.ctx(shareBuyModel).shareDetail(uid, param, isApp).then(data => {
req.ctx(shareBuyModel).shareDetail(param, isApp).then(data => {
res.render('share-buy/share-detail', {
pageHeader: headerModel.setNav({
... ...
... ... @@ -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;
}
... ...
... ... @@ -3,7 +3,7 @@
<img src="{{image banner 750 366}}"><img>
</div>
<div class="coupon-list">
<div class="coupon-list" data-student="{{isStudent}}">
{{# userCouponBoList}}
<div class="coupon-group">
<div class="coupon-left">
... ... @@ -14,7 +14,11 @@
<p class="coupon-type">{{shareCouponType}}</p>
</div>
<div class="coupon-right">
<a href="{{detailUrl}}">立即参与</a>
{{#if detailUrl}}
<a href="{{detailUrl}}" class="join">立即参与</a>
{{else}}
<span class="join">立即参与</span>
{{/if}}
<p class="coupon-mold">{{shareCoupon}}</p>
<p class="coupon-limit">{{couponDescribe}}</p>
</div>
... ...
<div class="share-detail-page" >
{{# detailData}}
<div class="coupon-detail" data-student="{{isStudent}}" data-app="{{isApp}}">
<div class="coupon-detail" data-app="{{isApp}}">
<div class="countdown">
<div class="title">距离活动时间还剩:</div>
{{#if finish}}
... ... @@ -62,11 +62,3 @@
</div>
{{/ detailData}}
</div>
{{#unless detailData.isStudent}}
<div class="share-dialog-tip">
<div class="tip-box">
<div class="tip-center">完成学生认证即可参与活动哦~</div>
<a class="tip-btn" href="{{registerUrl}}">去认证</a>
</div>
</div>
{{/unless}}
... ...
'use strict';
require('activity/share-buy.page.css');
let $ = require('yoho-jquery');
let $ = require('yoho-jquery'),
dialog = require('plugin/dialog'),
yoho = require('yoho-app');
let $news = $('.news'),
newsLiL = $news.find('li').length,
... ... @@ -38,3 +40,24 @@ if (newsLiL > 1) {
setInterval(Marquee, 100);
}
$('.join').click(function() {
if ($('.coupon-list').data('student') === false) {
dialog.showDialog({
dialogText: '完成学生认证即可参与活动哦~',
fast: true,
hasFooter: {
rightBtnText: '去认证'
}
}, function() {
if (yoho.isApp) {
location.href = 'http://m.yohobuy.com/activity/student/register' +
'?openbuy:yohobuy={"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}';
} else {
location.href = '//m.yohobuy.com/activity/student/register';
}
}, null, true);
}
});
... ...
... ... @@ -73,7 +73,7 @@
white-space: nowrap;
}
a {
.join {
float: right;
margin: 55px 35px 0 0;
display: block;
... ...