diff --git a/src/components/JbcGuess.vue b/src/components/JbcGuess.vue
new file mode 100644
index 0000000..72fe3be
--- /dev/null
+++ b/src/components/JbcGuess.vue
@@ -0,0 +1,153 @@
+
+
+
+ 猜你喜欢
+
+
+
+
+ {{ item.name }}
+
+ ¥
+ {{ item.price }}
+
+
+
+
+ {{ finish ? '没有更多数据~' : '正在加载...' }}
+
+
+
+
+
+
diff --git a/src/pages/index/components/HotPanel.vue b/src/pages/index/components/HotPanel.vue
index 1a2e356..7108778 100644
--- a/src/pages/index/components/HotPanel.vue
+++ b/src/pages/index/components/HotPanel.vue
@@ -45,6 +45,7 @@ defineProps<{
font-size: 32rpx;
color: #262626;
position: relative;
+
.title-desc {
font-size: 24rpx;
color: #7f7f7f;
@@ -59,20 +60,25 @@ defineProps<{
height: 254rpx;
border-right: 1rpx solid #eee;
border-top: 1rpx solid #eee;
+
.title {
justify-content: start;
}
+
&:nth-child(2n) {
border-right: 0 none;
}
+
&:nth-child(-n + 2) {
border-top: 0 none;
}
+
.image {
width: 150rpx;
height: 150rpx;
}
}
+
.cards {
flex: 1;
padding: 15rpx 20rpx;
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 21c04bc..549d9e7 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -3,13 +3,15 @@
-
+
+
+
@@ -22,6 +24,7 @@ import { getCategory, getHomeBanner, getHomeHot } from '@/services/home'
import { onLoad } from '@dcloudio/uni-app'
import CategoryPanel from './components/CategoryPanel.vue'
import HotPanel from './components/HotPanel.vue'
+import type { JbcGuessInstance } from '@/types/components'
// 获取轮播图数据
const bannerList = ref([])
@@ -42,8 +45,17 @@ const hotList = ref([])
const getHotList = async () => {
const res = await getHomeHot()
hotList.value = res.result
- console.log('hotList: ', hotList.value)
}
+
+// 猜你喜欢 实例
+const guessRef = ref()
+
+// 滚动到底部调用子组件的方法
+const onScrollToLower = () => {
+ guessRef.value?.getMore()
+}
+
+// 页面加载勾子
onLoad(() => {
getBannerList()
getCategoryList()
@@ -59,12 +71,12 @@ page {
}
.viewport {
- height: 100%;
display: flex;
flex-direction: column;
+ height: 100%;
}
-.scroll-view {
+.scrool-view {
flex: 1;
overflow: hidden;
}
diff --git a/src/services/home.ts b/src/services/home.ts
index a7917a2..79097bb 100644
--- a/src/services/home.ts
+++ b/src/services/home.ts
@@ -1,4 +1,5 @@
-import type { BannerItem, CategoryItem, HotItem } from '@/types/home'
+import type { PageParams, PageResult } from '@/types/global'
+import type { BannerItem, CategoryItem, GuessItem, HotItem } from '@/types/home'
import { http } from '@/utils/http'
/**
@@ -37,3 +38,16 @@ export const getHomeHot = () => {
method: 'GET',
})
}
+
+/**
+ * 获取首页猜你喜欢
+ * @param data - 分页参数
+ * @returns 猜你喜欢数据
+ */
+export const getGuessLike = (data?: PageParams) => {
+ return http>({
+ url: '/home/goods/guessLike',
+ method: 'GET',
+ data,
+ })
+}
diff --git a/src/types/components.d.ts b/src/types/components.d.ts
index adae446..31099f9 100644
--- a/src/types/components.d.ts
+++ b/src/types/components.d.ts
@@ -1,10 +1,13 @@
import JbcSwiper from '@/components/JbcSwiper.vue'
+import JbcGuess from '@/components/JbcGuess.vue'
declare module 'vue' {
export interface GlobalComponents {
JbcSwiper: typeof JbcSwiper
+ JbcGuess: typeof JbcGuess
}
}
// 组件实例类型
export type JbcSwiperInstance = InstanceType
+export type JbcGuessInstance = InstanceType