myqrcode.js
1.34 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
'use strict';
const _ = require('lodash');
const model = require('../models/myqrcode'),
headerModel = require('../../../doraemon/models/header'); // 头部model
exports.index = (req, res, next) => {
let params = req.query,
esc = false,
appversion = _.isArray(req.query.app_version) ? req.query.app_version[0] : req.query.app_version || '';
if (Number(appversion.substr(0, 1) < 5) ||
(Number(appversion.substr(0, 1)) === 5 && Number(appversion.substr(2, 1)) < 2)) {
esc = true;
}
let uname;
try {
uname = esc ? decodeURIComponent(params.uname) : decodeURIComponent(params.uname.replace(/\%/g, escape('%')));
} catch (e) {
uname = params.uname;
}
req.ctx(model).getQr({
token: params.token,
}).then(result => {
params.token = result;
params.uname = uname;
params.icon = params.icon || 'https://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png?imageView/2/w/{width}/h/{height}';
res.render('myqrcode', {
title: '查看二维码',
module: 'home',
page: 'myqrcode',
isPassportPage: true,
data: params,
pageHeader: headerModel.setNav({
navTitle: '查看二维码'
})
});
}).catch(next);
};