Authored by 毕凯

Merge branch 'feature/birthdayAct' into 'release/5.7'

Feature/birthday act



See merge request !535
... ... @@ -64,6 +64,10 @@ const logger = global.yoho.logger;
// 访问域名层级
app.set('subdomain offset', 3);
// 添加请求上下文
app.use(global.yoho.httpCtx());
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
... ...
/**
* @author: jing.li@yoho.cn
* @date: 2017/04/24
*/
'use strict';
const birtdDayModel = require('../models/birthday');
exports.index = (req, res) => {
let responseData = {
module: 'activity',
page: 'birthday',
title: '生日卷',
width750: true,
localCss: true
};
res.render('birthday', responseData);
};
exports.getCoupon = (req, res, next) => {
req.ctx(birtdDayModel).getCoupon({uid: req.user.uid}).then(data => {
res.json(data);
}).catch(next);
};
... ...
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getCoupon(params) {
let options = {
data: {
method: 'app.promotion.validateGetBirthCoupon',
uid: params.uid
},
param: {
code: 200
}
};
return this.get(options).then(result => {
return result;
});
}
};
... ...
... ... @@ -43,6 +43,8 @@ const appDownloads = require(`${cRoot}/app-downloads`);
const redbag = require(`${cRoot}/redbag`);
const annualAccount = require(`${cRoot}/annual-account`);
const birthday = require(`${cRoot}/birthday`);
// routers
router.get('/demo', demo.index);
... ... @@ -239,4 +241,7 @@ router.get('/app-downloads', appDownloads.index);
router.get('/couponSend', couponFloor.couponSend); // 获取优惠券
router.get('/birthday', auth, birthday.index); // 生日卷活动
router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态
module.exports = router;
... ...
<div class="birthday-c">
<a class="btn"></a>
<div class="rule clearfix">
<div class="rule-item">
<div>领取时间:</div>
<div>生日当月可领取,以您个人信息填写的生日为准。</div>
</div>
<div class="rule-item">
<div>领取详情:</div>
<div>生日卷领取之日起16日内有效,过期不补偿,领取后请尽快使用。</div>
</div>
<div class="rule-item">
<div>领取资格:</div>
<div>您在领取时,必须是有货VIP银卡、金卡、白金卡用户,<a href="//m.yohobuy.com/home/grade">(了解您当前的VIP级别)</a>,且在个人信息中已完善生日信息<a href="//m.yohobuy.com/home/mydetails">(查看/完善个人信息)</a></div>
</div>
</div>
<p class="foot-tip">温馨提示:同一用户一年内(365天)仅可以领取一次生日特惠哦!</p>
<div class="dia-c">
<div class="bg"></div>
<div class="dia">
<p class="title"></p>
<p class="message"></p>
</div>
</div>
</div>
... ...
... ... @@ -184,7 +184,8 @@ exports.grade = (req, res, next) => {
module: 'home',
page: 'grade',
title: '会员等级',
pageFooter: true
pageFooter: true,
width750: true
};
let param = {
... ... @@ -216,7 +217,8 @@ exports.preferential = (req, res, next) => {
module: 'home',
page: 'grade',
title: '会员特权详情',
pageFooter: true
pageFooter: true,
width750: true
};
let param = {
... ...
... ... @@ -79,3 +79,20 @@ exports.pickCoupon = (req, res, next) => {
res.end();
}).catch(next);
};
// 生日卷
exports.birthCoupon = (req, res, next) => {
let responseData = {
module: 'home',
page: 'message',
pageHeader: headerModel.setNav({
navTitle: '生日卷'
}),
title: '生日卷',
pageFooter: true
};
model._getBirthCouponById(req.user.uid).then(result => {
res.render('birth-coupon', Object.assign(responseData, result));
}).catch(next);
};
... ...
... ... @@ -362,7 +362,8 @@ const getGrade = (param) => {
enp = {
description: val.description,
pic: val.pic,
title: val.title
title: val.title,
href: val.id === 8
};
obj.privilege.push(enp);
... ... @@ -461,7 +462,8 @@ const getPreferential = (params) => {
obj = {
description: val.description,
pic: val.pic,
title: val.title
title: val.title,
href: val.id === 8
};
resu.privilege.push(obj);
... ...
... ... @@ -55,9 +55,35 @@ const _getBirthCouponById = (uid) => {
uid: uid,
couponType: 4,
}).then(result => {
if (result && result.data) {
return result.data;
let final = {
ticket: []
};
final.birthType = true;
if (result.data.list && result.data.list[0].body.is_collar === 'Y') {
final = {
isCollar: true
};
} else {
if (result.data && !result.data[0].err) {
for (let coupon of result.data) {
final.ticket.push({
id: coupon.id ? coupon.id : '',
couponAmount: coupon.couponAmount,
couponName: coupon.couponName.split('-')[0],
startTime: _formatDay(coupon.startTime),
endTime: _formatDay(coupon.endTime),
useLimit: coupon.useLimit
});
}
} else {
final = {
err: result.data[0].err
};
}
}
return final;
} else {
if (result.code === 410) {
return [{err: result.message}];
... ... @@ -71,7 +97,7 @@ const _getBirthCouponById = (uid) => {
};
// 获取详情页
const _detail = (result, id, couponData) => {
const _detail = (result, id) => {
let final = {};
if (result.data && result.data.list) {
... ... @@ -83,49 +109,6 @@ const _detail = (result, id, couponData) => {
// 判断消息类型
switch (item.type) {
case 'pullCoupon':
final = {
ticket: []
};
final.birthType = true;
if (result.data.list[0].body.is_collar === 'Y') {
final = {
isCollar: true
};
} else {
if (couponData && !couponData[0].err) {
for (let coupon of couponData) {
final.ticket.push({
id: coupon.id ? coupon.id : '',
couponAmount: coupon.couponAmount,
couponName: coupon.couponName.split('-')[0],
startTime: _formatDay(coupon.startTime),
endTime: _formatDay(coupon.endTime),
useLimit: coupon.useLimit
});
}
} else {
final = {
err: couponData[0].err
};
}
}
// 领取生日券消息
// final.coupons = [];
// for (let coupon of couponData) {
// final.coupons.push({
// id: coupon.id ? coupon.id : '',
// remark: coupon.couponName ? coupon.couponName : '',
// useTime: item.body.use_time ? item.body.use_time : '',
// pickTime: item.body.collar_time ? item.body.collar_time : '',
// canPick: true
// });
// }
break;
case 'button':
// 促销活动
if (item.body) {
... ... @@ -175,9 +158,7 @@ const getList = (params) => {
}).then(result => {
if (params.msgid) {
// 绕的一比
return _getBirthCouponById(params.uid).then(couponData => {
return _detail(result, params.msgid, couponData);
});
return _detail(result, params.msgid);
} else {
return _list(result);
}
... ... @@ -228,4 +209,5 @@ module.exports = {
getList,
delMsg,
pickCoupon,
_getBirthCouponById
};
... ...
... ... @@ -99,6 +99,9 @@ router.get('/messageDetail', auth, message.index);
router.post('/ajaxDelMes', auth, message.ajaxDelMes);
router.post('/pickCoupon', auth, message.pickCoupon);
// 生日卷消息
router.get('/birthCoupon', auth, message.birthCoupon);
// 在线客服
router.get('/onlineservice', onlineService.getOnlineServiceInfo);
router.get('/onlineservicedetail', onlineService.getOnlineServiceDetail);
... ...
<div class="massage-page yoho-page">
{{#if err}}
<div class="err">{{err}}</div>
{{else}}
<div class="birth-type-c">
<div class="title">以下优惠券任选其一</span></div>
<div class="ticket-list">
{{#ticket}}
<div class="ticket">
<div class="left">
<span>¥</span>
<div>{{couponAmount}}</div>
</div>
<div class="right">
<p class="first">{{couponName}}</p>
<p>{{startTime}}&nbsp-&nbsp{{endTime}}</p>
</div>
<a class="btn" data-id="{{id}}"></a>
</div>
{{/ticket}}
</div>
</div>
{{/if}}
</div>
... ...
... ... @@ -2,25 +2,6 @@
{{#info}}
{{#if err}}
<div class="err">{{err}}</div>
{{else if birthType}}
<div class="birth-type-c">
<div class="title">以下优惠券任选其一</span></div>
<div class="ticket-list">
{{#ticket}}
<div class="ticket">
<div class="left">
<span>¥</span>
<div>{{couponAmount}}</div>
</div>
<div class="right">
<p class="first">{{couponName}}</p>
<p>{{startTime}}&nbsp-&nbsp{{endTime}}</p>
</div>
<a class="btn" data-id="{{id}}"></a>
</div>
{{/ticket}}
</div>
</div>
{{else}}
<div class="massage-main">
<h6>{{title}}Yoho!Buy有货 | 潮流购物逛不停</h6>
... ... @@ -77,4 +58,4 @@
{{/if}}
{{/if}}
{{/info}}
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -24,7 +24,7 @@
{{else if isCollar}}
<a class="disable">已领取</a>
{{else}}
<a href="//m.yohobuy.com/home/messageDetail?id={{id}}">立即领取</a>
<a href="//m.yohobuy.com/home/birthCoupon">立即领取</a>
{{/if}}
</div>
</div>
... ... @@ -37,4 +37,4 @@
{{else}}
<p style="text-align:center">您没有消息</p>
{{/if}}
</div>
\ No newline at end of file
</div>
... ...
<div class="vip-privilege-page yoho-page">
<ul class="privilege-list">
{{#each privilege}}
<li>
<img class="icon" src="{{pic}}">
<p>
{{title}}
<span>{{description}}</span>
</p>
</li>
{{/each}}
</ul>
</div>
\ No newline at end of file
<div class="privilege-list clearfix">
{{#each privilege}}
<a{{#if href}} href="//m.yohobuy.com/activity/birthday"{{/if}}>
<img class="icon" src="{{pic}}">
<p>
{{title}}
<span>{{description}}</span>
</p>
{{#if href}}
<span class="iconfont">&#xe604;</span>
{{/if}}
</a>
{{/each}}
</div>
</div>
... ...
<ul class="privilege-list">
<div class="privilege-list clearfix">
{{#each privilege}}
<li>
<a{{#if href}} href="//m.yohobuy.com/activity/birthday"{{/if}}>
<img class="icon" src="{{pic}}">
<p>
{{title}}
<span>{{description}}</span>
</p>
</li>
{{#if href}}
<span class="iconfont">&#xe604;</span>
{{/if}}
</a>
{{/each}}
</ul>
\ No newline at end of file
</div>
... ...
'use strict';
import {
Controller
} from 'yoho-mvc';
import {
Init,
Dialog
} from './view';
class BirthController extends Controller {
constructor() {
super();
this.init = new Init();
this.dialog = new Dialog();
this.winObj = $('.birthday-c');
this.init.winHeight(this.winObj);
this.dialog.getClick();
}
}
module.exports = BirthController;
... ...
require('activity/birthday/birthday.page.css');
const BirthController = require('./controller');
new BirthController();
... ...
let tip = require('plugin/tip');
let mvc = require('yoho-mvc');
class GetAjax {
getAjax() {
let diaobj = {};
let data = {
url: '/activity/getCoupon',
async: false
};
mvc.http(data).then(result => {
if (result && result.data && result.code === 200) {
diaobj.num = parseInt(result.data.not_support_reasons, 10);
diaobj.message = result.data.not_support_reasons_message;
diaobj.title = result.data.not_support_reasons_title;
diaobj.support = result.data.is_support;
} else {
tip.show('网络异常!');
}
}).catch(() => {
tip.show('网络断开了~~');
});
return diaobj;
}
}
export {
GetAjax
};
... ...
import {
View
} from 'yoho-mvc';
import {
GetAjax
} from './model';
class Init extends View {
constructor() {
super();
}
winHeight(obj) {
obj.css('min-height', $(window).height() + 'px');
}
}
class Dialog extends View {
constructor() {
super();
this.getAjax = new GetAjax();
}
getClick() {
this.diaObj = $('.dia-c');
$('.birthday-c .btn').on('click', () => {
this.couponObj = this.getAjax.getAjax();
this.show(this.diaObj, this.couponObj);
});
$(document).on('touchend touchcancel', '.dia .close', () => {
this.hide(this.diaObj);
});
}
show(obj, message) {
if (message && message.support === 'Y') {
location.href = '//m.yohobuy.com/home/birthCoupon';
} else {
if (message && message.num === 1) {
obj.addClass('small');
}
obj.find('.bg').show();
this.thisObj = obj.find('.dia');
this.thisObj.append('<span class="close"></span>');
this.thisObj.find('.title').text(message.title);
this.thisObj.find('.message').text(message.message);
this.thisObj.show();
}
}
hide(obj) {
obj.find('.bg').hide();
this.thisObj = obj.find('.dia');
$('.close').remove();
this.thisObj.hide();
}
}
export {
Init,
Dialog
};
... ...
.birthday-c {
background-image: resolve("activity/birthday/bg.jpg");
background-size: 100% auto;
background-repeat: no-repeat;
background-color: #c30d23;
background-position: center top;
position: relative;
padding-top: 536px;
min-height: 1100px;
.btn {
width: 500px;
height: 158px;
display: block;
margin: 0 auto;
}
.rule {
width: 600px;
margin: 90px auto 0;
.rule-item {
color: #fff;
font-size: 20px;
float: left;
line-height: 35px;
div {
&:nth-child(odd) {
float: left;
width: 120px;
}
&:nth-child(even) {
float: left;
width: 480px;
}
a {
font-size: 22px;
color: #fff;
text-decoration: underline;
}
}
}
}
.foot-tip {
font-size: 16px;
color: #231815;
text-decoration: underline;
padding: 60px 0 20px;
text-align: center;
line-height: 30px;
}
.dia-c {
.bg {
width: 100%;
height: 100%;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: #000;
opacity: 0.65;
display: none;
}
.dia {
display: none;
width: 650px;
height: 677px;
background-size: 100%;
position: absolute;
top: 50%;
left: 50%;
margin-top: -338px;
margin-left: -325px;
background-image: resolve("activity/birthday/dia.png");
.close {
width: 40px;
height: 40px;
display: block;
position: absolute;
top: 58px;
right: 11px;
}
.title {
text-align: center;
color: #fff;
font-size: 50px;
line-height: 80px;
font-weight: bold;
margin-top: 290px;
text-shadow: 0 0 20px #f9e071;
}
.message {
text-align: center;
color: #fff;
font-size: 50px;
line-height: 80px;
font-weight: bold;
text-shadow: 0 0 20px #f9e071;
}
}
}
.dia-c.small {
.title {
font-size: 37px;
line-height: 50px;
margin-top: 325px;
}
.message {
font-size: 23px;
line-height: 50px;
}
}
}
... ...
... ... @@ -176,13 +176,29 @@
height: 70px;
}
li {
a {
width: 690px;
clear: both;
float: left;
padding: 25px 0;
border-bottom: solid 1px #e5e5e5;
&:last-child {
border-bottom: 0;
}
.iconfont {
float: right;
line-height: 70px;
}
}
p {
font-size: 28px;
margin-left: 100px;
margin-left: 30px;
min-height: 70px;
width: 560px;
float: left;
}
span {
... ...