1.微信扫一扫 (wx.scanCode)
<!-- wxml -->
<button bindtap="getQRCode">微信扫一扫</button>
<view>{{ scanCodeMsg }}</view>
// js
Page({
data:{
scanCodeMsg:''
},
getQRCode: function(){
var _this = this;
wx.scanCode({ //扫描API
success: function(res){
console.log('扫码成功',res); //输出回调信息
_this.setData({
scanCodeMsg: res.result
});
wx.showToast({
title: '成功',
duration: 2000
});
},
fail: function(err){
console.log('扫码失败',err);
}
})
}
})