Browse Source

feat(mall): 添加超值划算商品功能

- 新增 getFavourableProducts 接口获取超值划算商品列表
- 在首页添加超值划算商品轮播组件
- 优化订单列表,只显示未使用的积分兑换订单
- 新增 lightning、textGreatMoney 和 grabNow 资产
EvilDragon 4 months ago
parent
commit
fd35b51ef0

+ 36 - 0
packages/app/src/core/libs/requests.ts

@@ -327,6 +327,42 @@ export const getProducts = (query: { oneCategory?: string; secondCategory?: stri
       secondCategory: string
     }[]
   }>('/app-api/member/product/page', query)
+/**
+ * 获取超值划算商品
+ */
+export const getFavourableProducts = () =>
+  httpPost<
+    {
+      id: number
+      prodcutName: string
+      productId: string
+      oneCategory: string
+      oneCategoryName: string
+      secondCategory: string
+      secondCategoryName: string
+      isRestrict: number
+      productRepertory: number
+      productPrice: string
+      productType: number
+      vendorId: number
+      vendorName: string
+      needPoints: number
+      points: number
+      gainType: number
+      exchangeDesc: string
+      productCoverImgUrl: string
+      productDetailsImgUrl: string
+      contentDesc: string
+      status: number
+      exchangeCount: number
+      memberLevelIds: string
+      memberLevelName: string
+      favourablePoints: number
+      favourableEndDate: string
+      createTime: string
+      updateTime: string
+    }[]
+  >('/app-api/member/product/listFavourableProduct')
 export const getProduct = (id: string) =>
   httpGet<{
     id: number

+ 89 - 4
packages/app/src/pages/home/mall/index.vue

@@ -14,6 +14,7 @@ import { shoppingBag } from '@designer-hub/assets/src/assets/svgs/index'
 import { useRouter } from '../../../core/utils/router'
 import {
   getBanners,
+  getFavourableProducts,
   getProductCategories,
   getProductItemBuy,
   getProducts,
@@ -24,6 +25,9 @@ import Banner from '../components/banner.vue'
 import BottomAppBar from '@/components/bottom-app-bar.vue'
 import { useUserStore } from '../../../store'
 import { storeToRefs } from 'pinia'
+import lightning from '@designer-hub/assets/src/libs/assets/lightning'
+import textGreatMoney from '@designer-hub/assets/src/libs/assets/textGreatMoney'
+import grabNow from '@designer-hub/assets/src/libs/assets/grabNow'
 
 const router = useRouter()
 const userStore = useUserStore()
@@ -39,6 +43,10 @@ const { data: carts, run: setCarts } = useRequest(
   () => getProductItemBuy({ userId: userInfo.value.userId }),
   { initialData: { list: [], total: 0 } },
 )
+const { data: favourableProducts, run: setFavourableProducts } = useRequest(
+  () => getFavourableProducts(),
+  { initialData: [] },
+)
 const current = ref<number>(0)
 const swiperList = computed(() => banners.value.map((it) => it.bannerImgUrl))
 const categories = computed(() => productCategories.value.find(({ id }) => id === 1)?.children)
@@ -51,9 +59,10 @@ const handleChange = async () => {
   setCarts()
 }
 onMounted(async () => {
-  await setProductCategories()
-  await setBanners()
-  await setCarts()
+  await Promise.all([setProductCategories(), setBanners(), setCarts(), setFavourableProducts()])
+  // await setProductCategories()
+  // await setBanners()
+  // await setCarts()
   category.value = categories.value[0]
 })
 </script>
@@ -61,8 +70,84 @@ onMounted(async () => {
 <template>
   <view class="bg-white flex-grow flex flex-col px-3.5 py-5.5 gap-5.5">
     <Banner :mode="BannerMode.Mall"></Banner>
+    <div v-if="favourableProducts.length" class="relative aspect-[1.47/1]">
+      <div class="aspect-[2.99/1] bg-black rounded-2xl">
+        <div class="px-3 h-11 flex items-center">
+          <wd-img width="22" height="22" :src="lightning"></wd-img>
+          <wd-img width="95" height="25" :src="textGreatMoney"></wd-img>
+          <div class="flex-1"></div>
+          <div
+            class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-relaxed"
+          >
+            17:02:18 结束
+          </div>
+        </div>
+      </div>
+      <div class="absolute top-11 left-0 right-0 bottom-0 bg-white rounded-2xl shadow">
+        <swiper class="w-full h-full" v-model:value="current">
+          <template v-for="(it, i) in favourableProducts" :key="i">
+            <swiper-item>
+              <div class="w-full h-full px-4 flex items-center gap-3">
+                <wd-img
+                  width="114"
+                  height="114"
+                  custom-class="rounded-2xl overflow-hidden"
+                  :src="it.productCoverImgUrl"
+                />
+                <div>
+                  <div
+                    class="w-[178px] text-black/90 text-base font-normal font-['PingFang SC'] leading-normal"
+                  >
+                    <!-- 海蓝之谜精华面霜60ml -->
+                    {{ it.prodcutName }}
+                  </div>
+                  <div class="flex items-center gap-2.5">
+                    <div class="flex-1">
+                      <wd-progress
+                        :percentage="(it.exchangeCount || 0 / it.productRepertory || 0) * 100"
+                        hide-text
+                        color="black"
+                      ></wd-progress>
+                    </div>
+                    <div
+                      class="text-black/40 text-[10px] font-normal font-['PingFang_SC'] leading-normal"
+                    >
+                      还剩{{ it.productRepertory - it.exchangeCount }}件
+                    </div>
+                  </div>
+                  <div class="flex items-end gap-1 mt-5">
+                    <div class="text-[#ef4343] text-[22px] font-normal font-['D-DIN_Exp'] pb-3">
+                      <!-- 1600 -->
+                      {{ it.favourablePoints }}
+                    </div>
+                    <div class="text-black/60 text-sm font-normal font-['PingFang_SC'] pb-3">
+                      积分
+                    </div>
+                    <div class="flex-1"></div>
+                    <div @click="router.push(`/pages/home/mall/detail/index?id=${it.productId}`)">
+                      <wd-img width="106" height="40" :src="grabNow"></wd-img>
+                    </div>
+                  </div>
+                  <div class="flex gap-4">
+                    <div
+                      class="text-black/30 text-[10px] font-normal font-['PingFang SC'] line-through leading-normal"
+                    >
+                      {{ it.points }}积分
+                    </div>
+                    <div
+                      class="text-black/30 text-[10px] font-normal font-['PingFang SC'] line-through leading-normal"
+                    >
+                      ¥{{ it.productPrice }}
+                    </div>
+                  </div>
+                </div>
+              </div>
+            </swiper-item>
+          </template>
+        </swiper>
+      </div>
+    </div>
     <div class="w-full inline-flex gap-2">
-      <!-- <div><wd-button type="primary" size="small">GELATO专区</wd-button></div> -->
       <template v-for="(it, i) in categories" :key="i">
         <div>
           <wd-button

+ 1 - 1
packages/app/src/pages/mine/orders/index.vue

@@ -54,7 +54,7 @@ const handleClick = (order: PointsOrder) => {
                   </div>
                   <div>
                     <div
-                      v-if="it.gainType === 1"
+                      v-if="it.gainType === 1 && it.orderStatus === '0'"
                       class="w-[58px] h-[26px] bg-[#020202] rounded-[20px] backdrop-blur-[10px] flex items-center justify-center"
                       @click.stop="router.push(`/pages/mine/orders/code/index?id=${it.id}`)"
                     >

+ 11 - 0
packages/assets/src/assets/grab-now.svg

@@ -0,0 +1,11 @@
+<svg width="106" height="40" viewBox="0 0 106 40" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M14.9799 5.47537C16.6841 2.11642 20.1311 0 23.8977 0H97L82 35H13.0297C7.06212 35 3.19535 28.7021 5.89547 23.3803L14.9799 5.47537Z" fill="black" fill-opacity="0.85"/>
+<path d="M27.98 19.144H36.814V20.446H27.98V19.144ZM36.464 12.284H29.072V10.982H38.004L37.318 16.302H40.048C39.8987 19.578 39.6233 21.5473 39.222 22.21C38.83 22.8727 37.9993 23.204 36.73 23.204L35.134 23.148L34.784 21.86C35.484 21.944 36.1327 21.986 36.73 21.986C37.402 21.986 37.8593 21.7947 38.102 21.412C38.3353 21.02 38.508 19.7507 38.62 17.604H29.8L30.738 12.984L32.096 13.096L31.494 16.302H35.876L36.464 12.284ZM46.656 10.52H48.028V14.734H53.208V16.022H48.028V21.65H54.286V22.938H41.742V21.65H46.656V10.52ZM64.716 10.632C65.444 12.2467 66.6993 13.6607 68.482 14.874L67.754 15.98C67.4087 15.756 67.0867 15.518 66.788 15.266V18.724C66.7787 19.4893 66.3633 19.9 65.542 19.956C65.1687 19.956 64.6647 19.9373 64.03 19.9L63.694 18.696C64.254 18.7427 64.702 18.766 65.038 18.766C65.3553 18.766 65.514 18.6027 65.514 18.276V16.19H62.728V21.272C62.728 21.748 62.9473 21.986 63.386 21.986H65.78C66.3587 21.986 66.7227 21.8693 66.872 21.636C67.012 21.384 67.124 20.8707 67.208 20.096L68.454 20.502C68.314 21.7993 68.0993 22.5787 67.81 22.84C67.5207 23.0827 66.97 23.204 66.158 23.204H62.826C61.8833 23.204 61.412 22.7187 61.412 21.748V15.518C61.1507 15.742 60.8567 15.9707 60.53 16.204L59.816 15.112C61.3933 13.9733 62.6207 12.48 63.498 10.632H64.716ZM66.494 15.014C65.4767 14.118 64.6787 13.1007 64.1 11.962C63.5027 13.1287 62.784 14.146 61.944 15.014H66.494ZM60.11 17.268C59.662 17.5013 59.214 17.7253 58.766 17.94V21.93C58.766 22.854 58.304 23.316 57.38 23.316H56.148L55.854 22.028C56.274 22.0747 56.6287 22.098 56.918 22.098C57.2633 22.098 57.436 21.93 57.436 21.594V18.5C56.82 18.7333 56.2647 18.9293 55.77 19.088L55.448 17.828C56.176 17.6413 56.8387 17.436 57.436 17.212V14.37H55.728V13.096H57.436V10.562H58.766V13.096H60.012V14.37H58.766V16.652C59.3633 16.3533 59.8113 16.12 60.11 15.952V17.268Z" fill="white"/>
+<path d="M82.2462 17.1393L90.6384 0H105.854L98.8591 10.9846H105.854L77 40L88.3667 17.1393H82.2462Z" fill="url(#paint0_linear_460_358)"/>
+<defs>
+<linearGradient id="paint0_linear_460_358" x1="101.516" y1="-1.81577" x2="77.1782" y2="40.1035" gradientUnits="userSpaceOnUse">
+<stop stop-color="#F17112"/>
+<stop offset="1" stop-color="#F0D194"/>
+</linearGradient>
+</defs>
+</svg>

+ 3 - 0
packages/assets/src/assets/lightning.svg

@@ -0,0 +1,3 @@
+<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M9.34359 20.6726C9.29019 20.6726 9.24998 20.6583 9.22329 20.6323C9.03607 20.5781 8.96932 20.472 9.02272 20.3115L10.2662 12.9716H4.85136C4.71771 12.9716 4.6241 12.918 4.57052 12.8111C4.49043 12.705 4.50377 12.5847 4.61073 12.4501L12.9535 1.54044C13.0604 1.37993 13.1807 1.35407 13.3144 1.46017C13.448 1.48686 13.515 1.59468 13.515 1.78104L12.2715 9.1211H17.0446C17.1782 9.1211 17.2718 9.17536 17.3254 9.28146C17.3521 9.38841 17.3521 9.50872 17.3254 9.64254L9.62443 20.5522C9.54416 20.6323 9.45055 20.6726 9.34359 20.6726Z" fill="white"/>
+</svg>

File diff suppressed because it is too large
+ 1 - 0
packages/assets/src/assets/text-great-money.svg


+ 2 - 0
packages/assets/src/libs/assets/grabNow.ts

@@ -0,0 +1,2 @@
+import grabNow from '../../assets/grab-now.svg' 
+ export default grabNow

+ 2 - 0
packages/assets/src/libs/assets/lightning.ts

@@ -0,0 +1,2 @@
+import lightning from '../../assets/lightning.svg' 
+ export default lightning

+ 2 - 0
packages/assets/src/libs/assets/textGreatMoney.ts

@@ -0,0 +1,2 @@
+import textGreatMoney from '../../assets/text-great-money.svg' 
+ export default textGreatMoney

Some files were not shown because too many files changed in this diff