weixin_52219567 1 hafta önce
ebeveyn
işleme
ddb46aa2ff

+ 10 - 10
src/views/home/jdcomponents/JDBannerCards.vue

@@ -17,8 +17,8 @@
       <!-- 百亿补贴 -->
       <div class="subsidy-box card-base">
         <div class="c-header flex-between">
-          <span class="title">{{ dataInfo1.mainTitle }}</span>
-          <span class="tag">{{ dataInfo1.subTitle }}</span>
+          <span class="title" :style="{ color: dataInfo1.mainTitleColor }">{{ dataInfo1.mainTitle }}</span>
+          <span class="tag" :style="{ color: dataInfo1.subTitleColor }">{{ dataInfo1.subTitle }}</span>
         </div>
         <div class="p-list flex">
           <div
@@ -39,8 +39,8 @@
       <!-- 企采榜单 -->
       <div class="card-base b-item">
         <div class="c-header flex-between">
-          <span class="title">{{ dataInfo2.mainTitle }}</span>
-          <span class="tag-orange">{{ dataInfo2.mainTitle }}</span>
+          <span class="title" :style="{ color: dataInfo2.mainTitleColor }">{{ dataInfo2.mainTitle }}</span>
+          <span class="tag-orange" :style="{ color: dataInfo2.subTitleColor }">{{ dataInfo2.mainTitle }}</span>
         </div>
         <div class="rank-list flex">
           <div class="r-i" v-for="(item, index) in dataInfo2.adModuleItemList" :key="index" @click="onPath(item.tagLink)">
@@ -54,8 +54,8 @@
       <!-- 品牌好店 -->
       <div class="card-base b-item">
         <div class="c-header flex-between">
-          <span class="title">{{ dataInfo3.mainTitle }}</span>
-          <span class="tag-orange">{{ dataInfo3.mainTitle }}</span>
+          <span class="title" :style="{ color: dataInfo3.mainTitleColor }">{{ dataInfo3.mainTitle }}</span>
+          <span class="tag-orange" :style="{ color: dataInfo3.subTitleColor }">{{ dataInfo3.mainTitle }}</span>
         </div>
         <div class="brand-box flex">
           <div class="brand-i" v-for="(item, index) in dataInfo3.adModuleItemList" :key="index" @click="onPath(item.tagLink)">
@@ -69,8 +69,8 @@
       <!-- 企业精选 -->
       <div class="card-base b-item">
         <div class="c-header flex-between">
-          <span class="title">{{ dataInfo4.mainTitle }}</span>
-          <span class="tag-gray">{{ dataInfo4.mainTitle }}</span>
+          <span class="title" :style="{ color: dataInfo4.mainTitleColor }">{{ dataInfo4.mainTitle }}</span>
+          <span class="tag-gray" :style="{ color: dataInfo4.subTitleColor }">{{ dataInfo4.mainTitle }}</span>
         </div>
         <div class="p-list flex">
           <div
@@ -91,8 +91,8 @@
       <!-- 京东新品 -->
       <div class="card-base b-item">
         <div class="c-header flex-between">
-          <span class="title">{{ dataInfo5.mainTitle }}</span>
-          <span class="tag-orange">{{ dataInfo5.mainTitle }}</span>
+          <span class="title" :style="{ color: dataInfo5.mainTitleColor }">{{ dataInfo5.mainTitle }}</span>
+          <span class="tag-orange" :style="{ color: dataInfo5.subTitleColor }">{{ dataInfo5.mainTitle }}</span>
         </div>
         <div class="p-list flex">
           <div

+ 1 - 1
src/views/home/jdcomponents/JDHeader.vue

@@ -56,7 +56,7 @@
 
         <div class="header-actions">
           <div :style="{ borderColor: config.themeColor }" class="btn-keeper" @click="onPath(config.rightBtnLink)">
-            <img :src="config.rightBtnIcon" alt="" />{{ config.rightBtnText }}
+            <img v-if="config.rightBtnIcon" :src="config.rightBtnIcon" alt="" />{{ config.rightBtnText }}
           </div>
         </div>
       </div>

+ 71 - 8
src/views/home/jdcomponents/JDProducts.vue

@@ -47,17 +47,23 @@
     <div class="product-grid">
       <div class="p-card" v-for="(p, i) in baseProducts" :key="i">
         <div class="p-img-box">
-          <img :src="p.image" @error="handleImgError" />
+          <img :src="p.image || p.productImage" @error="handleImgError" />
         </div>
         <div class="p-info">
           <div class="p-name">
             <span class="tag-zy">{{ p.isSelf == 1 ? '自营' : '非自营' }}</span>
