vue 中使用微信扫码功能

1.npm i weixin-jsapi
2.页面使用 import wx from ‘weixin-jsapi’ -S
3.页面一加载就配置一下
const res = await get(’/v2/oper/wechat/scan_sign’, { handleError: true })
前提是要从后台接口中拿相应的数据
wx.config({
debug: true,
appId: res.data.app_id, //appid
timestamp: res.data.timestamp, //时间戳
nonceStr: res.data.nonceStr, //随机字符串
signature: res.data.signature, //签名
jsApiList: [‘scanQRCode’],
})
4.扫码的时候
wx.scanQRCode({
needResult: 1,
scanType: [‘qrCode’, ‘barCode’],
success(res) {
const sn_url = res.resultStr
const len = sn_url.split(’/’).length
const sn_16 = sn_url.split(’/’)[len - 1]
// console.log(‘扫码返回-----’,sn_16);
that.getMachineSlotsInfo(sn_16, ‘sn_16’)
},
})

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值