111
This commit is contained in:
parent
58d9fb3d7a
commit
42ef4d312e
@ -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);
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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();
|
||||||
|
|
||||||
|
|||||||
@ -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={}
|
||||||
|
if(token){
|
||||||
|
header['Authorization']='Bearer ' + token
|
||||||
|
|
||||||
const defaultData = {
|
|
||||||
version: '4.0.0',
|
|
||||||
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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user