繪制整個屏幕并保存到相冊
capture() { // 繪制圖片保存相冊
let _this = this;
let pages = getCurrentPages();
let page = pages[pages.length - 1];
let bitmap=null;
// #ifdef APP-PLUS
let currentWebview = page.$getAppWebview();
bitmap = new plus.nativeObj.Bitmap('amway_img');
// 將webview內(nèi)容繪制到Bitmap對象中
currentWebview.draw(bitmap,function(){
console.log('截屏繪制圖片成功');
// bitmap.save( "_doc/"+Math.random()+".jpg"
bitmap.save( "_doc/invite.jpg"
,{}
,function(i){
console.log('保存圖片成功:'+JSON.stringify(i));
uni.saveImageToPhotosAlbum({
filePath: i.target,
success: function () {
_this.imagePath = i.target
bitmap.clear(); //銷毀Bitmap圖片
uni.showToast({icon:'success',title: '保存成功',duration: 1500});
// uni.shareWithSystem({
// type:'image',
// imageUrl:_this.imagePath,
// success:(res)=>{
// // 分享完成矮台,請注意此時不一定是成功分享
// },
// fail:(err)=>{
// // 分享失敗
// }
// })
}
});
}
,function(e){
console.log('保存圖片失敗:'+JSON.stringify(e));
});
},function(e){
console.log('截屏繪制圖片失敗:'+JSON.stringify(e));
});
// #endif
//currentWebview.append(amway_bit);
},