周宾
4 小时以前 5392dc649209ff372ec276aa6cbf86b16b12a375
src/pages/index.vue
@@ -209,14 +209,17 @@
            </up-grid>
         </view>
      </view>
      <GoodsDetailPopup ref="refGoodsDetailPopup"></GoodsDetailPopup>
   </view>
</template>
<script setup>
import {ref, onMounted, nextTick, reactive} from 'vue';
import {userLoginFacotryList} from "@/api/login";
import { stockinDetail, detailManagementByCustom } from '@/api/inventoryManagement/receiptManagement'
import modal from "@/plugins/modal";
import useUserStore from "@/store/modules/user";
import GoodsDetailPopup from './components/GoodsDetailPopup.vue';
const userStore = useUserStore()
const factoryId = ref('');
@@ -259,6 +262,10 @@
   {
      icon: '/static/images/icon/huikuandengji@2x.png',
      label: '库存管理',
   },
   {
      icon: '/static/images/icon/huikuandengji@2x.png',
      label: '产品扫码',
   }
]);
@@ -558,6 +565,9 @@
            url: '/pages/inventoryManagement/stockManagement/index'
         });
         break
      case '产品扫码':
         scanQRCode()
         break
      default:
         uni.showToast({
            title: `点击了${item.label}`,
@@ -612,6 +622,73 @@
   });
}
//开始扫码
const scanQRCode = ()=>{
   uni.scanCode({
      onlyFromCamera:true,
      scanType:['barCode','qrCode'],
      success(res) {
         searchDetail(res.result||'')
      },
      fail(res) {
         uni.showToast({
            title: res.errMsg||'扫码失败',
            icon: 'none',
            duration: 1500
         })
      }
   })
}
//谈框相关
const refGoodsDetailPopup = ref(null)
//查看详情
const searchDetail = (barcode)=>{
   if(!barcode||barcode.indexOf(',')==-1){
      uni.showToast({
         title:"请扫描正确的二维码",
         icon: 'none',
         duration: 1500
      })
      return
   }
   let barcodeList = barcode.split(",")
   let barcodeId = barcodeList[0]
   let type = barcodeList[1]
   let detailApi = null
   if(type==1){
      detailApi = stockinDetail
   }else if(type==2){
      detailApi = detailManagementByCustom
   }
   if(!detailApi){
      uni.showToast({
         title:"请扫描正确的二维码",
         icon: 'none',
         duration: 1500
      })
      return
   }
   detailApi({id:barcodeId}).then((resp) => {
      if(resp.code!=200||!resp.data)return
      // barcodeDetail.value = resp.data
      refGoodsDetailPopup.value.open({
         type: type,
         ...resp.data
      })
   }).catch(() => {
      uni.showToast({
         title: "获取数据失败",
         icon: 'none',
         duration: 1500
      });
   })
}
// 定义方法
const click = (name) => {
   if (uToastRef.value) {