This commit is contained in:
zoujiandong 2025-08-27 14:18:00 +08:00
parent 58d9fb3d7a
commit 42ef4d312e
4 changed files with 78 additions and 40 deletions

View File

@ -33,7 +33,9 @@ const api = {
getCode(data,header) {
return request('/expertAPI/smsSend', data, 'post', true,'application/json',header);
},
getHomeData(){
return request('/expertAPI/index', {}, 'post', false);
},
// 视频相关API
getVideoList(data) {
return request('/video/list', data, 'get', true);

View File

@ -39,7 +39,7 @@
const props = defineProps({
visible: {
type: Boolean,
default: true
default: false
},
title: {
type: String,

View File

@ -261,6 +261,7 @@
import { onShow, onLoad, onPageScroll } from "@dcloudio/uni-app";
import CustomTabbar from '@/components/tabBar/tabBar.vue';
import unidialog from "@/components/dialog/dialog.vue"
import api from '@/api/api.js'
import navTo from "@/utils/navTo.js";
import bg from "@/static/more_bg.png"
import patient from "@/static/icon_home_my_patient.png"
@ -279,7 +280,7 @@
const showSign=ref(false)
// refs
const tabbarRef = ref(null);
const visible=ref(true)
const visible=ref(false)
//
const scrollTop = ref(0);
const bannerHeight = 400; // rpx
@ -673,32 +674,66 @@
}
};
// tabbar
const updateTabbarData = () => {
if (tabbarRef.value) {
const newTabList = [
{
icon: 'home',
activeIcon: 'home-filled',
text: '首页',
color: '#999999',
activeColor: '#007aff',
badge: 0,
showRedDot: false,
pagePath: '/pages/index/index'
},
{
icon: 'mic',
activeIcon: 'mic-filled',
text: '患教学堂',
color: '#999999',
activeColor: '#007aff',
badge: 15,
showRedDot: true,
pagePath: '/pages/education/education'
//
const getHomeData = async () => {
try {
uni.showLoading({ title: '加载中...' });
const res = await api.getHomeData();
console.log('首页数据:', res);
if (res && res.data) {
const data = res.data;
//
if (data.bannerList && data.bannerList.length > 0) {
bannerList.length = 0;
bannerList.push(...data.bannerList);
}
];
tabbarRef.value.updateTabList(newTabList);
//
if (data.gridList && data.gridList.length > 0) {
gridList.length = 0;
gridList.push(...data.gridList);
}
//
if (data.noticeList && data.noticeList.length > 0) {
noticeList.length = 0;
noticeList.push(...data.noticeList);
}
// E
if (data.specialList && data.specialList.length > 0) {
specialList.length = 0;
specialList.push(...data.specialList);
}
//
if (data.courseList && data.courseList.length > 0) {
courseList.length = 0;
courseList.push(...data.courseList);
}
//
if (data.replayList && data.replayList.length > 0) {
replayList.length = 0;
replayList.push(...data.replayList);
}
//
if (data.guideList && data.guideList.length > 0) {
guideList.length = 0;
guideList.push(...data.guideList);
}
}
} catch (error) {
console.error('获取首页数据失败:', error);
uni.showToast({
title: '数据加载失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
};
@ -719,11 +754,8 @@
//
onShow(() => {
console.log('首页显示');
});
//
onMounted(() => {
console.log('首页组件已挂载');
//
getHomeData();
// tabbar
testTabbar();

View File

@ -36,18 +36,22 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
}
let header = {
'content-type': contentType,
'Authorization': 'Bearer ' + token
}
const defaultData = {
version: '4.0.0',
user_uuid: 'Rj3zuTY6zP6YTjHsYEz',
client_type: 'A', //client_type,
let defaultData={}
if(token){
header['Authorization']='Bearer ' + token
}
defaultData = {
version: '4.0.0',
user_uuid: 'Rj3zuTY6zP6YTjHsYEz',
client_type: 'A', //client_type,
}
return new Promise(function(e, n) {
let timestamp = Date.now();
uni.request({
data: {...data,...defaultData,timestamp:new Date().getTime()},
data: {...data,...defaultData,timestamp:new Date().getTime().toString()},
url: url.indexOf('http') != -1 ? url : encodeURI(BASE_URL + url),
method: method,
sslVerify: false,