uni-app保存图片至相册

	 		keepPic(){
				var that=this;
				uni.showLoading({
					title: '保存中',
				});
				var ws=null;
				ws=this.$mp.page.$getAppWebview();
				var bitmap=null;
			    bitmap = new plus.nativeObj.Bitmap('test');
					// 将webview内容绘制到Bitmap对象中
				ws.draw(bitmap,function(){
						console.log('截屏绘制图片成功');
						var bitmaps=plus.nativeObj.Bitmap.getItems();;
						console.log(JSON.stringify(bitmaps),'Bitmap对象中2');
						bitmap.save( "_doc/a.jpg",{},function(i){
							console.log('保存图片成功:'+JSON.stringify(i));		       		
						uni.saveImageToPhotosAlbum({
						    filePath: i.target,
						    success: function () {
						    bitmap.clear();
							setTimeout(()=>{
								uni.hideLoading();
								uni.showToast({
								 	title: "保存成功",
								 	icon: "none"
								 });
							 },2000)
						   },
						})	
	                }
					,function(e){
						console.log('保存图片失败:'+JSON.stringify(e));
				});	
				},function(e){
					console.log('截屏绘制图片失败:'+JSON.stringify(e));
				},{check:true,	// 设置为检测白屏
						clip:{top:'0',left:'0',height:'100%',width:'100%'}	// 设置截屏区域
				});
			},

你可能感兴趣的:(uni-app)