小程序长按图片识别二维码

方案1:使用wx.previewImage识别 

✅ 识别小程序码 - ✅ 跳转小程序

✅ 识别群二维码 - ✅ 跳转到加群页面

✅ 识别名片二维码 - ✅ 跳转到加好友页面

❌ 识别小程序二维码

WXML:

<image src="https://img.demo.com/upload/images/qrcode.jpg" mode="widthFix"
 data-src="https://img.demo.com/upload/images/qrcode.jpg" bindtap="previewImage">
</image>

JS: 

previewImage: function(e) {
    var url = e.target.dataset.src;
    wx.previewImage({
      current: url,
      urls: [url]
    })
},

 方案2:使用web-view加载二维码

✅ 识别小程序码 - ✅ 跳转小程序

✅ 识别群二维码 - ✅ 跳转到加群页面

✅ 识别名片二维码 - ✅ 跳转到加好友页面

❌ 识别小程序二维码

HTML:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<img src="https://img.demo.com/upload/images/qrcode.jpg"></div>
	</body>
</html>

WXML:

<web-view src="https://www.demo.com/test.html"></web-view>

猜你喜欢

转载自blog.csdn.net/watson2017/article/details/119042578