Commit 294ec89a by 王昆

Merge branch 'bpo-web' of gitlab.gongsibao.com:jiangyong/zhichan into bpo-web

parents 85d10e42 6e30de44
const qr = require("qr-image");
var settings = require("../../config/settings");
var ossClient = require("./ossClient");
const fs = require("fs");
class QrClient{
constructor(){
}
/**
* fn:生成二维码
* @return http连接 上传失败后返回null
* @param key
* @returns {Promise<void>}
*/
async generateQR(text){
try {
if(!text){
return null;
}
let key = "_"+new Date().getTime(), filePath = settings.localPath();
var qr_png = qr.image(text, {size :10 });
let _r = await qr_png.pipe(require('fs').createWriteStream(`${filePath}${key}.png`));
console.log(_r);
if(!_r){
return null;
}
let urlRes = await new ossClient().upfile(key,`${filePath}${key}.png`);
fs.unlink(`${filePath}${key}.png`, (err) => {
if (err){
console.log(`二维码删除失败`);
}
console.log('已成功地删除文件');
});
return urlRes.url;
}catch (e) {
console.log(e);
return null;
}
}
}
module.exports=QrClient;
\ No newline at end of file
...@@ -167,6 +167,9 @@ module.exports = function (app) { ...@@ -167,6 +167,9 @@ module.exports = function (app) {
req.url.indexOf("ecompanyCtl/findOne") > 0 || req.url.indexOf("ecompanyCtl/findOne") > 0 ||
req.url.indexOf("userCtl/updateSigner") > 0 || req.url.indexOf("userCtl/updateSigner") > 0 ||
req.url.indexOf("econtractCtl/genContract") > 0 || req.url.indexOf("econtractCtl/genContract") > 0 ||
req.url.indexOf("authCtl/test") > 0 ||
req.url.indexOf("getOssConfig") > 0) { req.url.indexOf("getOssConfig") > 0) {
// 韵达电子签免登陆, 因为它们牛逼闪闪的技术只会用iframe丢cookie // 韵达电子签免登陆, 因为它们牛逼闪闪的技术只会用iframe丢cookie
return next(); return next();
......
...@@ -29,6 +29,18 @@ var settings = { ...@@ -29,6 +29,18 @@ var settings = {
return "http://43.247.184.94:7200/"; return "http://43.247.184.94:7200/";
} }
}, },
localPath: function () {
var os = require("os");
let platform = os.platform() || "";
let rootPath = "";
// windows
if (platform.toLocaleLowerCase().startsWith('win')) {
rootPath = "C:\\Temp\\";
} else {
rootPath="/tmp"
}
return rootPath;
},
apiconfig: { apiconfig: {
AES: { AES: {
key: "qUPsMflPfgpPP1Ua", //密钥 key: "qUPsMflPfgpPP1Ua", //密钥
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment