Commit 659869c1 by Sweet Zhang

分享码确认无误时再来绘制

parent cf2fd5f2
...@@ -32,6 +32,19 @@ export class MkMaterialDetailComponent implements OnInit { ...@@ -32,6 +32,19 @@ export class MkMaterialDetailComponent implements OnInit {
}; };
// 发送请求保存分享码 // 发送请求保存分享码
this.shareCallBack(); this.shareCallBack();
}
download(canvas) {
const a = document.createElement('a');
// 设置地址
a.href = canvas.toDataURL('image/png', 1);
// 设置下载名称
a.download = '银盾保险经纪';
// 触发点击事件
a.click();
}
canvasPic() {
this.canvas.nativeElement.width = window.screen.width; this.canvas.nativeElement.width = window.screen.width;
this.canvas.nativeElement.height = window.screen.height; this.canvas.nativeElement.height = window.screen.height;
const canvas = this.canvas.nativeElement as HTMLCanvasElement; const canvas = this.canvas.nativeElement as HTMLCanvasElement;
...@@ -64,31 +77,26 @@ export class MkMaterialDetailComponent implements OnInit { ...@@ -64,31 +77,26 @@ export class MkMaterialDetailComponent implements OnInit {
// 绘制图像 就是绘制二维码到我们自己写的canvas中去 // 绘制图像 就是绘制二维码到我们自己写的canvas中去
ctx.drawImage(shareQr, this.canvas.nativeElement.width - 120, this.canvas.nativeElement.height - 125, 100, 100); ctx.drawImage(shareQr, this.canvas.nativeElement.width - 120, this.canvas.nativeElement.height - 125, 100, 100);
document.querySelector('#bannerImg').setAttribute('src', canvas.toDataURL('image/png', 1)); document.querySelector('#bannerImg').setAttribute('src', canvas.toDataURL('image/png', 1));
this.canvas.nativeElement.style.display = 'none';
}; };
// 绘制字体 // 绘制字体
ctx.font = '14px 微软雅黑'; ctx.font = '14px 微软雅黑';
ctx.fillStyle = '#081a71'; ctx.fillStyle = '#081a71';
ctx.fillText('长按了解详情', this.canvas.nativeElement.width - 115, this.canvas.nativeElement.height - 8); ctx.fillText('长按了解详情', this.canvas.nativeElement.width - 115, this.canvas.nativeElement.height - 8);
ctx.fillText(`银盾保险经纪 ${this.lifeCustomerInfo.practitionerBasicInfo.name}`, 15, this.canvas.nativeElement.height - 100); ctx.fillText(`银盾保险经纪 ${this.lifeCustomerInfo['practitionerBasicInfo']['name']}`, 15, this.canvas.nativeElement.height - 100);
ctx.fillText(`手机号:${this.lifeCustomerInfo.mobileNo}`, 15, this.canvas.nativeElement.height - 70); ctx.fillText(`手机号:${this.lifeCustomerInfo.mobileNo}`, 15, this.canvas.nativeElement.height - 70);
ctx.fillText('微信号:123456', 15, this.canvas.nativeElement.height - 40); ctx.fillText('微信号:123456', 15, this.canvas.nativeElement.height - 40);
}; };
} }
download(canvas) {
const a = document.createElement('a');
// 设置地址
a.href = canvas.toDataURL('image/png', 1);
// 设置下载名称
a.download = '银盾保险在线';
// 触发点击事件
a.click();
}
shareCallBack() { shareCallBack() {
this.myService.shareCallBack(this.shareInfo).subscribe(res => { this.myService.shareCallBack(this.shareInfo).subscribe(res => {
console.log(res); if (res['success']) {
}) this.canvasPic();
} else {
}
});
} }
} }
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