feat: 实现导航栏高度计算及多页面适配

refactor: 优化请求拦截器处理逻辑

style: 更新Tabbar组件样式及图标资源

feat(rank): 添加排行榜前三名特殊样式图标

fix(detail): 修复GET请求参数处理问题

feat(home): 新增首页顶部背景及搜索区域

refactor(util): 移除无用代码并添加日志调试

fix(api): 修正行业和概念标签请求参数格式

feat(minihome): 实现首页轮播图及样式调整
This commit is contained in:
34701892@qq.com 2025-08-15 13:44:27 +08:00
parent 126f48d883
commit 1ba80c041c
14 changed files with 333 additions and 90 deletions

View File

@ -1,4 +1,4 @@
import request from "@/utils";
import request from "@/utils/index";
/**
*
@ -33,10 +33,11 @@ export const fetchArticleFavorate = (data: any) => {
// 热门行业
export const getListByTagIndustry = (data: any) => {
return request.get(`/news/list/industry?name=${data.name}`);
console.log("🚀 ~ getListByTagIndustry ~ data:", data)
return request.get("/news/list/industry", { name: data.name });
};
// 概念标签
export const getListByTag = (data: any) => {
return request.get(`/news/list/tag?name=${data.name}`);
return request.get("/news/list/tag", { name: data.name });
};

View File

@ -4,7 +4,16 @@
<view class="list" v-else>
<view v-for="(item, index) in rankListLocal" :key="index" class="news-item" @click="goDetail(item, 0)">
<view class="rank-tag">
<text class="rank-text">{{ index + 1 }}</text>
<view v-if="index == 0" class="rank-text-top3">
<image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/icon_top_1.png" />
</view>
<view v-else-if="index == 1" class="rank-text-top3">
<image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/icon_top_2.png" />
</view>
<view v-else-if="index == 2" class="rank-text-top3">
<image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/icon_top_3.png" />
</view>
<text class="rank-text" v-else>{{ index + 1 }}</text>
</view>
<!-- :style="{ filter: Session.get('token') ? '' : 'blur(5px)' }" -->
@ -18,9 +27,9 @@
dayjs(item.publish_time).format("YYYY-MM-DD HH:MM:ss")
}}</text>
</view>
<text class="score">
<!-- <text class="score">
<text v-if="index < 3">资讯评分</text>
{{ item.news_score }}</text>
{{ item.news_score }}</text> -->
</view>
</view>
</view>
@ -33,8 +42,8 @@
<img src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/down_icon.png" class="exp_up" v-else />
</view>
<LoginPopup :show="LoginShow" @handlePopupClose="handlePopupClose"
@handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" />
<!-- <LoginPopup :show="LoginShow" @handlePopupClose="handlePopupClose"
@handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" /> -->
</view>
</template>
@ -159,7 +168,7 @@ const handlePopupErrorCallback = () => {
text-align: left;
font-style: normal;
img {
image {
width: 33rpx;
height: 41rpx;
margin-top: -10rpx;
@ -167,11 +176,30 @@ const handlePopupErrorCallback = () => {
}
.rank-text {
font-family: PingFangSC, PingFang SC;
font-weight: bold;
font-size: 28rpx;
color: #e98254;
// font-family: PingFangSC, PingFang SC;
// font-weight: bold;
// font-size: 28rpx;
// color: #e98254;
width: 32rpx;
height: 30rpx;
margin-top: -20rpx;
background: #f5f5f5;
border-radius: 8rpx;
font-family: AvantiBold;
font-size: 24rpx;
color: #5A5A5A;
line-height: 26rpx;
text-align: left;
font-style: normal;
display: flex;
text-align: center;
justify-content: center;
align-items: center;
}
.news-content {

View File

@ -43,9 +43,14 @@
</view>
<view style="padding: 35rpx;">
<text class="articleDes" :class="props?.data?.needpay && 'needpay'" style="white-space: pre-wrap;"
<!-- <text class="articleDes" :class="props?.data?.needpay && 'needpay'" style="white-space: pre-wrap;"
v-html="props.data.content">
</text>
</text> -->
<rich-text class="articleDes" :class="props?.data?.needpay && 'needpay'" style="white-space: pre-wrap;"
v-html="props.data.content"></rich-text>
</view>
<!-- <view

View File

@ -1,5 +1,6 @@
<template>
<view class="mine">
<PageHeaderView title="个人中心"></PageHeaderView>
<!-- 用户信息 -->
<view class="userContainer">
<u-avatar src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/images/avatar.png" size="60"></u-avatar>
@ -92,6 +93,8 @@ import { onPullDownRefresh, onShow } from "@dcloudio/uni-app";
import { Session } from "@/utils/storage";
import LoginPopup from "@/components/loginPopup/index.vue";
import { useShareStore } from "@/stores/shareStore";
import PageHeaderView from "@/components/PageHeaderView.vue";
const stores = useShareStore();
const curPages = getCurrentPages();

View File

@ -2,21 +2,22 @@
<view class="tabbar">
<view class="tabbar_item" @click="tabChange(0)">
<image v-if="tabIndex == 1"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/home_icon_normal.png"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/home_icon_normal.pngg"
class="tabbar_img" />
<image v-if="tabIndex == 0"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/home_icon_press.png"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/home_icon_pre.png"
class="tabbar_img" />
<text class="tabbar_title" :style="{ color: tabIndex == 0 ? '#3F80FA' : '#666666' }">首页</text>
<text class="tabbar_title" :style="{ color: tabIndex == 0 ? '#D13E3C' : '#757A80' }">海外资讯</text>
</view>
<view class="tabbar_item" @click="tabChange(1)">
<image v-if="tabIndex == 0"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/all_icon_normal.png"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/mine_icon_normal.png"
class="tabbar_img" />
<image v-if="tabIndex == 1"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/all_icon_press.png" class="tabbar_img" />
<text class="tabbar_title" :style="{ color: tabIndex == 1 ? '#3F80FA' : '#666666' }">全部</text>
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/mine_icon_pre.png"
class="tabbar_img" />
<text class="tabbar_title" :style="{ color: tabIndex == 1 ? '#D13E3C' : '#757A80' }">全部</text>
</view>
</view>
</template>
@ -38,12 +39,15 @@ onMounted(async () => { });
<style scoped lang="scss">
.tabbar {
display: flex;
width: 100vw;
height: 150rpx;
position: fixed;
bottom: 0;
left: 0;
box-shadow: 0 -2rpx 10rpx rgba(128, 128, 128, 0.2);
width: 100vw;
background-color: white;
z-index: 9999999;
.tabbar_item {
width: 50%;

View File

@ -1,8 +1,7 @@
<template>
<view class="tabs">
<u-tabs :list="list1" :activeStyle="{
color: '#303133',
fontWeight: 'bold',
<!-- <u-tabs :list="list1" :activeStyle="{
color: '#AF201E',
transform: 'scale(1.05)',
fontSize: '24rpx'
}" :inactiveStyle="{
@ -12,7 +11,15 @@
}" :itemStyle="{
width: '27.5vw',
height: '70rpx',
}" @click="click"></u-tabs>
}" lineColor="#AF201E" v-model="tabIndex" :current="0" @change="tabChange"></u-tabs> -->
<view v-for="(item, index) in list1" :key="index" :class="['tab_item', tabIndex == index ? 'active' : '']"
@click="tabChange({ index: index, name: item.name })">
<text>{{ item.name }}</text>
<view class="line" v-if="tabIndex == index"></view>
</view>
</view>
</template>
@ -28,13 +35,65 @@ const list1 = reactive([
]);
const tabIndex = ref(0);
function tabChange(index) {
tabIndex.value = index;
emit("tabChange", index);
function tabChange(item) {
console.log("🚀 ~ tabChange ~ item:", item)
tabIndex.value = 0;
if (item.index == 1) {
uni.navigateTo({
url: '/pages/realtimeInfo/rankDetail?type=0'
})
} else if (item.index == 2) {
uni.navigateTo({
url: '/pages/realtimeInfo/rankDetail?type=1'
})
}
else {
emit("tabChange", item.index);
}
}
onMounted(async () => { });
</script>
<style scoped lang="scss"></style>
<style scoped lang="scss">
.tabs {
background-color: white;
display: flex;
.tab_item {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 28rpx;
color: #6B727A;
line-height: 40rpx;
text-align: left;
font-style: normal;
width: 33vw;
height: 50rpx;
display: flex;
flex-direction: column;
text-align: center;
justify-content: space-between;
align-items: center;
}
.active {
font-family: PingFangSC, PingFang SC;
font-weight: 500;
font-size: 30rpx;
color: #AF201E;
line-height: 42rpx;
text-align: left;
font-style: normal;
}
.line {
width: 40rpx;
height: 5rpx;
background: #AF201E;
}
}
</style>

View File

@ -1,4 +1,5 @@
// const baseURL = "http://192.168.31.25:8060/api";
// export const baseUrl = "http://192.168.3.38:8040/apih5";
export const baseUrl = "https://cankao.cs.com.cn/apih5";
export const baseUrlDataV = "https://cankao.cs.com.cn/zzck_datav";

View File

@ -7,7 +7,11 @@
"pages": [
//pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "pages/minihome/index"
"path": "pages/minihome/index",
"style": {
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
},
{
"path": "pages/realtimeInfo/index"
@ -18,6 +22,9 @@
{
"path": "pages/login/index"
},
{
"path": "pages/realtimeInfo/rankDetail"
},
{
"path": "pages/home/index",
"style": {
@ -52,9 +59,6 @@
{
"path": "pages/worldlyAffairs/index"
},
{
"path": "pages/realtimeInfo/rankDetail"
},
{
"path": "pages/realtimeInfo/home"
},

View File

@ -1,5 +1,7 @@
<template>
<view class="container">
<view :style="{ height: getNavHeight() + 'px' }"></view>
<!-- 导航栏 start -->
<view class="custom-bav-bar">
<view class="left">
@ -47,6 +49,9 @@ import Column from "@/components/column/index.vue";
import Comment from "@/components/comment/index.vue";
import { useShareStore } from "@/stores/shareStore";
import { Session } from "@/utils/storage";
import { getNavHeight } from "@/utils/util"
const stores = useShareStore();
const curPages = getCurrentPages();

View File

@ -1,11 +1,46 @@
<template>
<!-- 顶部 banner 区域 -->
<view class="all">
<Navbar title="中证参考" :hasBack="false"></Navbar>
<Tabs @tabChange="tabChange"></Tabs>
<!-- <Navbar title="中证参考" :hasBack="false"></Navbar> -->
<image class="top_bk" src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/top_bg.png"></image>
<view :style="{ height: getNavHeight() + 'px' }" v-if="tabIndex == 0"></view>
<view
:style="{ height: getNavHeight() + 'px', backgroundColor: '#fff', position: 'sticky', top: 0, zIndex: '999999' }"
v-else></view>
<view class="content">
<view :style="{ position: 'sticky', top: getNavHeight() + 'px' }" v-if="tabIndex == 0">
<view class="r_sreach">
<image class="logo_text" src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/logo_text_icon.png">
</image>
<view class="sreach">
<view class="sreach_icon">
<image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/icon_search_line.png"></image>
</view>
<view class="sreach_text">
<text>搜索资讯</text>
</view>
</view>
</view>
<view style="padding: 0 24rpx;margin-top: 30rpx;">
<u-swiper :list="list1" @change="change" @click="click"></u-swiper>
</view>
<view style="margin-top: 30rpx;">
<Tabs></Tabs>
</view>
</view>
<view style="margin-top: 30rpx;" v-if="tabIndex == 0">
<RankListMini :newsList="newsList"></RankListMini>
</view>
<MineMini v-if="tabIndex == 1"></MineMini>
</view>
<RankListMini v-if="tabIndex == 0" :newsList="newsList"></RankListMini>
<MineMini v-if="tabIndex == 1"></MineMini>
<Tabbar @tabChange="tabChange"></Tabbar>
</view>
</template>
@ -18,32 +53,106 @@ import RankListMini from "@/components/RankListMini.vue";
// const Mine = defineAsyncComponent(() => import("@/components/mine.vue"));
import MineMini from "@/components/mineMini.vue";
import Tabs from "@/components/mini/Tabs.vue";
import {
getTopNews,
} from "@/api/newsInfo";
import { onShow } from "@dcloudio/uni-app";
import { getNavHeight } from "@/utils/util"
const list1 = reactive([
'https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/banner1.png',
'https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/banner1.png',
'https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/banner1.png',
]);
const newsList = ref([]);
//
async function getNewsList() {
newsList.value = await getTopNews({});
uni.stopPullDownRefresh()
}
const tabIndex = ref(0);
function tabChange(index) {
tabIndex.value = index;
switch (index) {
case 0:
getNewsList()
break;
case 1:
break;
}
}
onShow(() => {
tabChange(0)
})
onMounted(async () => {
getNewsList()
});
</script>
<style scoped lang="scss"></style>
<style scoped lang="scss">
.top_bk {
width: 100%;
height: 300rpx;
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
.content {
position: relative;
z-index: 99999;
.r_sreach {
display: flex;
align-items: center;
padding: 0 30rpx;
}
.logo_text {
width: 88rpx;
height: 45rpx;
}
.sreach {
display: flex;
align-items: center;
padding: 0rpx 30rpx;
background-color: #fff;
border-radius: 100rpx;
width: 47vw;
height: 68rpx;
margin-left: 20rpx;
}
.sreach_icon {
margin-right: 10rpx;
display: flex;
align-items: center;
image {
width: 35rpx;
height: 35rpx;
margin-top: 5rpx;
}
}
.sreach_text {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: #999999;
line-height: 33rpx;
text-align: left;
font-style: normal;
}
}
</style>

View File

@ -1,19 +1,17 @@
<template>
<view class="all">
<PageHeaderView
:title="type == 0 ? '热门行业池Top10' : '风口概念池Top10'"
></PageHeaderView>
<!-- #ifdef MP-WEIXIN -->
<view :style="{ height: getNavHeight() + 'px' }"></view>
<!-- #endif -->
<PageHeaderView :title="type == 0 ? '热门行业池Top10' : '风口概念池Top10'"></PageHeaderView>
<!-- 类目标签 start -->
<view class="page_content">
<view class="tag_list">
<view
:class="['tag_item', clickTagIndex == index ? tagClickedClass : '']"
class="tag_item"
v-for="(item, index) in tagList"
:key="index"
@click="clickTag(index)"
>
<view :class="['tag_item', clickTagIndex == index ? tagClickedClass : '']" class="tag_item"
v-for="(item, index) in tagList" :key="index" @click="clickTag(index)">
{{ item.content }}
</view>
</view>
@ -22,12 +20,7 @@
<!-- 列表 start -->
<view class="list">
<view
v-for="(item, index) in list"
:key="index"
class="news-item"
@click="goDetail(item)"
>
<view v-for="(item, index) in list" :key="index" class="news-item" @click="goDetail(item)">
<view class="news-content">
<text class="news-title">{{ item.title }}</text>
<text class="news-desc">{{ item.summary }}</text>
@ -58,17 +51,19 @@ import {
import { getListByTag, getListByTagIndustry } from "@/api/detail";
import dayjs from "dayjs/esm/index";
import { onLoad } from "@dcloudio/uni-app";
import { getNavHeight } from "@/utils/util"
const props = defineProps({
type: {
type: String,
default: () => 0,
},
index: {
type: String,
default: () => 0,
},
});
// const props = defineProps({
// type: {
// type: String,
// default: () => 0,
// },
// index: {
// type: String,
// default: () => 0,
// },
// });
const clickTagIndex = ref(0);
@ -109,6 +104,7 @@ async function getTopConcept_dFn() {
topConceptList.value = await getTopConcept_d({});
}
const list = ref([]);
async function getListByTagFn() {
let id = 0;
@ -118,6 +114,8 @@ async function getListByTagFn() {
} else {
id = topConceptList.value[clickTagIndex.value].content;
}
console.log("🚀 ~ getListByTagFn ~ id:", id)
uni.showLoading();
if (props.type == 1) {
// id = 1125;
@ -145,8 +143,14 @@ function goDetail(item) {
}
const tagClickedClass = ref("");
onMounted(async () => {
if (props.type && props.type == 0) {
const props = reactive({
})
onLoad(async (e) => {
props.type = e.type
if (e.type && e.type == 0) {
//
tagClickedClass.value = "tag_item_act_blue";
// top10
@ -160,11 +164,15 @@ onMounted(async () => {
tagList.value = topConceptList.value;
}
if (props.index) {
if (e.index) {
clickTagIndex.value = props.index;
}
getListByTagFn();
})
onMounted(async () => {
});
</script>
@ -254,11 +262,16 @@ onMounted(async () => {
text-align: left;
font-style: normal;
display: -webkit-box; /* 设置为WebKit内核的弹性盒子模型 */
-webkit-box-orient: vertical; /* 垂直排列 */
-webkit-line-clamp: 2; /* 限制显示三行 */
overflow: hidden; /* 隐藏超出范围的内容 */
text-overflow: ellipsis; /* 使用省略号 */
display: -webkit-box;
/* 设置为WebKit内核的弹性盒子模型 */
-webkit-box-orient: vertical;
/* 垂直排列 */
-webkit-line-clamp: 2;
/* 限制显示三行 */
overflow: hidden;
/* 隐藏超出范围的内容 */
text-overflow: ellipsis;
/* 使用省略号 */
}
.news-meta {

View File

@ -10,10 +10,13 @@ Request.interceptors.request((request: any) => {
request.header["content-type"] = request.header.contentType;
delete request.header.contentType;
}
if (request.method === "GET") {
request.data = qs.stringify(request.data);
request.url = request.url + "?" + request.data;
}
// if (request.method === "GET") {
// request.data = qs.stringify(request.data);
console.log("🚀 ~ request.data:", request.data)
// request.url = request.url + "?" + request.data;
// }
return request;
});

