summer.js
5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var couponModel = require('../../models/coupon'),
urlFormat = require('../../util/url'),
cookie = require('../../util/cookie'),
errUtil = require('../../util/error'),
msgModel = require('../../models/message');
/**
* 夏季领券第一波
*/
exports.first = (req, res) => {
var renderData = {
layout: false, // 原有活动移植,忽略公有模板
module: 'coupon/summer-1',
title: 'YOHO!BUY有货【夏日新品节】',
isApp: req.isApp,
couponUrl: urlFormat('/home/coupons', null, 'default') + '?openby:yohobuy={"action":"go.coupon"}', // 个人中心优惠券
banner: {
img: 'http://img01.yohoboys.com/staticimg/2016/04/08/18/01261f3ab06fe49da541b8fef708ec6676.jpg?imageMogr2/quality/90',
url: 'http://feature.yoho.cn/0411/0411APPHOME/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"YOHO!BUY有货【夏日新品节】","url":"http://feature.yoho.cn/0411/0411APPHOME/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"386"},"param":{"share_id":"386"}}}'
},
weixinUrl: 'http://mp.weixin.qq.com/s?__biz=MjM5ODI5MDA4MA==&mid=201849402&idx=1&sn=c0089812f9769d82e0075f69d771f6e1#rd', // 微信关注地址
appUrl: 'http://www.yohoshow.com/about/index/yohobuyqr', // APP 下载地址
shareTitle: 'YOHO!BUY有货【夏日新品节】入夏风潮来袭!130元优惠券限时派送中~',
shareDesc: '夏日新品全线开售~更有夏品满减,折上最高直减¥100!',
shareImg: 'http://img01.yohoboys.com/staticimg/2016/04/08/18/010f90240883f1ee60ed831b5be477e52b.png',
shareLink: 'http://feature.yoho.cn/0411/0411APPHOME/index.html'
};
var uid = cookie.getUid(req);
var couponId = res.app.locals.proEnv ? '20455,20457,20459' : '12463,12461,12459';
renderData.activityId = res.app.locals.proEnv ? 564 : 499; // 正式活动ID 564
couponModel({
uid: uid,
couponId: couponId.split(',')
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponData.length && couponInfo.code === 200) {
// 发送站内信有问题
msgModel.sendSingleMessage({
uid: uid,
title: '【优惠券】您有3张夏日新品节优惠券。',
content: '尊敬的客户:恭喜您成功获得3张夏日新品节优惠券 !您可以在个人中心查看优惠券详情。'
});
}
return couponData;
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponInfo.code === 401) {
renderData.geted = true;
}
if (couponInfo.code !== 401 && couponInfo.code !== 200) {
renderData.fail = true;
}
res.render('coupon/summer/index', renderData); // 渲染页面
}).catch((err) => {
errUtil.webError(err, res); // 抓取 Promise 链的错误
});
};
/**
* 夏季领券第二波
*/
exports.second = (req, res) => {
var renderData = {
layout: false, // 原有活动移植,忽略公有模板
module: 'coupon/summer-2',
title: 'YOHO!BUY有货【夏日新品节】',
isApp: req.isApp,
couponUrl: urlFormat('/home/coupons', null, 'default') + '?openby:yohobuy={"action":"go.coupon"}', // 个人中心优惠券
banner: {
img: 'http://img02.yohoboys.com/staticimg/2016/04/15/15/0284b2808f07c969beaf3410711e77f510.jpg?imageMogr2/quality/90',
url: 'http://feature.yoho.cn/0418/0418APPHOME/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"YOHO!BUY有货【夏日新品节】", "url":"http://feature.yoho.cn/0418/0418APPHOME/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"386"},"param":{"share_id":"386"}}}'
},
weixinUrl: 'http://mp.weixin.qq.com/s?__biz=MjM5ODI5MDA4MA==&mid=201849402&idx=1&sn=c0089812f9769d82e0075f69d771f6e1#rd', // 微信关注地址
appUrl: 'http://www.yohoshow.com/about/index/yohobuyqr', // APP 下载地址
shareTitle: 'YOHO!BUY有货【夏日新品节】初夏新品全线首发!更有200元优惠券限时派送中~',
shareDesc: '1000+潮牌限时赠礼~更有初夏型品,2件8折!',
shareImg: 'http://img02.yohoboys.com/staticimg/2016/04/15/15/0284b2808f07c969beaf3410711e77f510.jpg',
shareLink: 'http://feature.yoho.cn/0418/0418APPHOME/index.html'
};
var uid = cookie.getUid(req);
var couponId = res.app.locals.proEnv ? '20989,20991,20993' : '12463,12461,12459';
renderData.activityId = res.app.locals.proEnv ? 580 : 499; // 正式活动 ID 580
couponModel({
uid: uid,
couponId: couponId.split(',')
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponData.length && couponInfo.code === 200) {
// 发送站内信有问题
msgModel.sendSingleMessage({
uid: uid,
title: '【优惠券】您有3张夏日新品节优惠券。',
content: '尊敬的客户:恭喜您成功获得3张夏日新品节优惠券 !您可以在个人中心查看优惠券详情。'
});
}
return couponData;
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponInfo.code === 401) {
renderData.geted = true;
}
if (couponInfo.code !== 401 && couponInfo.code !== 200) {
renderData.fail = true;
}
res.render('coupon/summer/index', renderData); // 渲染页面
}).catch((err) => {
errUtil.webError(err, res); // 抓取 Promise 链的错误
});
};