40 lines
785 B
Plaintext
40 lines
785 B
Plaintext
|
|
export type QrOpt = {
|
|
content:string,
|
|
logo?:string,
|
|
qrSize?:number,
|
|
logoW?:number,
|
|
logoH?:number,
|
|
marign?:number,
|
|
callback:(data:string)=>void
|
|
|
|
|
|
}
|
|
|
|
export function getQrData (opt:QrOpt):void{
|
|
console.log(opt.content)
|
|
if(opt.qrSize==null){
|
|
opt.qrSize=300;
|
|
}
|
|
|
|
if(opt.logo==null){
|
|
var b=QR.createQrCode(opt.content,opt.qrSize!.toInt());
|
|
console.log(b);
|
|
opt.callback("data:image/jpg;base64,"+b)
|
|
//return "data:image/jpg;base64,"+b;
|
|
}else{
|
|
var l=UTSiOS.getResourcePath(opt.logo!)
|
|
if(opt.logoW==null){
|
|
opt.logoW=50;
|
|
|
|
}
|
|
if(opt.logoH==null){
|
|
opt.logoH=50;
|
|
}
|
|
var b=QR.createQrCodeWithLogo(opt.content,opt.qrSize!.toInt(),l,opt.logoW!.toInt(),opt.logoH!.toInt());
|
|
console.log(b);
|
|
opt.callback("data:image/jpg;base64,"+b)
|
|
|
|
}
|
|
|
|
} |