feat(国内资讯): 添加国内资讯详情功能及页面跳转

- 在domesticMini.vue中添加跳转到详情页的功能
- 在api/index.ts中新增获取国内资讯详情的接口
- 修改indexNewsInfo.vue以支持国内资讯详情展示
- 更新minihome/index.vue的tab切换逻辑
This commit is contained in:
zzp 2025-08-30 20:33:45 +08:00
parent a82d86efc2
commit d74ce73971
4 changed files with 48 additions and 17 deletions

View File

@ -72,7 +72,12 @@ export const doShare = (data: any) => {
return Request.post("/user/share", data);
};
// 微信分享
// 国内资讯列表
export const getDomestic = (data: any) => {
return Request.get("/news/domestic", data);
};
};
// 国内资讯详情
export const getDomesticDetail = (data: any) => {
return Request.get(`/news/domestic/${data.id}`);
};

View File

@ -19,6 +19,13 @@ const form = reactive({
pageNum: 1,
pageSize: 10,
});
function doDetail(item) {
uni.navigateTo({
url: "/pages/detail/indexNewsInfo?id=" + item.id + "&type=guonei",
});
}
async function getDomesticFn() {
uni.showLoading();
let { code, data } = await getDomestic({

View File

@ -50,7 +50,7 @@
<!-- 底部栏 评论 / 收藏 -->
<Comment
v-if="isLogin"
v-if="isLogin && !isDomestic"
:data="data"
@handleClickLike="handleClickLike"
@handleClickStar="handleClickStar"
@ -88,7 +88,7 @@ import {
fetchArticleLike,
fetchArticleFavorate,
} from "@/api/detail";
import { getNewsList, doShare } from "@/api";
import { getNewsList, doShare, getDomesticDetail } from "@/api";
import Article from "@/components/article/indexNewsInfo.vue";
import Column from "@/components/column/index.vue";
import Comment from "@/components/comment/indexMini.vue";
@ -109,24 +109,37 @@ onReachBottom(() => {
console.log("🚀 ~ onReachBottom ~ onReachBottom:");
});
const isDomestic = ref<boolean>(false);
onLoad(async (option: any) => {
uni.pageScrollTo({
scrollTop: 0,
});
newType.value = option.type || 14;
const res = await fetchArticleDetail({
id: option.id,
// id: 763,
});
if (option?.type == "guonei") {
isDomestic.value = true;
let res = await getDomesticDetail({ id: option.id });
if (res.code === 200) {
data.value = res.data;
if (res.code === 200) {
data.value = res.data;
data.value.content = res.data.content.replace(/\n{3,}/g, "\n");
res.data.content = res.data.content.replace(/\n{3,}/g, "\n");
columnName.value = data.columnName1;
}
} else {
newType.value = option.type || 14;
const res = await fetchArticleDetail({
id: option.id,
// id: 763,
});
columnName.value = res.data.columnName1;
newList(res.data.columnId1);
wxShare();
if (res.code === 200) {
data.value = res.data;
res.data.content = res.data.content.replace(/\n{3,}/g, "\n");
columnName.value = res.data.columnName1;
newList(res.data.columnId1);
wxShare();
}
}
});

View File

@ -124,6 +124,9 @@ function tabChange(index) {
break;
case 1:
break;
case 2:
uni.setStorageSync("homeTabIndex", 2);
break;
}
}
@ -157,8 +160,11 @@ onPageScroll((val) => {
});
onShow(() => {
if (uni.getStorageSync("homeTabIndex") == 1) {
tabChange(1);
if (
uni.getStorageSync("homeTabIndex") == 1 ||
uni.getStorageSync("homeTabIndex") == 2
) {
tabChange(uni.getStorageSync("homeTabIndex"));
} else {
tabChange(0);
}