weixin_52219567 2 weken geleden
bovenliggende
commit
5bda6d748f

+ 10 - 1
src/api/goods/index.ts

@@ -1,6 +1,6 @@
 import request from '@/utils/request';
 
-//商品详情
+//商品详情-id
 
 export const getProductDetail = (id: any) => {
   return request({
@@ -9,6 +9,15 @@ export const getProductDetail = (id: any) => {
   });
 };
 
+//商品详情-productNo
+
+export const getProductDetailByNo = (id: any) => {
+  return request({
+    url: '/product/indexProduct/getProductDetailByNo/' + id,
+    method: 'get'
+  });
+};
+
 //将商品添加到购物车
 export const addProductShoppingCart = (params: any) => {
   return request({

+ 2 - 1
src/components/ProductCard/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="product-card" @click="onPath(`/item?id=${product.id}`)">
+  <div class="product-card" @click="onPath(`/item?id=${product.id}&productNo=${product.productNo}`)">
     <div class="card-header" v-if="showCheckbox || showAction">
       <el-checkbox v-if="showCheckbox" v-model="checked" @change="handleCheck" />
       <slot name="action">
@@ -41,6 +41,7 @@ interface Product {
   price: string | number;
   originalPrice?: string | number;
   tag?: string;
+  productNo?: string;
 }
 
 const props = defineProps<{

+ 1 - 1
src/views/enterprise/agreementSupply/index.vue

@@ -61,7 +61,7 @@
       <div v-if=" productList.length > 0">
         <div class="product-grid">
           <div v-for="(item, index) in productList" :key="item.id || index" class="product-card">
-            <div class="product-image" @click="onPath(`/item?id=${item.id}`)">
+            <div class="product-image" @click="onPath(`/item?id=${item.id}&productNo=${item.productNo}`)">
               <el-image :src="item.productImage" fit="contain">
                 <template #error
                   ><div class="image-placeholder">

+ 1 - 1
src/views/home/index copy.vue

@@ -174,7 +174,7 @@
     </div>
     <div class="expert-bos">
       <template v-for="(item, index) in expertList" :key="index">
-        <div class="expert-list" v-if="Number(index) < 5" @click="onPath('/item?id=' + item.id)">
+        <div class="expert-list" v-if="Number(index) < 5" @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)">
           <img :src="item.productImage" alt="" />
           <div class="itemName ellipsis">{{ item.itemName || '' }}</div>
           <div class="price">

+ 5 - 1
src/views/home/index-data.vue

@@ -130,7 +130,11 @@
         <img class="goods-one" :src="item.imageUrl" alt="" />
         <div class="goods-shop">
           <template v-for="(item1, index1) in item.goodsList" :key="index1">
-            <div v-if="Number(index1) < 8" class="shop-list flex-column-between" @click="onPath('/item?id=' + item1.id)">
+            <div
+              v-if="Number(index1) < 8"
+              class="shop-list flex-column-between"
+              @click="onPath('/item?id=' + item1.id + '&productNo=' + item1.productNo)"
+            >
               <img class="shop-img" :src="item1.productImage ? item1.productImage.split(',')[0] : ''" alt="" />
               <div class="shop-name ellipsis2">{{ item1.itemName || '' }}</div>
               <div class="shop-price">

+ 1 - 1
src/views/home/index.vue

@@ -206,7 +206,7 @@
     </div>
     <div class="expert-bos">
       <template v-for="(item, index) in expertList" :key="index">
-        <div class="expert-list" v-if="Number(index) < 5" @click="onPath('/item?id=' + item.id)">
+        <div class="expert-list" v-if="Number(index) < 5" @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)">
           <img :src="item.productImage" alt="" />
           <div class="itemName ellipsis">{{ item.itemName || '' }}</div>
           <div class="price">

+ 1 - 1
src/views/home/pccomponents/pages/discover.vue

@@ -109,7 +109,7 @@
             v-if="Number(index) < 4"
             class="goods-bos flex-column-between hover-color"
             :style="componentData.boxRadius ? { borderRadius: componentData.boxRadius + 'px' } : {}"
-            @click="onPath('/item?id=' + item.id)"
+            @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
           >
             <img
               class="goods-img"

+ 2 - 2
src/views/home/pccomponents/pages/goods.vue

@@ -6,7 +6,7 @@
         :key="index"
         class="goods-list flex-column-between hover-color"
         :style="goodsCss"
-        @click="onPath('/item?id=' + item.id)"
+        @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
       >
         <img
           class="goods-img"
@@ -43,7 +43,7 @@
               :key="index"
               class="goods-list flex-column-between hover-color"
               :style="goodsCss"
-              @click="onPath('/item?id=' + item.id)"
+              @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
             >
               <img
                 class="goods-img"

+ 1 - 1
src/views/home/pccomponents/pages/goodsList.vue

@@ -14,7 +14,7 @@
           :key="index"
           class="goods-list flex-column-between hover-color"
           :style="goodsCss"
-          @click="onPath('/item?id=' + item.id)"
+          @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
         >
           <img
             class="goods-img"

+ 42 - 17
src/views/item/index.vue

@@ -158,7 +158,12 @@
       </div> -->
     </div>
     <div class="data-bos">
-      <div v-for="(item, index) in recommendList" :key="index" class="data-list" @click="onPath('/item?id=' + item.id)">
+      <div
+        v-for="(item, index) in recommendList"
+        :key="index"
+        class="data-list"
+        @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
+      >
         <img class="data-img" :src="item.productImage ? item.productImage.split(',')[0] : ''" alt="" />
         <div class="data-title">{{ item.itemName || '' }}</div>
         <div class="money">
@@ -204,7 +209,8 @@ import {
   addProductBrowsingHistory,
   addProductCollect,
   favoritesList,
-  cancelProductCollect
+  cancelProductCollect,
+  getProductDetailByNo
 } from '@/api/goods/index';
 
 import { getRecommendedCategoryProductList } from '@/api/home/index-mro';
@@ -223,6 +229,7 @@ const navIndex = ref<any>(0);
 const recommendList = ref<any>([]);
 const num = ref<any>(1);
 const carouselIndex = ref<any>(0);
+const productNo = ref<any>(null);
 
 watch(route, () => {
   initData();
@@ -234,8 +241,13 @@ onMounted(() => {
 
 // 核心修复:统一初始化函数
 const initData = () => {
-  id.value = route.query.id;
-  getInfo();
+  id.value = route.query.id ? route.query.id : null;
+  productNo.value = route.query.productNo ? route.query.productNo : null;
+  if (productNo.value) {
+    getInfoProductNo();
+  } else {
+    getInfoId();
+  }
 
   if (getToken()) {
     getCollection();
@@ -244,25 +256,38 @@ const initData = () => {
   }
 };
 
-// 商品详情
-const getInfo = () => {
+// 商品详情-id
+const getInfoId = () => {
   getProductDetail(id.value).then((res) => {
     if (res.code == 200) {
-      carousel.value = [];
-      if (res.data.imageUrl) {
-        carousel.value = res.data.imageUrl.split(',');
-        if (carousel.value.length > 5) {
-          carousel.value = carousel.value.slice(0, 5);
-        }
-      }
-      num.value = Number(res.data.minOrderQuantity || 1);
-      dataInfo.value = res.data;
-      dataInfo.value.minOrderQuantity = num.value;
-      dataInfo.value.allStock = Number(res.data.totalInventory || 0) + Number(res.data.nowInventory || 0) + Number(res.data.virtualInventory || 0);
+      getInfo(res);
     }
   });
 };
 
+//商品详情-productNo
+const getInfoProductNo = () => {
+  getProductDetailByNo(productNo.value).then((res) => {
+    if (res.code == 200) {
+      getInfo(res);
+    }
+  });
+};
+
+const getInfo = (res: any) => {
+  carousel.value = [];
+  if (res.data.imageUrl) {
+    carousel.value = res.data.imageUrl.split(',');
+    if (carousel.value.length > 5) {
+      carousel.value = carousel.value.slice(0, 5);
+    }
+  }
+  num.value = Number(res.data.minOrderQuantity || 1);
+  dataInfo.value = res.data;
+  dataInfo.value.minOrderQuantity = num.value;
+  dataInfo.value.allStock = Number(res.data.totalInventory || 0) + Number(res.data.nowInventory || 0) + Number(res.data.virtualInventory || 0);
+};
+
 // 收藏
 const getCollection = () => {
   isProductInDefaultCollect(id.value).then((res) => {

+ 6 - 1
src/views/plan/procure.vue

@@ -50,7 +50,12 @@
               <div>历史浏览商品</div>
             </div>
             <div class="procure-bos">
-              <div v-for="(item, index) in goodsList" :key="index" class="procure-list" @click="onPath('/item?id=' + item.id)">
+              <div
+                v-for="(item, index) in goodsList"
+                :key="index"
+                class="procure-list"
+                @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
+              >
                 <img :src="item.productImage" alt="" />
                 <div>
                   <div class="procure1">{{ item.itemName }}</div>

+ 6 - 1
src/views/plan_info/index.vue

@@ -11,7 +11,12 @@
         <!-- 数据 -->
         <div class="data-bos">
           <div class="data-box">
-            <div v-for="(item1, index1) in item.list" :key="index1" class="data-list" @click="onPath('/item?id=' + item1.id)">
+            <div
+              v-for="(item1, index1) in item.list"
+              :key="index1"
+              class="data-list"
+              @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
+            >
               <img class="data-img" :src="item1.productImage" alt="" />
               <div class="data-title ellipsis">{{ item1.itemName }}</div>
               <div class="money">

+ 6 - 1
src/views/plan_info/procure.vue

@@ -14,7 +14,12 @@
         <!-- 数据 -->
         <div class="data-bos">
           <div class="data-box">
-            <div v-for="(item1, index1) in item.list" :key="index1" class="data-list" @click="onPath('/item?id=' + item1.id)">
+            <div
+              v-for="(item1, index1) in item.list"
+              :key="index1"
+              class="data-list"
+              @click="onPath('/item?id=' + item1.id + '&productNo=' + item1.productNo)"
+            >
               <img class="data-img" :src="item1.productImage" alt="" />
               <div class="data-title">{{ item1.itemName }}</div>
               <div class="money">

+ 1 - 2
src/views/search/brand.vue

@@ -39,8 +39,7 @@
     </div>
     <!-- 商品 -->
     <div class="expert-bos">
-      <!-- @click="onPath('/item?id=' + item.id)" -->
-      <div v-for="(item, index) in dataList" :key="index" class="expert-list">
+      <div v-for="(item, index) in dataList" :key="index" class="expert-list" @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)">
         <img :src="item.brandBigImage" alt="" />
         <div class="itemName ellipsis">{{ item.brandName || '' }}</div>
       </div>

+ 1 - 1
src/views/search/index.vue

@@ -125,7 +125,7 @@
 
     <!-- 商品 -->
     <div class="expert-bos">
-      <div v-for="(item, index) in dataList" :key="index" class="expert-list" @click="onPath('/item?id=' + item.id)">
+      <div v-for="(item, index) in dataList" :key="index" class="expert-list" @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)">
         <img :src="item.productImage" alt="" />
         <div class="itemName ellipsis">{{ item.itemName || '' }}</div>
         <div class="price">

+ 1 - 1
src/views/search/special.vue

@@ -73,7 +73,7 @@
     </div>
     <!-- 商品 -->
     <div class="expert-bos">
-      <div v-for="(item, index) in dataList" :key="index" class="expert-list" @click="onPath('/item?id=' + item.id)">
+      <div v-for="(item, index) in dataList" :key="index" class="expert-list" @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)">
         <img :src="item.productImage" alt="" />
         <div class="itemName ellipsis">{{ item.itemName || '' }}</div>
         <div class="price">