View File

@ -21,6 +21,7 @@ class requestClass {
// 拦截器
interceptors = {
request: (func: Fn) => {
console.log("🚀 ~ requestClass ~ func:", func)
if (func) {
requestClass[requestBefore] = func;
} else {
@ -55,7 +56,14 @@ class requestClass {
options.url = requestClass[isCompleteURL](options.url)
? options.url
: options.baseURL + options.url;
options.data = options.data;
// 新增如果是GET请求且data为空对象则删除data
if (options.method === 'GET' && options.data && Object.keys(options.data).length === 0) {
delete options.data;
} else {
options.data = options.data;
}
options.header = { ...options.header, ...this[config].header };
options.method = options.method || this[config].method;
@ -69,17 +77,6 @@ class requestClass {
reject(requestClass[requestAfter](err));
};
uni.request(options);
// 中断请求实现方法
// let obj: any = {}
// obj[request.url] = uni.request(options)
// abortRequest() {
// for (const key in obj) {
// if (Object.prototype.hasOwnProperty.call(obj, key)) {
// const element = obj[key];
// element.abort()
// }
// }
// }
});
}

View File

@ -82,3 +82,14 @@ export const jumpUrl = (url) => {
};
export function getNavHeight() {
const systemInfo = uni.getSystemInfoSync();
console.log(systemInfo);
const statusBarHeight = systemInfo.statusBarHeight; // 状态栏高度
const navigationBarHeight = systemInfo.platform === 'android' ? statusBarHeight + 48 : statusBarHeight + 44; // 通常安卓底部有48px的导航栏iOS是44px
console.log('状态栏高度:', statusBarHeight);
console.log('导航栏高度:', navigationBarHeight);
return statusBarHeight
}