From 500078714411487af00161e01bd7e0b5efdc3414 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期四, 07 八月 2025 13:32:32 +0800
Subject: [PATCH] add:热门景点
---
sub-pages/film-list/film-list.vue | 97 ++++++++++++++++++++++++++++++++----------------
1 files changed, 64 insertions(+), 33 deletions(-)
diff --git a/sub-pages/film-list/film-list.vue b/sub-pages/film-list/film-list.vue
index f069e46..4a4e54d 100644
--- a/sub-pages/film-list/film-list.vue
+++ b/sub-pages/film-list/film-list.vue
@@ -30,31 +30,69 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { onLoad, onShow, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
-import { FilmCategoryTree,FilmWorks } from '@/types/index'
+import { FilmCategoryTree,FilmWorks,FilmWorksQueryDTO } from '@/types/index'
import { useGlobal } from '@/composables/useGlobal'
const { $http, $message, $store } = useGlobal()
import { FilmTabCategory,FilmWorksCategory } from '@/enums/dict'
import { useNavigator } from '@/composables/useNavigator'
const { navigateTo } = useNavigator()
-import { getTabList } from '@/sub-pages/utils/api'
+import { getTabList,getFilmWorksBase } from '@/sub-pages/utils/api'
+import { useUserStore } from '@/store/user'
const theme = ref('light')
const search = ref('')
+const keywords = ref('') // 新增关键词状态
const tabList = ref<FilmCategoryTree[]>([])
+const currentCategory = ref('') // 默认为空表示全部
const onSearch = (value: string) => {
- uni.showToast({
- title: `搜索:${value}`,
- icon: 'none'
+ const searchValue = typeof value === 'string' ? value : search.value
+ keywords.value = searchValue
+ filmPage.value = 1
+ films.value = []
+ filmStatus.value = 'loadmore'
+ getfilms()
+
+}
+
+const click = (item: FilmCategoryTree) => {
+ currentCategory.value = item.name // 更新当前分类
+ keywords.value = search.value
+ filmPage.value = 1 // 重置页码
+ films.value = [] // 清空电影列表
+ filmStatus.value = 'loadmore' // 重置加载状态
+ getfilms() // 重新加载数据
+}
+
+const handleDetailClick = async (item: FilmCategoryTree) => {
+ const userStore = useUserStore()
+ // 尝试获取最新用户信息验证登录状态
+ try {
+ await userStore.getCurrentInfo()
+ if (userStore.hasLogin) {
+ navigateTo(`/sub-pages/film-list/film-detail?id=${item.id}`)
+ } else {
+ showLoginModal()
+ }
+ } catch (err) {
+ console.error('验证登录状态失败:', err)
+ showLoginModal()
+ }
+ // const urlOfficicl=`/sub-pages/film-list/film-official-detail?id=${item.id}`;
+ // const url= `/sub-pages/film-list/film-detail?id=${item.id}`
+ // navigateTo(url)
+}
+
+const showLoginModal = () => {
+ uni.showModal({
+ title: '登录提示',
+ content: '查看详情需要登录,是否前往登录?',
+ confirmText: '去登录',
+ success: (res) => {
+ if(res.confirm) uni.navigateTo({ url: '/pages/login/login' })
+ }
})
}
-
-const handleDetailClick = (item: FilmCategoryTree) => {
- const urlOfficicl=`/sub-pages/film-list/film-official-detail?id=${item.id}`;
- const url= `/sub-pages/film-list/film-detail?id=${item.id}`
- navigateTo(url)
-}
-
const showToast = (msg: string) => {
uni.showToast({ title: msg, icon: 'none' })
}
@@ -66,7 +104,7 @@
onMounted(() => {
- flowList.value = items
+
})
onShow(() => {
@@ -96,11 +134,19 @@
const filmStatus = ref('loading')
const getfilms = async () => {
if (filmStatus.value === 'nomore') return
-
filmStatus.value = 'loading'
- // TODO 暂时使用光影社区的类别
- const records = await getFilmWorksBase('', filmSize, filmPage.value)
+ // TODO 暂时使用光影的类别
+ const query: FilmWorksQueryDTO = {
+ category: currentCategory.value, // 将当前分类ID加入查询参数
+ classify: '',
+ type: '',
+ current: filmPage.value,
+ size: filmSize,
+ status: 'published',
+ keywords: keywords.value // 关键修改
+ };
+ const records = await getFilmWorksBase(query)
if (records && records.length > 0) {
// 使用 Set 进行去重
@@ -120,23 +166,8 @@
}
}
-const getFilmWorksBase = async (type: String, pageSize: Number, currentPage: Number) => {
- const {
- code, data
- } = await $http.request('get', '/api/filmWorks/list', {
- params: {
- classify: type,
- size: pageSize,
- current: currentPage
- }
- })
- if (code == 0) {
- return data.records
- } else {
- $message.showToast('系统异常,无法获取数据')
- return null;
- }
-}
+
+
--
Gitblit v1.9.3