-            {{ p.name }}
+            {{ p.name || p.itemName || '' }}
           </div>
           <div class="p-price-row">
             <span class="p-currency">¥</span>
-            <span class="p-price">{{ p.price }}</span>
-            <span class="p-decimal" v-if="p.dec !== '00'">.{{ p.dec }}</span>
+            <template v-if="p.price">
+              <span class="p-price">{{ p.price.split('.')[0] }}</span>
+              <span class="p-decimal">.{{ p.price.split('.')[1] }}</span>
+            </template>
+            <template v-if="p.memberPrice">
+              <span class="p-price">{{ p.memberPrice.split('.')[0] }}</span>
+              <span class="p-decimal">.{{ p.memberPrice.split('.')[1] }}</span>
+            </template>
             <span class="tag-ep">企业价</span>
           </div>
           <div class="p-actions">
@@ -69,8 +75,8 @@
               </svg>
             </button>
             <button class="btn-buy" @click="onPath('/item?id=' + p.id + '&productNo=' + p.productNo)">
-              <span class="txt-normal">加入采购清单</span>
-              <span class="txt-hover">注册企业用户可享</span>
+              <span class="txt-normal">加入购物车</span>
+              <span class="txt-hover">加入购物车</span>
             </button>
           </div>
         </div>
@@ -86,6 +92,7 @@
 import { recommendThemeConfig } from '@/api/home/index-enterprise';
 import { onPath } from '@/utils/siteConfig';
 import { addProductShoppingCart } from '@/api/goods/index';
+import { getPcProductPage } from '@/api/search/index';
 
 const categories = ref<any>([]);
 const baseProducts = ref<any>([]);
@@ -99,7 +106,26 @@ recommendThemeConfig({}).then((res) => {
         item.goodsList = JSON.parse(item.selectedProductIds);
       }
     });
-    baseProducts.value = categories.value[0].goodsList;
+    if (categories.value[0].categoryPath) {
+      categories.value[0].pageNum = 1;
+      categories.value[0].pageSize = 20;
+      categories.value[0].topCategoryId = '';
+      categories.value[0].mediumCategoryId = '';
+      categories.value[0].bottomCategoryId = '';
+      const categoryList = categories.value[0].categoryPath.split(',');
+      if (categoryList.length > 0) {
+        categories.value[0].topCategoryId = categoryList[0];
+      }
+      if (categoryList.length > 1) {
+        categories.value[0].mediumCategoryId = categoryList[1];
+      }
+      if (categoryList.length > 2) {
+        categories.value[0].bottomCategoryId = categoryList[2];
+      }
+      getList();
+    } else {
+      baseProducts.value = categories.value[0].goodsList;
+    }
   }
 });
 
@@ -110,7 +136,44 @@ const showNext = ref(true);
 
 const onCurrentCat = (index: any) => {
   currentCat.value = index;
-  baseProducts.value = categories.value[index].goodsList;
+  if (categories.value[index].categoryPath) {
+    categories.value[index].pageNum = 1;
+    categories.value[index].pageSize = 20;
+    categories.value[index].topCategoryId = '';
+    categories.value[index].mediumCategoryId = '';
+    categories.value[index].bottomCategoryId = '';
+    const categoryList = categories.value[index].categoryPath.split(',');
+    if (categoryList.length > 0) {
+      categories.value[index].topCategoryId = categoryList[0];
+    }
+    if (categoryList.length > 1) {
+      categories.value[index].mediumCategoryId = categoryList[1];
+    }
+    if (categoryList.length > 2) {
+      categories.value[index].bottomCategoryId = categoryList[2];
+    }
+    getList();
+  } else {
+    baseProducts.value = categories.value[index].goodsList;
+  }
+};
+
+const getList = () => {
+  const datas = {
+    pageNum: categories.value[currentCat.value].pageNum,
+    pageSize: categories.value[currentCat.value].pageSize,
+    topCategoryId: categories.value[currentCat.value].topCategoryId,
+    mediumCategoryId: categories.value[currentCat.value].mediumCategoryId,
+    bottomCategoryId: categories.value[currentCat.value].bottomCategoryId
+  };
+  getPcProductPage(datas).then((res) => {
+    if (res.code == 200) {
+      baseProducts.value = res.rows ? res.rows : [];
+      // dataList.value = res.rows ? res.rows : [];
+      // // 判断是否还有更多数据
+      // hasMore.value = dataList.value.length === httpObj.value.pageSize;
+    }
+  });
 };
 const checkScroll = () => {
   if (!navListRef.value) return;