admin管理员组

文章数量:1529449

在遇到二维码的页面的时候,需要用到点击二维码图片并保存在用户手机中,让用户在相册中找到这个二维码

在html中对图片添加点击事件


<view  @longpress="saveImg()">
	<image src="http://qcxj.funnyworking/static/imges/mine/Customer_Service.png" mode='widthFix' ></image>
/view>

在js中需要调用两个接口,第一个是用于下载图片的接口,第二是用于保存图片的接口

// 保存图片
		saveImg(w){
			console.log(w)
			uni.downloadFile({      //下载图片
				url:'http://qcxj.funnyworking/static/imges/mine/Customer_Service.png',
				success:(res)=>{
					console.log(res.tempFilePath)
					uni.saveImageToPhotosAlbum({     //将图片保存在手机
						filePath:res.tempFilePath,     //保存的位置
						success: (res) => {
							console.log(res)
							console.log('长按保存图片')
							
						}
					})
				}
			})
			
		},

就这样可以简单实现长按图片并保存的效果

 

其余功能之后更改。。。。。。。。。。。。。。

本文标签: 按下图片Uniapp