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) { getCode(data,header) {
return request('/expertAPI/smsSend', data, 'post', true,'application/json',header); return request('/expertAPI/smsSend', data, 'post', true,'application/json',header);
}, },
getHomeData(){
return request('/expertAPI/index', {}, 'post', false);
},
// 视频相关API // 视频相关API
getVideoList(data) { getVideoList(data) {
return request('/video/list', data, 'get', true); return request('/video/list', data, 'get', true);

View File

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

View File

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

View File

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