feat(国内资讯): 添加国内资讯详情功能及页面跳转
- 在domesticMini.vue中添加跳转到详情页的功能 - 在api/index.ts中新增获取国内资讯详情的接口 - 修改indexNewsInfo.vue以支持国内资讯详情展示 - 更新minihome/index.vue的tab切换逻辑
This commit is contained in:
parent
a82d86efc2
commit
d74ce73971
|
|
@ -72,7 +72,12 @@ export const doShare = (data: any) => {
|
||||||
return Request.post("/user/share", data);
|
return Request.post("/user/share", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 微信分享
|
// 国内资讯列表
|
||||||
export const getDomestic = (data: any) => {
|
export const getDomestic = (data: any) => {
|
||||||
return Request.get("/news/domestic", data);
|
return Request.get("/news/domestic", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 国内资讯详情
|
||||||
|
export const getDomesticDetail = (data: any) => {
|
||||||
|
return Request.get(`/news/domestic/${data.id}`);
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@ const form = reactive({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function doDetail(item) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/detail/indexNewsInfo?id=" + item.id + "&type=guonei",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function getDomesticFn() {
|
async function getDomesticFn() {
|
||||||
uni.showLoading();
|
uni.showLoading();
|
||||||
let { code, data } = await getDomestic({
|
let { code, data } = await getDomestic({
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
<!-- 底部栏 评论 / 收藏 -->
|
<!-- 底部栏 评论 / 收藏 -->
|
||||||
<Comment
|
<Comment
|
||||||
v-if="isLogin"
|
v-if="isLogin && !isDomestic"
|
||||||
:data="data"
|
:data="data"
|
||||||
@handleClickLike="handleClickLike"
|
@handleClickLike="handleClickLike"
|
||||||
@handleClickStar="handleClickStar"
|
@handleClickStar="handleClickStar"
|
||||||
|
|
@ -88,7 +88,7 @@ import {
|
||||||
fetchArticleLike,
|
fetchArticleLike,
|
||||||
fetchArticleFavorate,
|
fetchArticleFavorate,
|
||||||
} from "@/api/detail";
|
} from "@/api/detail";
|
||||||
import { getNewsList, doShare } from "@/api";
|
import { getNewsList, doShare, getDomesticDetail } from "@/api";
|
||||||
import Article from "@/components/article/indexNewsInfo.vue";
|
import Article from "@/components/article/indexNewsInfo.vue";
|
||||||
import Column from "@/components/column/index.vue";
|
import Column from "@/components/column/index.vue";
|
||||||
import Comment from "@/components/comment/indexMini.vue";
|
import Comment from "@/components/comment/indexMini.vue";
|
||||||
|
|
@ -109,10 +109,22 @@ onReachBottom(() => {
|
||||||
console.log("🚀 ~ onReachBottom ~ onReachBottom:");
|
console.log("🚀 ~ onReachBottom ~ onReachBottom:");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isDomestic = ref<boolean>(false);
|
||||||
onLoad(async (option: any) => {
|
onLoad(async (option: any) => {
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
});
|
});
|
||||||
|
if (option?.type == "guonei") {
|
||||||
|
isDomestic.value = true;
|
||||||
|
let res = await getDomesticDetail({ id: option.id });
|
||||||
|
if (res.code === 200) {
|
||||||
|
data.value = res.data;
|
||||||
|
|
||||||
|
data.value.content = res.data.content.replace(/\n{3,}/g, "\n");
|
||||||
|
|
||||||
|
columnName.value = data.columnName1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
newType.value = option.type || 14;
|
newType.value = option.type || 14;
|
||||||
const res = await fetchArticleDetail({
|
const res = await fetchArticleDetail({
|
||||||
id: option.id,
|
id: option.id,
|
||||||
|
|
@ -128,6 +140,7 @@ onLoad(async (option: any) => {
|
||||||
newList(res.data.columnId1);
|
newList(res.data.columnId1);
|
||||||
wxShare();
|
wxShare();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const newList = async (columnId: number) => {
|
const newList = async (columnId: number) => {
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,9 @@ function tabChange(index) {
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
uni.setStorageSync("homeTabIndex", 2);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,8 +160,11 @@ onPageScroll((val) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
if (uni.getStorageSync("homeTabIndex") == 1) {
|
if (
|
||||||
tabChange(1);
|
uni.getStorageSync("homeTabIndex") == 1 ||
|
||||||
|
uni.getStorageSync("homeTabIndex") == 2
|
||||||
|
) {
|
||||||
|
tabChange(uni.getStorageSync("homeTabIndex"));
|
||||||
} else {
|
} else {
|
||||||
tabChange(0);
|
tabChange(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue