| | |
| | | // i-carbon-code |
| | | import { tabBar } from '@/pages.json' |
| | | import { tabbarStore } from './tabbar' |
| | | import qrcode from "@/utils/qrcode"; |
| | | |
| | | /** tabbarList 里面的 path 从 pages.config.ts 得到 */ |
| | | const tabbarList = tabBar.list.map((item) => ({ ...item, path: `/${item.pagePath}` })) |
| | |
| | | // }) |
| | | // return false |
| | | // 模拟成功 |
| | | const systemInfo = uni.getSystemInfoSync() |
| | | if (systemInfo.uniPlatform === 'app') { |
| | | // 只允许通过相机扫码 |
| | | uni.scanCode({ |
| | | onlyFromCamera: true, |
| | | success: function(res) { |
| | | console.log('条码类型:' + res.scanType) |
| | | console.log('条码内容:' + res.result) |
| | | if (res?.scanType !== 'QR_CODE') { |
| | | uni.showToast({ |
| | | title: '请使用二维码进行扫码', |
| | | icon: 'none', |
| | | }) |
| | | return false |
| | | } |
| | | |
| | | // 只允许通过相机扫码 |
| | | uni.scanCode({ |
| | | onlyFromCamera: true, |
| | | success: function (res) { |
| | | console.log('条码类型:' + res.scanType) |
| | | console.log('条码内容:' + res.result) |
| | | if (res?.scanType !== 'QR_CODE') { |
| | | uni.showToast({ |
| | | title: '请使用二维码进行扫码', |
| | | icon: 'none', |
| | | // 使用split方法截取资产编号 |
| | | // const assetCode = res.result.split('资产编号:')[1].split(' ')[0] |
| | | uni.navigateTo({ |
| | | url: `/pages/scan/index?result=${res.result}`, |
| | | }) |
| | | return false |
| | | } |
| | | |
| | | // 使用split方法截取资产编号 |
| | | // const assetCode = res.result.split('资产编号:')[1].split(' ')[0] |
| | | uni.navigateTo({ |
| | | url: `/pages/scan/index?result=${res.result}`, |
| | | }) |
| | | }, |
| | | fail: function (res) {}, |
| | | }) |
| | | }, |
| | | fail: function (res) {}, |
| | | }) |
| | | } else { |
| | | uni.chooseImage({ |
| | | count: 1, |
| | | sizeType: ['original', 'compressed'], |
| | | sourceType: ['camera'], |
| | | success: function(response) { |
| | | qrcode.decode(response.tempFilePaths[0]) |
| | | qrcode.callback = (res) => { |
| | | console.log('res', res) |
| | | if (res === 'error decoding QR Code') { |
| | | uni.showToast({ |
| | | title: '二维码解析失败', |
| | | duration: 2000, |
| | | icon: 'none', |
| | | }) |
| | | } else { |
| | | uni.navigateTo({ |
| | | url: `/pages/scan/index?result=${res}`, |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | }) |
| | | } |
| | | } else { |
| | | tabbarStore.setCurIdx(index) |
| | | tabbarStore.setLastIdx(index) |