车间能级提升-智能设备管理系统
eims-ui-mobile/src/components/fg-tabbar/fg-tabbar.vue
@@ -53,6 +53,7 @@
// 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}` }))
@@ -69,7 +70,8 @@
    // })
    // return false
    // 模拟成功
    const systemInfo = uni.getSystemInfoSync()
    if (systemInfo.uniPlatform === 'app') {
    // 只允许通过相机扫码
    uni.scanCode({
      onlyFromCamera: true,
@@ -93,6 +95,30 @@
      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 })