From 89822dc3d76f82904f59b1181dec3498e7402b5a Mon Sep 17 00:00:00 2001 From: liruiqiang <3151805288@qq.com> Date: Sat, 16 Aug 2025 17:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=83=AD=E9=97=A8=E6=8E=A8=E8=8D=90=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E4=B8=8E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages.json | 7 ++ src/pages/hot/hot.vue | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/services/hot.ts | 20 ++++++ src/types/global.d.ts | 18 +++++ src/types/home.d.ts | 20 ++---- src/types/hot.d.ts | 23 ++++++ 6 files changed, 261 insertions(+), 16 deletions(-) create mode 100644 src/pages/hot/hot.vue create mode 100644 src/services/hot.ts create mode 100644 src/types/hot.d.ts diff --git a/src/pages.json b/src/pages.json index 91d3477..dadf4cb 100644 --- a/src/pages.json +++ b/src/pages.json @@ -44,6 +44,13 @@ "style": { "navigationBarTitleText": "登录" } + }, + { + "path" : "pages/hot/hot", + "style" : + { + "navigationBarTitleText" : "热门推荐" + } } ], "globalStyle": { diff --git a/src/pages/hot/hot.vue b/src/pages/hot/hot.vue new file mode 100644 index 0000000..3eb3df5 --- /dev/null +++ b/src/pages/hot/hot.vue @@ -0,0 +1,189 @@ + + + + + diff --git a/src/services/hot.ts b/src/services/hot.ts new file mode 100644 index 0000000..2bd1d18 --- /dev/null +++ b/src/services/hot.ts @@ -0,0 +1,20 @@ +import { http } from '@/utils/http' +import type { PageParams } from '@/types/global' +import type { HotResult } from '@/types/hot' + +type HotParams = PageParams & { + /** Tab 项的 id,默认查询全部 Tab 项的第 1 页数据 */ + subType?: string +} +/** + * 通用热门推荐类型 + * @param url 请求地址 + * @param data 请求参数 + */ +export const getHotRecommendAPI = (url: string, data?: HotParams) => { + return http({ + method: 'GET', + url, + data, + }) +} diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 7c2136f..468846d 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -19,3 +19,21 @@ export type PageParams = { /** 页大小:默认值为 10 */ pageSize?: number } + +/** 通用商品类型 */ +export type GoodsItem = { + /** 商品描述 */ + desc: string + /** 商品折扣 */ + discount: number + /** id */ + id: string + /** 商品名称 */ + name: string + /** 商品已下单数量 */ + orderNum: number + /** 商品图片 */ + picture: string + /** 商品价格 */ + price: number +} diff --git a/src/types/home.d.ts b/src/types/home.d.ts index 31b44c1..cba9b88 100644 --- a/src/types/home.d.ts +++ b/src/types/home.d.ts @@ -1,3 +1,5 @@ +import type { GoodsItem } from '@/types/global' + /** 首页-广告区域数据类型 */ export type BannerItem = { /** 跳转链接 */ @@ -37,19 +39,5 @@ export type HotItem = { } /** 猜你喜欢-商品类型 */ -export type GuessItem = { - /** 商品描述 */ - desc: string - /** 商品折扣 */ - discount: number - /** id */ - id: string - /** 商品名称 */ - name: string - /** 商品已下单数量 */ - orderNum: number - /** 商品图片 */ - picture: string - /** 商品价格 */ - price: number -} +// GuessItem 和 GoodsItem 类型相同 +export type GuessItem = GoodsItem diff --git a/src/types/hot.d.ts b/src/types/hot.d.ts new file mode 100644 index 0000000..0d20b9d --- /dev/null +++ b/src/types/hot.d.ts @@ -0,0 +1,23 @@ +import type { PageResult, GoodsItem } from './global' + +/** 热门推荐 */ +export type HotResult = { + /** id信息 */ + id: string + /** 活动图片 */ + bannerPicture: string + /** 活动标题 */ + title: string + /** 子类选项 */ + subTypes: SubTypeItem[] +} + +/** 热门推荐-子类选项 */ +export type SubTypeItem = { + /** 子类id */ + id: string + /** 子类标题 */ + title: string + /** 子类对应的商品集合 */ + goodsItems: PageResult +}