|
|
@@ -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) => {
|