基本信息
源码名称:<赞>微信小程序:扫描二维码/条形码
源码大小:0.04M
文件格式:.zip
开发语言:js
更新时间:2018-06-23
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
//index.js //获取应用实例 const app = getApp() // 扫描类型 const scanType = { 'WX_CODE': '微信小程序', 'QR_CODE': '二维码', 'EAN_8': '条形码(EAN_8)', 'EAN_13': '条形码(EAN_13)', 'UPC_A': '条形码(UPC_A)', 'UPC_E': '条形码(UPC_E)', 'CODE_25': '条形码(CODE_25)', 'CODE_39': '条形码(CODE_39)', 'CODE_128': '条形码(CODE_128)', } Page({ data: { scanResult: { isShow: false, type: '', text: '', msg: '', }, }, onLoad () { }, onScan () { wx.scanCode({ success: (res) => { console.log(res); let msg = ''; if (res.scanType === 'WX_CODE' && res.result === '') { msg = '宝宝心里苦,但宝宝不说...' } this.setData({ scanResult: { isShow: true, type: scanType[res.scanType], text: res.result, msg, }, }); // 存入Storage if (this.data.scanResult.text !== '') { wx.getStorage({ key: 'scanLogs', complete: (res) => { console.log(res); let scanLogs = res.data || []; this.data.scanResult.date = Date.now(); scanLogs.unshift(this.data.scanResult); wx.setStorageSync('scanLogs', scanLogs); } }) } } }) }, onCopy () { // 复制到剪贴板 wx.setClipboardData({ data: this.data.scanResult.text, success: function(res) { wx.showToast({ title: '复制成功', }) } }) }, })