Authored by zzzzzzz

二维码调用接口

'use strict';
const crypto = global.yoho.crypto;
const model = require('../models/myqrcode');
exports.index = (req, res, next) => {
let params = req.query;
params.token = crypto.encryption('yoho9646yoho9646', JSON.stringify({
tk: params.token,
ct: Math.floor(Date.now()/1000),
}));
console.log(params.token);
console.log(crypto.decrypt('yoho9646yoho9646', params.token));
res.render('myqrcode', {
title: '查看二维码',
module: 'home',
page: 'myqrcode',
isPassportPage: true,
data: params,
});
model.getQr({
token: params.token,
}).then(result => {
params.token = result;
res.render('myqrcode', {
title: '查看二维码',
module: 'home',
page: 'myqrcode',
isPassportPage: true,
data: params,
});
}).catch(next);
};
... ...
"use strict";
'use strict';
const api = global.yoho.API;
exports.getQr = (params) => {
return api.get('', {
method: 'app.twoDimen.getCode',
uid: 1234,
uid: params.token,
}).then(result => {
return result;
return (result && result.date && result.data.code) || '';
});
}
\ No newline at end of file
};
... ...