coupon.js
2.9 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
'use strict';
const mRoot = '../models';
const library = '../../../library';
const couponModel = require(`${mRoot}/coupon`); // 领取优惠券 model
const log = require(`${library}/logger`);
exports.index = (req, res) => {
var renderData = {
module: 'coupon',
page: 'index',
appDownLoadLink: 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho'
},
ordercode = req.query.ordercode,
uid = req.query.uid,
mobile = req.query.mobile;
renderData.uid = uid;
renderData.mobile = mobile;
renderData.ordercode = ordercode;
// 测试假数据
// res.render('coupon', renderData); // 渲染页面
couponModel.getPageInfo({
ordercode: ordercode,
uid: uid
}).then((couponData) => {
if (couponData.code === 200) {
// 获取信息成功
couponData.ordercode = ordercode;
}
couponData.appDownLoadLink = renderData.appDownLoadLink;
res.render('coupon', {
result: couponData,
module: 'coupon',
page: 'index',
title: couponData.title
});
}).catch((err) => {
log.error('频道页面渲染错误:' + JSON.stringify(err));
});
};
exports.getCoupon = (req, res) => {
var renderData = {
module: 'coupon',
page: 'index'
};
var ordercode = req.query.ordercode,
mobile = req.query.mobile;
renderData.mobile = mobile;
renderData.ordercode = ordercode;
// //测试假数据
// res.render('coupon', renderData); // 渲染页面
couponModel.getCoupon({
ordercode: ordercode,
mobile: mobile
}).then((couponData) => {
if (couponData.code === 200) {
// 获取信息成功
couponData.ordercode = ordercode;
}
console.log(couponData);
res.json({
result: couponData
});
}).catch((err) => {
log.error('频道页面渲染错误:' + JSON.stringify(err));
});
};
exports.verify = (req, res) => {
var renderData = {
module: 'coupon',
page: 'index'
};
var ordercode = req.query.ordercode,
mobile = req.query.mobile,
identifycode = req.query.identifycode;
renderData.mobile = mobile;
renderData.ordercode = ordercode;
renderData.identifycode = identifycode;
// //测试假数据
// res.render('coupon', renderData); // 渲染页面
couponModel.registerAndSendCoupon({
ordercode: ordercode,
mobile: mobile,
identifycode: identifycode
}).then((couponData) => {
if (couponData.code === 200) {
// 获取信息成功
couponData.ordercode = ordercode;
}
console.log(couponData);
res.json({
result: couponData
});
}).catch((err) => {
log.error('频道页面渲染错误:' + JSON.stringify(err));
});
};