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);
|
||||
};
|
||||
|
||||
// 微信分享
|
||||
// 国内资讯列表
|
||||
export const getDomestic = (data: any) => {
|
||||
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,
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -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,10 +109,22 @@ onReachBottom(() => {
|
|||
console.log("🚀 ~ onReachBottom ~ onReachBottom:");
|
||||
});
|
||||
|
||||
const isDomestic = ref<boolean>(false);
|
||||
onLoad(async (option: any) => {
|
||||
uni.pageScrollTo({
|
||||
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;
|
||||
const res = await fetchArticleDetail({
|
||||
id: option.id,
|
||||
|
|
@ -128,6 +140,7 @@ onLoad(async (option: any) => {
|
|||
newList(res.data.columnId1);
|
||||
wxShare();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const newList = async (columnId: number) => {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue