111
This commit is contained in:
parent
58d9fb3d7a
commit
42ef4d312e
@ -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);
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: false
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user