Authored by lijing

开发完成

... ... @@ -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',
... ...
... ... @@ -5,6 +5,8 @@
'use strict';
const birtdDayModel = require('../models/birthday');
exports.index = (req, res) => {
let responseData = {
module: 'activity',
... ... @@ -16,3 +18,9 @@ exports.index = (req, res) => {
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;
});
}
};
... ...
... ... @@ -241,5 +241,6 @@ router.get('/app-downloads', appDownloads.index);
router.get('/couponSend', couponFloor.couponSend); // 获取优惠券
router.get('/birthday', birthday.index); // 生日卷活动
router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态
module.exports = router;
... ...
... ... @@ -17,9 +17,9 @@
<p class="foot-tip">温馨提示:同一用户一年内(365天)仅可以领取一次生日特惠哦!</p>
<div class="dia-c">
<div class="bg"></div>
<div class="dia dia-0"></div>
<div class="dia dia-1"></div>
<div class="dia dia-2"></div>
<div class="dia dia-3"></div>
<div class="dia">
<p class="title"></p>
<p class="message"></p>
</div>
</div>
</div>
... ...
... ... @@ -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);
};
... ...
... ... @@ -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>
... ...
{
"name": "m-yohobuy-node",
"version": "5.6.2",
"version": "5.7.0",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -26,7 +26,7 @@
"body-parser": "^1.16.1",
"captchapng": "0.0.1",
"cheerio": "^0.22.0",
"client-sessions": "^0.7.0",
"client-sessions": "^0.8.0",
"compression": "^1.6.2",
"connect-memcached": "^0.2.0",
"connect-multiparty": "^2.0.0",
... ... @@ -37,7 +37,7 @@
"lodash": "^4.17.4",
"memory-cache": "^0.1.6",
"moment": "^2.18.1",
"oneapm": "^1.2.20",
"oneapm": "^2.0.0",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"passport-qq": "0.0.3",
... ... @@ -45,20 +45,20 @@
"passport-strategy": "^1.0.0",
"passport-weixin": "^0.1.0",
"request": "^2.81.0",
"request-promise": "^3.0.0",
"request-promise": "^4.2.0",
"uuid": "^3.0.1",
"xml2js": "^0.4.17",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "0.2.23",
"yoho-node-lib": "=0.2.25",
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
"autoprefixer": "^6.7.4",
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-loader": "^7.0.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.3.3",
"babel-preset-env": "^1.4.0",
"css-loader": "^0.28.0",
"cssnano": "^3.10.0",
"eslint": "^3.19.0",
... ... @@ -66,7 +66,7 @@
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^2.0.1",
"extract-text-webpack-plugin": "^2.1.0",
"handlebars-loader": "^1.4.0",
"handlebars-loader": "^1.5.0",
"happypack": "^3.0.3",
"husky": "^0.13.3",
"nodemon": "^1.11.0",
... ... @@ -78,24 +78,24 @@
"postcss-import": "^9.1.0",
"postcss-loader": "^1.3.1",
"postcss-position": "^0.5.0",
"postcss-pxtorem": "^4.0.0",
"postcss-pxtorem": "^4.0.1",
"postcss-scss": "^0.4.1",
"postcss-short": "^3.0.3",
"postcss-sprites": "^4.2.0",
"postcss-sprites": "^4.2.1",
"postcss-use": "^2.3.0",
"precss": "^1.4.0",
"shelljs": "^0.7.6",
"style-loader": "^0.16.1",
"style-loader": "^0.17.0",
"stylelint": "^7.10.1",
"stylelint-config-yoho": "^1.2.8",
"stylelint-formatter-table": "^1.0.2",
"stylelint-processor-html": "^1.0.0",
"stylelint-webpack-plugin": "^0.7.0",
"vue": "^2.2.6",
"vue-loader": "^11.3.4",
"vue-template-compiler": "^2.2.6",
"webpack": "^2.3.3",
"webpack-dev-server": "^2.4.2",
"vue": "^2.3.0",
"vue-loader": "^12.0.2",
"vue-template-compiler": "^2.3.0",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.5",
"webpack-uglify-parallel": "^0.1.3",
"yoho-cookie": "^1.2.0",
"yoho-fastclick": "^1.0.6",
... ...
... ... @@ -27,7 +27,7 @@ _.mergeWith(baseConfig, {
}]
},
devServer: {
host: '0.0.0.0',
host: devInfo.host,
port: devInfo.port,
publicPath: devInfo.publicPath,
contentBase: [path.join(__dirname, './bundle/'), path.join(__dirname, '../')],
... ...
... ... @@ -2,6 +2,8 @@ import {
View
} from 'yoho-mvc';
let tip = require('plugin/tip');
class Init extends View {
winHeight(obj) {
obj.css('min-height', $(window).height() + 'px');
... ... @@ -11,34 +13,61 @@ class Init extends View {
class Dialog extends View {
getClick() {
this.diaObj = $('.dia-c');
this.index = this.getAjax();
$('.birthday-c .btn').on('click', () => {
this.show(this.diaObj, this.index);
this.couponObj = this.getAjax();
this.show(this.diaObj, this.couponObj);
});
$(document).on('touchend touchcancel', '.dia .close', () => {
this.hide(this.diaObj, this.index);
this.hide(this.diaObj);
});
}
show(obj, num) {
obj.find('.bg').show();
this.thisObj = obj.find('.dia:eq(' + num + ')');
this.thisObj.append('<span class="close"></span>');
this.thisObj.show();
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, num) {
hide(obj) {
obj.find('.bg').hide();
this.thisObj = obj.find('.dia:eq(' + num + ')');
this.thisObj = obj.find('.dia');
$('.close').remove();
this.thisObj.hide();
}
getAjax() {
this.index = 3;
return this.index;
let diaobj = {};
$.ajax({
url: '/activity/getCoupon',
async: false,
success: function(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('网络异常!');
}
},
error: function() {
tip.show('网络异常!');
}
});
return diaobj;
}
}
... ...
... ... @@ -78,6 +78,7 @@
left: 50%;
margin-top: -338px;
margin-left: -325px;
background-image: resolve("activity/birthday/dia.png");
.close {
width: 40px;
... ... @@ -87,22 +88,38 @@
top: 58px;
right: 11px;
}
}
.dia-0 {
background-image: resolve("activity/birthday/dia-0.png");
}
.title {
text-align: center;
color: #fff;
font-size: 50px;
line-height: 80px;
font-weight: bold;
margin-top: 290px;
text-shadow: 0 0 20px #f9e071;
}
.dia-1 {
background-image: resolve("activity/birthday/dia-0.png");
.message {
text-align: center;
color: #fff;
font-size: 50px;
line-height: 80px;
font-weight: bold;
text-shadow: 0 0 20px #f9e071;
}
}
}
.dia-2 {
background-image: resolve("activity/birthday/dia-0.png");
.dia-c.small {
.title {
font-size: 37px;
line-height: 50px;
margin-top: 325px;
}
.dia-3 {
background-image: resolve("activity/birthday/dia-0.png");
.message {
font-size: 23px;
line-height: 50px;
}
}
}
... ...