diff --git a/components/kl-card-picture/index.vue b/components/kl-card-picture/index.vue index 840af71..69dd064 100644 --- a/components/kl-card-picture/index.vue +++ b/components/kl-card-picture/index.vue @@ -46,11 +46,11 @@ }, }) - const handleClick = () => { + const handleClick = async () => { console.log(props.itemInfo) // 跳转到下载详情页 并且是单独开标签 - navigateTo(`/down-drawe-detail/${props.itemInfo.id}`) // 修改为在新窗口打开 + await navigateTo(`/down-drawe-detail/${props.itemInfo.id}`) // 修改为在新窗口打开 } diff --git a/package.json b/package.json index 013f180..94c32d8 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "pdfjs-dist": "^5.4.54", "pinia": "^3.0.3", "qrcode.vue": "^3.6.0", + "swiper": "^11.2.10", "tinymce": "^6.2.0", "vue": "^3.5.18", "vue-pdf-embed": "^2.1.3", diff --git a/pages/down-drawe-detail/[id].vue b/pages/down-drawe-detail/[id].vue index 17d0517..87ef878 100644 --- a/pages/down-drawe-detail/[id].vue +++ b/pages/down-drawe-detail/[id].vue @@ -96,15 +96,15 @@
-
图纸ID: {{ detail?.id }}
-
文件大小:{{ detail?.filesInfo?.fileSize || 0 }}
+
图纸ID: {{ detail?.id }}
+
文件大小:{{ detail?.filesInfo?.fileSize || 0 }}
-
图纸格式:{{ detail?.formatType?.toString() }}
-
所需金币:{{ detail?.points }}金币
-
发布时间:{{ dayjs(detail?.createTime).format('YYYY-MM-DD HH:mm:ss') }}
-
图纸参数:{{ detail?.editTypeName }}
-
图纸分类:{{ detail?.projectTypeName }}
-
软件分类:{{ detail?.editionsName }}
+
图纸格式:{{ detail?.formatType?.toString() }}
+
所需金币:{{ detail?.points }}金币
+
发布时间:{{ dayjs(detail?.createTime).format('YYYY-MM-DD HH:mm:ss') }}
+
图纸参数:{{ detail?.editTypeName }}
+
图纸分类:{{ detail?.projectTypeName }}
+
软件分类:{{ detail?.editionsName }}
@@ -179,7 +179,7 @@ import ThumBnail from './components/swiper.vue' import CommentSection from '~/components/comment-section/index.vue' import { useRoute } from 'vue-router' - import { ref } from 'vue' + import { onMounted } from 'vue' import type { ProjectRespVO, ProjectDrawPageRespVO, UserExtendSimpleRespDTO, ProjectDrawMemberRespVO } from '~/api/drawe-detail/types' import useUserStore from '~/stores/user' const message = useMessage() @@ -187,15 +187,19 @@ // 获取路由参数 const route = useRoute() const id = route.params.id as string + // 获取详情 // const detail = ref({} as ProjectRespVO) - const {data: detail } = await useAsyncData('getDetail', async () => { + const {data: detail, refresh: refreshDetail } = await useAsyncData(`getDetail${id}`, async () => { const res = await getDetail({ id }) return res.data }) + console.log('==', detail.value); + + if (!detail.value) { throw createError({ statusCode: 404, @@ -219,35 +223,41 @@ // } // init() + + const [{data:mainWork},{data:userInfo},{data:relationRecommend}] = await Promise.all([ + getMainWork({ id: detail.value?.id, limit: 10, memberId: detail.value?.ownedUserId }), + getUserInfo({ id: detail.value?.id }), + getRelationRecommend({ type: detail.value?.type, projectType: detail.value?.projectType[0] }) + ]) // 获取最新发布 - const mainWork = ref([]) - const handleGetMainWork = () => { - getMainWork({ id: detail.value?.id, limit: 10, memberId: detail.value?.ownedUserId }).then((res) => { - if (res.code === 0) { - mainWork.value = res.data - } - }) - } + // const mainWork = ref([]) + // const handleGetMainWork = () => { + // getMainWork({ id: detail.value?.id, limit: 10, memberId: detail.value?.ownedUserId }).then((res) => { + // if (res.code === 0) { + // mainWork.value = res.data + // } + // }) + // } // 获取用户信息 - const userInfo = ref({} as UserExtendSimpleRespDTO) - const handleGetUserInfo = () => { - getUserInfo({ id: detail.value?.id }).then((res) => { - if (res.code === 0) { - userInfo.value = res.data - } - }) - } + // const userInfo = ref({} as UserExtendSimpleRespDTO) + // const handleGetUserInfo = () => { + // getUserInfo({ id: detail.value?.id }).then((res) => { + // if (res.code === 0) { + // userInfo.value = res.data + // } + // }) + // } // 获取关联推荐 - const relationRecommend = ref([]) - const getRelationRecommendList = () => { - getRelationRecommend({ type: detail.value?.type, projectType: detail.value?.projectType[0] }).then((res) => { - if (res.code === 0) { - relationRecommend.value = res.data - } - }) - } + // const relationRecommend = ref([]) + // const getRelationRecommendList = () => { + // getRelationRecommend({ type: detail.value?.type, projectType: detail.value?.projectType[0] }).then((res) => { + // if (res.code === 0) { + // relationRecommend.value = res.data + // } + // }) + // } const changeSwiper = (index: number) => { console.log(index) @@ -350,7 +360,7 @@ }) if (res.code === 0) { ElMessage.success(`${detail.value?.favoriteId ? '取消' : '收藏'}成功`) - // init() + refreshDetail() } } diff --git a/yarn.lock b/yarn.lock index cc2c3ba..fa33d06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6441,7 +6441,7 @@ svgo@^4.0.0: picocolors "^1.1.1" sax "^1.4.1" -swiper@^11.2.6: +swiper@^11.2.10, swiper@^11.2.6: version "11.2.10" resolved "https://registry.yarnpkg.com/swiper/-/swiper-11.2.10.tgz#ed0b17286b56f7fe8d4b46ed61e6e0bd8daaccad" integrity sha512-RMeVUUjTQH+6N3ckimK93oxz6Sn5la4aDlgPzB+rBrG/smPdCTicXyhxa+woIpopz+jewEloiEE3lKo1h9w2YQ==