我是靠谱客的博主 认真店员,这篇文章主要介绍生成订单核销二维码,扫码完成核销,现在分享给大家,希望可以做个参考。

需求:

  1. 用户端:根据用户支付成功的订单商品,生成核销二维码
  2. 店员端:扫描客户的二维码,获取二维码信息,验证判断二维码是否正确,根据二维码信息,获取用户 信息,完成核销功能

步骤

1.对用户订单号进行加密加钥处理
2.利用QRcode生成二维码
3.使用uni.scanCode获取二维码信息
4.对信息进行解密,判断是否正确

源码

导入qrcode.js
import qrCode from "../../common/weapp-qrcode.js";
对信息加密加钥,保存信息使用qrcode生成二维码

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
this.$refs.writeoff.open() let key = '13_9993wp_s#a52dx1p_'; //请勿随意修改 let data = key + this.UserInfo.member_id.toString(), width = 330 / 750 * wx.getSystemInfoSync().windowWidth, height = 330 / 750 * wx.getSystemInfoSync().windowWidth, code = new Buffer(data).toString('base64'); console.log('code', code) let QRcode = new qrCode('couponQrcode_0', { render: 'canvas', text: code, width: width, height: height, colorDark: "#000000", colorLight: "#ffffff", correctLevel: qrCode.CorrectLevel.H }) uni.hideTabBar({ animation: true }); setTimeout(() => { this.BillCode = true }, 390)

效果图请添加图片描述

扫码

对信息解密,判断二维码是否正确,

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
uni.scanCode({ onlyFromCamera: true, success: function(res) { setTimeout(() => { uni.hideLoading(); let data = res.result.toString(), MaskData = new Buffer(data, 'base64').toString('utf8'), arrayresult = MaskData.toString().split('_'); if (res.result.toString().length > 0 && arrayresult.length > 0 && arrayresult[2] === 's#a52dx1p') { let memberId = arrayresult[3] uni.navigateTo({ url: `../Mineday/billingCode?memberInfo=${memberId}` }) } else if (arrayresult[1] == 'Rts') { uni.showToast({ title: "请出示开单码", icon: "error", duration: 2500 }) } else { uni.showToast({ title: "二维码错误", icon: "error", duration: 2500 }) } }, 1000) }, fail: function(error) { setTimeout(() => { uni.hideLoading(); }, 20) }, complete: function(res) { uni.showLoading({ title: '识别中...', mask: true, }); }, })

最后

以上就是认真店员最近收集整理的关于生成订单核销二维码,扫码完成核销的全部内容,更多相关生成订单核销二维码内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(365)

评论列表共有 0 条评论

立即
投稿
返回
顶部