From 7ee6309073fdc9fd38979accabb733cee42cefaa Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期一, 09 六月 2025 14:59:55 +0800
Subject: [PATCH] 商品api接口
---
pages/tabbar/index/home.vue | 40 ++++++++++++++++++++++++++++++----------
1 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/pages/tabbar/index/home.vue b/pages/tabbar/index/home.vue
index d3b82cc..e65155f 100644
--- a/pages/tabbar/index/home.vue
+++ b/pages/tabbar/index/home.vue
@@ -66,14 +66,14 @@
</view>
<view style="width: 100%;word-wrap: break-word;white-space: normal;overflow-wrap: break-word;">
<text class="video-title">{{item.title}}</text>
- <text class="video-tag" v-for="(tag, index) in item.tagList" :key="tag">#{{tag.tagName}}</text>
+ <text class="video-tag" v-for="(tag, index) in item.tagList" :key="tag.id">#{{tag.tagName}}</text>
</view>
</view>
<!-- 鍙充晶浜掑姩鎸夐挳 -->
<view class="action-buttons">
<view class="avatar-container">
- <image class="avatar" :src="item.authorAvatar" mode="aspectFill"></image>
+ <image class="avatar" @click="jumpToHomePage(item.authorId)" :src="item.authorAvatar" mode="aspectFill"></image>
<!-- 鍏虫敞鍥炬爣 - 浣跨敤缁濆瀹氫綅 -->
<view v-if="!item.subscribeThisAuthor" class="follow-icon" @click="subscribeAuth(index, item.authorId)">
<text class="iconfont"></text>
@@ -183,6 +183,7 @@
export default {
data() {
return {
+ videoNoMore: false, // 鏄惁杩樻湁鏇村瑙嗛
commentNoMore: false, // 鏄惁杩樻湁鏇村璇勮
commentQuery: {
pageNumber: 1,
@@ -228,8 +229,11 @@
], // 瑙嗛鍒楄〃鏁版嵁
videoContexts: [], // 瑙嗛涓婁笅鏂囧璞¢泦鍚�
loading: false, // 鏄惁姝e湪鍔犺浇
- page: 1, // 褰撳墠椤电爜
- pageSize: 10 // 姣忛〉鏁伴噺
+ videoQuery: {
+ pageNumber: 1,
+ pageSize: 6,
+ videoFrom: 'recommend'
+ }
}
},
onShow() {
@@ -251,6 +255,12 @@
this.initVideoContexts();
},
methods: {
+ // 璺宠浆涓汉涓婚〉
+ jumpToHomePage(authorId) {
+ uni.navigateTo({
+ url: "/pages/video/home-page?authorId=" + authorId
+ })
+ },
// 鍙栨秷鐐硅禐
async cancelThumbsUp(id, commentIndex, replyIndex) {
const data = {
@@ -487,22 +497,31 @@
// 鍔犺浇瑙嗛鏁版嵁
async loadVideos() {
- if (this.loading) return;
+ if (this.loading || this.videoNoMore) return;
this.loading = true;
- getRecommendVideos({pageNumber: this.page, pageSize: this.pageSize}).then(res => {
+ getRecommendVideos(this.videoQuery).then(res => {
console.log(res, "瑙嗛鏁版嵁");
- if (this.page === 1) {
+ if (this.videoQuery.pageNumber === 1) {
this.videoList = res.data.data;
} else {
- this.videoList = [...this.videoList, ...res.data.data];
+ this.videoList = [
+ ...this.videoList,
+ ...res.data.data.filter(
+ (newItem) => !this.videoList.some((oldItem) => oldItem.id === newItem.id)
+ ),
+ ];
}
-
- this.page++;
this.$nextTick(() => {
this.initVideoContexts();
});
this.loading = false;
+ if(res.data.data.length < this.videoQuery.pageSize) {
+ this.videoNoMore = true;
+ return;
+ }
+ this.videoQuery.pageNumber++;
+
})
},
@@ -556,6 +575,7 @@
},
// 鍗曞嚮灞忓箷锛氭殏鍋滄垨缁х画鎾斁
togglePlay(index) {
+ console.log("鍗曞嚮瑙嗛", index, this.videoContexts);
if(this.currentVideoIsPlaying) {
this.videoContexts[index].pause();
} else {
--
Gitblit v1.8.0