| | |
| | | // 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, |
| | |
| | | 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) |
| | | uni.switchTab({ url }) |