qrcode.js
1.72 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
/**
* 个人中心二维码 controller
* @author: weiqingting<qingting.wei@yoho.cn>
* @date: 2016/05/16
*/
'use strict';
const QRcodeModel = require('../models/qrcode');
const helpers = global.yoho.helpers;
exports.QRcode = (req, res, next) => {
let id = req.query.orderCode || 0;
let bg={
'16-1':'//img13.static.yhbimg.com/yhb-img02/2016/07/28/14/02509790c87f7b26fc523fc81cdd2ee684.jpg',
'17-1':'//img13.static.yhbimg.com/yhb-img02/2016/07/28/14/02509790c87f7b26fc523fc81cdd2ee684.jpg',
'16-2':'//img13.static.yhbimg.com/yhb-img02/2016/07/28/14/0243ee8b76d1af13fe546b3538036ab3a9.jpg',
'17-2':'//img13.static.yhbimg.com/yhb-img02/2016/07/28/14/028d1fa99a0a22d882587aa0a309b41637.jpg'
}
let bgkey='16-1',ticktypeName='展览票';
QRcodeModel.getQRcodeData(id,req.user.uid).then((result)=>{
if (result) {
result.ticks = result.ticks.map(item=>{
if (+item.ticket_type === 2) {
item.isgroup = true;
}
return item;
});
if(result.ticks.length){
bgkey=[/月(\d+)/g.exec(result.ticks[0].entrance_time)[1],result.ticks[0].ticket_type].join('-');
ticktypeName=result.ticks[0].ticket_type==='2'?'套票':'展览票';
}
}
let vm = {
path: [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}, {name: '个人中心'},{name: '订单中心'}, {name: '查看二维码'}],
qrcodeData: result,
code: id,
bgsrc:bg[bgkey],
ticktypeName:ticktypeName,
returnOrder: helpers.urlFormat('/home/orders')
};
res.render('QRcode', vm);
}).catch(next);
};