Commit d7141989 by 王昆

gsb

parent 7d150077
...@@ -51,6 +51,21 @@ class BpoSDPJApi { ...@@ -51,6 +51,21 @@ class BpoSDPJApi {
return o.toString().trim(); return o.toString().trim();
} }
async testqr(obj, req) {
let arr = [];
for (let i = 0; i < 20; i++) {
this.tttttt();
// let url = await this.qrClient.generateQR("https://bpohhr.gongsibao.com/sdpj?no=D6L0EoGg1wkzO5GEvm%2B9hA%3D%3D&outTradeNo=01234567891011121319&mchtId=1286935856342376450");
// arr.push(url);
}
return arr;
}
async tttttt() {
let url = await this.qrClient.generateQR("https://bpohhr.gongsibao.com/sdpj?no=D6L0EoGg1wkzO5GEvm%2B9hA%3D%3D&outTradeNo=01234567891011121319&mchtId=1286935856342376450");
console.log(url);
}
/** /**
* 生成二维码 * 生成二维码
* @param obj * @param obj
......
...@@ -6,6 +6,7 @@ const fs = require("fs"); ...@@ -6,6 +6,7 @@ const fs = require("fs");
class QrClient{ class QrClient{
constructor(){ constructor(){
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
this.ossClient = system.getObject("util.ossClient");
} }
/** /**
...@@ -20,20 +21,11 @@ class QrClient{ ...@@ -20,20 +21,11 @@ class QrClient{
return null; return null;
} }
let key = prev + await this.redisClient.genrateId("qrcode") + ".png"; let key = prev + await this.redisClient.genrateId("qrcode") + ".png";
let filePath = settings.localPath(); console.log(1, key);
var qr_png = qr.image(text, {size :10 }); let is = qr.imageSync(text, {type: 'png' ,size :10});
let _r = await qr_png.pipe(require('fs').createWriteStream(`${filePath}${key}`)); console.log(2);
console.log(_r); let urlRes = await this.ossClient.upfile(key, is);
if(!_r){ console.log(3, urlRes);
return null;
}
let urlRes = await new ossClient().upfile(key,`${filePath}${key}`);
fs.unlink(`${filePath}${key}`, (err) => {
if (err){
console.log(`二维码删除失败`);
}
console.log('已成功地删除文件');
});
return urlRes.url; return urlRes.url;
}catch (e) { }catch (e) {
console.log(e); console.log(e);
......
...@@ -35,9 +35,9 @@ var settings = { ...@@ -35,9 +35,9 @@ var settings = {
let rootPath = ""; let rootPath = "";
// windows // windows
if (platform.toLocaleLowerCase().startsWith('win')) { if (platform.toLocaleLowerCase().startsWith('win')) {
rootPath = "D:/tmp"; rootPath = "D:/tmp/";
} else { } else {
rootPath="/tmp" rootPath="/tmp/"
} }
return rootPath; return rootPath;
}, },
......
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