Authored by lijing

开发完成

@@ -64,6 +64,10 @@ const logger = global.yoho.logger; @@ -64,6 +64,10 @@ const logger = global.yoho.logger;
64 64
65 // 访问域名层级 65 // 访问域名层级
66 app.set('subdomain offset', 3); 66 app.set('subdomain offset', 3);
  67 +
  68 +// 添加请求上下文
  69 +app.use(global.yoho.httpCtx());
  70 +
67 app.use(global.yoho.hbs({ 71 app.use(global.yoho.hbs({
68 extname: '.hbs', 72 extname: '.hbs',
69 defaultLayout: 'layout', 73 defaultLayout: 'layout',
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
5 5
6 'use strict'; 6 'use strict';
7 7
  8 +const birtdDayModel = require('../models/birthday');
  9 +
8 exports.index = (req, res) => { 10 exports.index = (req, res) => {
9 let responseData = { 11 let responseData = {
10 module: 'activity', 12 module: 'activity',
@@ -16,3 +18,9 @@ exports.index = (req, res) => { @@ -16,3 +18,9 @@ exports.index = (req, res) => {
16 18
17 res.render('birthday', responseData); 19 res.render('birthday', responseData);
18 }; 20 };
  21 +
  22 +exports.getCoupon = (req, res, next) => {
  23 + req.ctx(birtdDayModel).getCoupon({uid: req.user.uid}).then(data => {
  24 + res.json(data);
  25 + }).catch(next);
  26 +};
  1 +module.exports = class extends global.yoho.BaseModel {
  2 + constructor(ctx) {
  3 + super(ctx);
  4 + }
  5 +
  6 + getCoupon(params) {
  7 + let options = {
  8 + data: {
  9 + method: 'app.promotion.validateGetBirthCoupon',
  10 + uid: params.uid
  11 + },
  12 + param: {
  13 + code: 200
  14 + }
  15 + };
  16 +
  17 + return this.get(options).then(result => {
  18 + return result;
  19 + });
  20 + }
  21 +};
@@ -241,5 +241,6 @@ router.get('/app-downloads', appDownloads.index); @@ -241,5 +241,6 @@ router.get('/app-downloads', appDownloads.index);
241 router.get('/couponSend', couponFloor.couponSend); // 获取优惠券 241 router.get('/couponSend', couponFloor.couponSend); // 获取优惠券
242 242
243 router.get('/birthday', birthday.index); // 生日卷活动 243 router.get('/birthday', birthday.index); // 生日卷活动
  244 +router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态
244 245
245 module.exports = router; 246 module.exports = router;
@@ -17,9 +17,9 @@ @@ -17,9 +17,9 @@
17 <p class="foot-tip">温馨提示:同一用户一年内(365天)仅可以领取一次生日特惠哦!</p> 17 <p class="foot-tip">温馨提示:同一用户一年内(365天)仅可以领取一次生日特惠哦!</p>
18 <div class="dia-c"> 18 <div class="dia-c">
19 <div class="bg"></div> 19 <div class="bg"></div>
20 - <div class="dia dia-0"></div>  
21 - <div class="dia dia-1"></div>  
22 - <div class="dia dia-2"></div>  
23 - <div class="dia dia-3"></div> 20 + <div class="dia">
  21 + <p class="title"></p>
  22 + <p class="message"></p>
  23 + </div>
24 </div> 24 </div>
25 </div> 25 </div>
@@ -79,3 +79,20 @@ exports.pickCoupon = (req, res, next) => { @@ -79,3 +79,20 @@ exports.pickCoupon = (req, res, next) => {
79 res.end(); 79 res.end();
80 }).catch(next); 80 }).catch(next);
81 }; 81 };
  82 +
  83 +// 生日卷
  84 +exports.birthCoupon = (req, res, next) => {
  85 + let responseData = {
  86 + module: 'home',
  87 + page: 'message',
  88 + pageHeader: headerModel.setNav({
  89 + navTitle: '生日卷'
  90 + }),
  91 + title: '生日卷',
  92 + pageFooter: true
  93 + };
  94 +
  95 + model._getBirthCouponById(req.user.uid).then(result => {
  96 + res.render('birth-coupon', Object.assign(responseData, result));
  97 + }).catch(next);
  98 +};
@@ -55,9 +55,35 @@ const _getBirthCouponById = (uid) => { @@ -55,9 +55,35 @@ const _getBirthCouponById = (uid) => {
55 uid: uid, 55 uid: uid,
56 couponType: 4, 56 couponType: 4,
57 }).then(result => { 57 }).then(result => {
58 -  
59 if (result && result.data) { 58 if (result && result.data) {
60 - return result.data; 59 + let final = {
  60 + ticket: []
  61 + };
  62 +
  63 + final.birthType = true;
  64 + if (result.data.list && result.data.list[0].body.is_collar === 'Y') {
  65 + final = {
  66 + isCollar: true
  67 + };
  68 + } else {
  69 + if (result.data && !result.data[0].err) {
  70 + for (let coupon of result.data) {
  71 + final.ticket.push({
  72 + id: coupon.id ? coupon.id : '',
  73 + couponAmount: coupon.couponAmount,
  74 + couponName: coupon.couponName.split('-')[0],
  75 + startTime: _formatDay(coupon.startTime),
  76 + endTime: _formatDay(coupon.endTime),
  77 + useLimit: coupon.useLimit
  78 + });
  79 + }
  80 + } else {
  81 + final = {
  82 + err: result.data[0].err
  83 + };
  84 + }
  85 + }
  86 + return final;
61 } else { 87 } else {
62 if (result.code === 410) { 88 if (result.code === 410) {
63 return [{err: result.message}]; 89 return [{err: result.message}];
@@ -71,7 +97,7 @@ const _getBirthCouponById = (uid) => { @@ -71,7 +97,7 @@ const _getBirthCouponById = (uid) => {
71 }; 97 };
72 98
73 // 获取详情页 99 // 获取详情页
74 -const _detail = (result, id, couponData) => { 100 +const _detail = (result, id) => {
75 let final = {}; 101 let final = {};
76 102
77 if (result.data && result.data.list) { 103 if (result.data && result.data.list) {
@@ -83,49 +109,6 @@ const _detail = (result, id, couponData) => { @@ -83,49 +109,6 @@ const _detail = (result, id, couponData) => {
83 109
84 // 判断消息类型 110 // 判断消息类型
85 switch (item.type) { 111 switch (item.type) {
86 - case 'pullCoupon':  
87 - final = {  
88 - ticket: []  
89 - };  
90 - final.birthType = true;  
91 -  
92 - if (result.data.list[0].body.is_collar === 'Y') {  
93 -  
94 - final = {  
95 - isCollar: true  
96 - };  
97 -  
98 - } else {  
99 - if (couponData && !couponData[0].err) {  
100 - for (let coupon of couponData) {  
101 - final.ticket.push({  
102 - id: coupon.id ? coupon.id : '',  
103 - couponAmount: coupon.couponAmount,  
104 - couponName: coupon.couponName.split('-')[0],  
105 - startTime: _formatDay(coupon.startTime),  
106 - endTime: _formatDay(coupon.endTime),  
107 - useLimit: coupon.useLimit  
108 - });  
109 - }  
110 - } else {  
111 - final = {  
112 - err: couponData[0].err  
113 - };  
114 - }  
115 - }  
116 -  
117 - // 领取生日券消息  
118 - // final.coupons = [];  
119 - // for (let coupon of couponData) {  
120 - // final.coupons.push({  
121 - // id: coupon.id ? coupon.id : '',  
122 - // remark: coupon.couponName ? coupon.couponName : '',  
123 - // useTime: item.body.use_time ? item.body.use_time : '',  
124 - // pickTime: item.body.collar_time ? item.body.collar_time : '',  
125 - // canPick: true  
126 - // });  
127 - // }  
128 - break;  
129 case 'button': 112 case 'button':
130 // 促销活动 113 // 促销活动
131 if (item.body) { 114 if (item.body) {
@@ -175,9 +158,7 @@ const getList = (params) => { @@ -175,9 +158,7 @@ const getList = (params) => {
175 }).then(result => { 158 }).then(result => {
176 if (params.msgid) { 159 if (params.msgid) {
177 // 绕的一比 160 // 绕的一比
178 - return _getBirthCouponById(params.uid).then(couponData => {  
179 - return _detail(result, params.msgid, couponData);  
180 - }); 161 + return _detail(result, params.msgid);
181 } else { 162 } else {
182 return _list(result); 163 return _list(result);
183 } 164 }
@@ -228,4 +209,5 @@ module.exports = { @@ -228,4 +209,5 @@ module.exports = {
228 getList, 209 getList,
229 delMsg, 210 delMsg,
230 pickCoupon, 211 pickCoupon,
  212 + _getBirthCouponById
231 }; 213 };
@@ -99,6 +99,9 @@ router.get('/messageDetail', auth, message.index); @@ -99,6 +99,9 @@ router.get('/messageDetail', auth, message.index);
99 router.post('/ajaxDelMes', auth, message.ajaxDelMes); 99 router.post('/ajaxDelMes', auth, message.ajaxDelMes);
100 router.post('/pickCoupon', auth, message.pickCoupon); 100 router.post('/pickCoupon', auth, message.pickCoupon);
101 101
  102 +// 生日卷消息
  103 +router.get('/birthCoupon', auth, message.birthCoupon);
  104 +
102 // 在线客服 105 // 在线客服
103 router.get('/onlineservice', onlineService.getOnlineServiceInfo); 106 router.get('/onlineservice', onlineService.getOnlineServiceInfo);
104 router.get('/onlineservicedetail', onlineService.getOnlineServiceDetail); 107 router.get('/onlineservicedetail', onlineService.getOnlineServiceDetail);
  1 +<div class="massage-page yoho-page">
  2 + {{#if err}}
  3 + <div class="err">{{err}}</div>
  4 + {{else}}
  5 + <div class="birth-type-c">
  6 + <div class="title">以下优惠券任选其一</span></div>
  7 + <div class="ticket-list">
  8 + {{#ticket}}
  9 + <div class="ticket">
  10 + <div class="left">
  11 + <span>¥</span>
  12 + <div>{{couponAmount}}</div>
  13 + </div>
  14 + <div class="right">
  15 + <p class="first">{{couponName}}</p>
  16 + <p>{{startTime}}&nbsp-&nbsp{{endTime}}</p>
  17 + </div>
  18 + <a class="btn" data-id="{{id}}"></a>
  19 + </div>
  20 + {{/ticket}}
  21 + </div>
  22 + </div>
  23 + {{/if}}
  24 +</div>
@@ -2,25 +2,6 @@ @@ -2,25 +2,6 @@
2 {{#info}} 2 {{#info}}
3 {{#if err}} 3 {{#if err}}
4 <div class="err">{{err}}</div> 4 <div class="err">{{err}}</div>
5 - {{else if birthType}}  
6 - <div class="birth-type-c">  
7 - <div class="title">以下优惠券任选其一</span></div>  
8 - <div class="ticket-list">  
9 - {{#ticket}}  
10 - <div class="ticket">  
11 - <div class="left">  
12 - <span>¥</span>  
13 - <div>{{couponAmount}}</div>  
14 - </div>  
15 - <div class="right">  
16 - <p class="first">{{couponName}}</p>  
17 - <p>{{startTime}}&nbsp-&nbsp{{endTime}}</p>  
18 - </div>  
19 - <a class="btn" data-id="{{id}}"></a>  
20 - </div>  
21 - {{/ticket}}  
22 - </div>  
23 - </div>  
24 {{else}} 5 {{else}}
25 <div class="massage-main"> 6 <div class="massage-main">
26 <h6>{{title}}Yoho!Buy有货 | 潮流购物逛不停</h6> 7 <h6>{{title}}Yoho!Buy有货 | 潮流购物逛不停</h6>
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 {{else if isCollar}} 24 {{else if isCollar}}
25 <a class="disable">已领取</a> 25 <a class="disable">已领取</a>
26 {{else}} 26 {{else}}
27 - <a href="//m.yohobuy.com/home/messageDetail?id={{id}}">立即领取</a> 27 + <a href="//m.yohobuy.com/home/birthCoupon">立即领取</a>
28 {{/if}} 28 {{/if}}
29 </div> 29 </div>
30 </div> 30 </div>
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.6.2", 3 + "version": "5.7.0",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 "body-parser": "^1.16.1", 26 "body-parser": "^1.16.1",
27 "captchapng": "0.0.1", 27 "captchapng": "0.0.1",
28 "cheerio": "^0.22.0", 28 "cheerio": "^0.22.0",
29 - "client-sessions": "^0.7.0", 29 + "client-sessions": "^0.8.0",
30 "compression": "^1.6.2", 30 "compression": "^1.6.2",
31 "connect-memcached": "^0.2.0", 31 "connect-memcached": "^0.2.0",
32 "connect-multiparty": "^2.0.0", 32 "connect-multiparty": "^2.0.0",
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 "lodash": "^4.17.4", 37 "lodash": "^4.17.4",
38 "memory-cache": "^0.1.6", 38 "memory-cache": "^0.1.6",
39 "moment": "^2.18.1", 39 "moment": "^2.18.1",
40 - "oneapm": "^1.2.20", 40 + "oneapm": "^2.0.0",
41 "passport": "^0.3.2", 41 "passport": "^0.3.2",
42 "passport-local": "^1.0.0", 42 "passport-local": "^1.0.0",
43 "passport-qq": "0.0.3", 43 "passport-qq": "0.0.3",
@@ -45,20 +45,20 @@ @@ -45,20 +45,20 @@
45 "passport-strategy": "^1.0.0", 45 "passport-strategy": "^1.0.0",
46 "passport-weixin": "^0.1.0", 46 "passport-weixin": "^0.1.0",
47 "request": "^2.81.0", 47 "request": "^2.81.0",
48 - "request-promise": "^3.0.0", 48 + "request-promise": "^4.2.0",
49 "uuid": "^3.0.1", 49 "uuid": "^3.0.1",
50 "xml2js": "^0.4.17", 50 "xml2js": "^0.4.17",
51 "yoho-express-session": "^2.0.0", 51 "yoho-express-session": "^2.0.0",
52 "yoho-md5": "^2.0.0", 52 "yoho-md5": "^2.0.0",
53 - "yoho-node-lib": "0.2.23", 53 + "yoho-node-lib": "=0.2.25",
54 "yoho-zookeeper": "^1.0.8" 54 "yoho-zookeeper": "^1.0.8"
55 }, 55 },
56 "devDependencies": { 56 "devDependencies": {
57 "autoprefixer": "^6.7.4", 57 "autoprefixer": "^6.7.4",
58 "babel-core": "^6.24.1", 58 "babel-core": "^6.24.1",
59 - "babel-loader": "^6.4.1", 59 + "babel-loader": "^7.0.0",
60 "babel-polyfill": "^6.23.0", 60 "babel-polyfill": "^6.23.0",
61 - "babel-preset-env": "^1.3.3", 61 + "babel-preset-env": "^1.4.0",
62 "css-loader": "^0.28.0", 62 "css-loader": "^0.28.0",
63 "cssnano": "^3.10.0", 63 "cssnano": "^3.10.0",
64 "eslint": "^3.19.0", 64 "eslint": "^3.19.0",
@@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
66 "eslint-loader": "^1.7.1", 66 "eslint-loader": "^1.7.1",
67 "eslint-plugin-html": "^2.0.1", 67 "eslint-plugin-html": "^2.0.1",
68 "extract-text-webpack-plugin": "^2.1.0", 68 "extract-text-webpack-plugin": "^2.1.0",
69 - "handlebars-loader": "^1.4.0", 69 + "handlebars-loader": "^1.5.0",
70 "happypack": "^3.0.3", 70 "happypack": "^3.0.3",
71 "husky": "^0.13.3", 71 "husky": "^0.13.3",
72 "nodemon": "^1.11.0", 72 "nodemon": "^1.11.0",
@@ -78,24 +78,24 @@ @@ -78,24 +78,24 @@
78 "postcss-import": "^9.1.0", 78 "postcss-import": "^9.1.0",
79 "postcss-loader": "^1.3.1", 79 "postcss-loader": "^1.3.1",
80 "postcss-position": "^0.5.0", 80 "postcss-position": "^0.5.0",
81 - "postcss-pxtorem": "^4.0.0", 81 + "postcss-pxtorem": "^4.0.1",
82 "postcss-scss": "^0.4.1", 82 "postcss-scss": "^0.4.1",
83 "postcss-short": "^3.0.3", 83 "postcss-short": "^3.0.3",
84 - "postcss-sprites": "^4.2.0", 84 + "postcss-sprites": "^4.2.1",
85 "postcss-use": "^2.3.0", 85 "postcss-use": "^2.3.0",
86 "precss": "^1.4.0", 86 "precss": "^1.4.0",
87 "shelljs": "^0.7.6", 87 "shelljs": "^0.7.6",
88 - "style-loader": "^0.16.1", 88 + "style-loader": "^0.17.0",
89 "stylelint": "^7.10.1", 89 "stylelint": "^7.10.1",
90 "stylelint-config-yoho": "^1.2.8", 90 "stylelint-config-yoho": "^1.2.8",
91 "stylelint-formatter-table": "^1.0.2", 91 "stylelint-formatter-table": "^1.0.2",
92 "stylelint-processor-html": "^1.0.0", 92 "stylelint-processor-html": "^1.0.0",
93 "stylelint-webpack-plugin": "^0.7.0", 93 "stylelint-webpack-plugin": "^0.7.0",
94 - "vue": "^2.2.6",  
95 - "vue-loader": "^11.3.4",  
96 - "vue-template-compiler": "^2.2.6",  
97 - "webpack": "^2.3.3",  
98 - "webpack-dev-server": "^2.4.2", 94 + "vue": "^2.3.0",
  95 + "vue-loader": "^12.0.2",
  96 + "vue-template-compiler": "^2.3.0",
  97 + "webpack": "^2.4.1",
  98 + "webpack-dev-server": "^2.4.5",
99 "webpack-uglify-parallel": "^0.1.3", 99 "webpack-uglify-parallel": "^0.1.3",
100 "yoho-cookie": "^1.2.0", 100 "yoho-cookie": "^1.2.0",
101 "yoho-fastclick": "^1.0.6", 101 "yoho-fastclick": "^1.0.6",
@@ -27,7 +27,7 @@ _.mergeWith(baseConfig, { @@ -27,7 +27,7 @@ _.mergeWith(baseConfig, {
27 }] 27 }]
28 }, 28 },
29 devServer: { 29 devServer: {
30 - host: '0.0.0.0', 30 + host: devInfo.host,
31 port: devInfo.port, 31 port: devInfo.port,
32 publicPath: devInfo.publicPath, 32 publicPath: devInfo.publicPath,
33 contentBase: [path.join(__dirname, './bundle/'), path.join(__dirname, '../')], 33 contentBase: [path.join(__dirname, './bundle/'), path.join(__dirname, '../')],
@@ -2,6 +2,8 @@ import { @@ -2,6 +2,8 @@ import {
2 View 2 View
3 } from 'yoho-mvc'; 3 } from 'yoho-mvc';
4 4
  5 +let tip = require('plugin/tip');
  6 +
5 class Init extends View { 7 class Init extends View {
6 winHeight(obj) { 8 winHeight(obj) {
7 obj.css('min-height', $(window).height() + 'px'); 9 obj.css('min-height', $(window).height() + 'px');
@@ -11,34 +13,61 @@ class Init extends View { @@ -11,34 +13,61 @@ class Init extends View {
11 class Dialog extends View { 13 class Dialog extends View {
12 getClick() { 14 getClick() {
13 this.diaObj = $('.dia-c'); 15 this.diaObj = $('.dia-c');
14 - this.index = this.getAjax();  
15 16
16 $('.birthday-c .btn').on('click', () => { 17 $('.birthday-c .btn').on('click', () => {
17 - this.show(this.diaObj, this.index); 18 + this.couponObj = this.getAjax();
  19 + this.show(this.diaObj, this.couponObj);
18 }); 20 });
19 21
20 $(document).on('touchend touchcancel', '.dia .close', () => { 22 $(document).on('touchend touchcancel', '.dia .close', () => {
21 - this.hide(this.diaObj, this.index); 23 + this.hide(this.diaObj);
22 }); 24 });
23 } 25 }
24 26
25 - show(obj, num) { 27 + show(obj, message) {
  28 + if (message && message.support === 'Y') {
  29 + location.href = '//m.yohobuy.com/home/birthCoupon';
  30 + } else {
  31 + if (message && message.num === 1) {
  32 + obj.addClass('small');
  33 + }
26 obj.find('.bg').show(); 34 obj.find('.bg').show();
27 - this.thisObj = obj.find('.dia:eq(' + num + ')'); 35 + this.thisObj = obj.find('.dia');
28 this.thisObj.append('<span class="close"></span>'); 36 this.thisObj.append('<span class="close"></span>');
  37 + this.thisObj.find('.title').text(message.title);
  38 + this.thisObj.find('.message').text(message.message);
29 this.thisObj.show(); 39 this.thisObj.show();
30 } 40 }
  41 + }
31 42
32 - hide(obj, num) { 43 + hide(obj) {
33 obj.find('.bg').hide(); 44 obj.find('.bg').hide();
34 - this.thisObj = obj.find('.dia:eq(' + num + ')'); 45 + this.thisObj = obj.find('.dia');
35 $('.close').remove(); 46 $('.close').remove();
36 this.thisObj.hide(); 47 this.thisObj.hide();
37 } 48 }
38 49
39 getAjax() { 50 getAjax() {
40 - this.index = 3;  
41 - return this.index; 51 + let diaobj = {};
  52 +
  53 + $.ajax({
  54 + url: '/activity/getCoupon',
  55 + async: false,
  56 + success: function(result) {
  57 + if (result && result.data && result.code === 200) {
  58 + diaobj.num = parseInt(result.data.not_support_reasons, 10);
  59 + diaobj.message = result.data.not_support_reasons_message;
  60 + diaobj.title = result.data.not_support_reasons_title;
  61 + diaobj.support = result.data.is_support;
  62 + } else {
  63 + tip.show('网络异常!');
  64 + }
  65 + },
  66 + error: function() {
  67 + tip.show('网络异常!');
  68 + }
  69 + });
  70 + return diaobj;
42 } 71 }
43 } 72 }
44 73
@@ -78,6 +78,7 @@ @@ -78,6 +78,7 @@
78 left: 50%; 78 left: 50%;
79 margin-top: -338px; 79 margin-top: -338px;
80 margin-left: -325px; 80 margin-left: -325px;
  81 + background-image: resolve("activity/birthday/dia.png");
81 82
82 .close { 83 .close {
83 width: 40px; 84 width: 40px;
@@ -87,22 +88,38 @@ @@ -87,22 +88,38 @@
87 top: 58px; 88 top: 58px;
88 right: 11px; 89 right: 11px;
89 } 90 }
90 - }  
91 91
92 - .dia-0 {  
93 - background-image: resolve("activity/birthday/dia-0.png"); 92 + .title {
  93 + text-align: center;
  94 + color: #fff;
  95 + font-size: 50px;
  96 + line-height: 80px;
  97 + font-weight: bold;
  98 + margin-top: 290px;
  99 + text-shadow: 0 0 20px #f9e071;
94 } 100 }
95 101
96 - .dia-1 {  
97 - background-image: resolve("activity/birthday/dia-0.png"); 102 + .message {
  103 + text-align: center;
  104 + color: #fff;
  105 + font-size: 50px;
  106 + line-height: 80px;
  107 + font-weight: bold;
  108 + text-shadow: 0 0 20px #f9e071;
  109 + }
  110 + }
98 } 111 }
99 112
100 - .dia-2 {  
101 - background-image: resolve("activity/birthday/dia-0.png"); 113 + .dia-c.small {
  114 + .title {
  115 + font-size: 37px;
  116 + line-height: 50px;
  117 + margin-top: 325px;
102 } 118 }
103 119
104 - .dia-3 {  
105 - background-image: resolve("activity/birthday/dia-0.png"); 120 + .message {
  121 + font-size: 23px;
  122 + line-height: 50px;
106 } 123 }
107 } 124 }
108 } 125 }