|
|
@@ -66,6 +66,14 @@ Page({
|
|
|
sheet: false,
|
|
|
|
|
|
scienceList: [] as AnyArray,
|
|
|
+ leftColumnList: [] as AnyArray,
|
|
|
+ rightColumnList: [] as AnyArray,
|
|
|
+ scienceListPage: 1,
|
|
|
+ scienceListSize: 10,
|
|
|
+ scienceListTotal: 0,
|
|
|
+ scienceListLoading: false,
|
|
|
+ scienceListHasMore: true,
|
|
|
+ refreshing: false,
|
|
|
|
|
|
_loaded: false,
|
|
|
|
|
|
@@ -398,23 +406,18 @@ Page({
|
|
|
showCancel: false,
|
|
|
confirmText: `重新加载`,
|
|
|
})
|
|
|
- .catch(() => { });
|
|
|
+ .catch(() => {});
|
|
|
await this.load(true);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!this.data._loaded) {
|
|
|
this.loadScienceList();
|
|
|
- // useLocation()
|
|
|
- // .then((location) => {
|
|
|
- // this.setData({ location });
|
|
|
- // })
|
|
|
- // .catch(() => {});
|
|
|
getSolarTerms()
|
|
|
.then((solarTerms) => {
|
|
|
this.setData({ solarTerms });
|
|
|
})
|
|
|
- .catch(() => { });
|
|
|
+ .catch(() => {});
|
|
|
this.setData({ _loaded: true });
|
|
|
}
|
|
|
},
|
|
|
@@ -473,12 +476,6 @@ Page({
|
|
|
this.setData({
|
|
|
statusList: arr2,
|
|
|
});
|
|
|
-
|
|
|
- // if (!data?.healthAnalysisReportId) {
|
|
|
- // this.setData({
|
|
|
- // isShowComplete: true,
|
|
|
- // });
|
|
|
- // }
|
|
|
} catch (error: any) {
|
|
|
wx.showToast({
|
|
|
title: error.errMsg || "加载失败",
|
|
|
@@ -597,15 +594,17 @@ Page({
|
|
|
(<any>this).applyAnimatedStyle(".fab-2", () => {
|
|
|
"worklet";
|
|
|
return {
|
|
|
- transform: `translateX(${-offset.value}px) translateY(${-offset.value / 2
|
|
|
- }px)`,
|
|
|
+ transform: `translateX(${-offset.value}px) translateY(${
|
|
|
+ -offset.value / 2
|
|
|
+ }px)`,
|
|
|
};
|
|
|
});
|
|
|
(<any>this).applyAnimatedStyle(".fab-3", () => {
|
|
|
"worklet";
|
|
|
return {
|
|
|
- transform: `translateX(${-offset.value}px) translateY(${offset.value / 2
|
|
|
- }px)`,
|
|
|
+ transform: `translateX(${-offset.value}px) translateY(${
|
|
|
+ offset.value / 2
|
|
|
+ }px)`,
|
|
|
};
|
|
|
});
|
|
|
(<any>this).applyAnimatedStyle(".fab-4", () => {
|
|
|
@@ -684,12 +683,171 @@ Page({
|
|
|
this.setData({ position: {}, sheet: false });
|
|
|
},
|
|
|
|
|
|
- async loadScienceList() {
|
|
|
+ async loadScienceList(reset = false) {
|
|
|
+ // 如果正在加载,直接返回(防止重复请求)
|
|
|
+ if (this.data.scienceListLoading) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有更多数据且不是重置,直接返回
|
|
|
+ if (!reset && !this.data.scienceListHasMore) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重置分页信息
|
|
|
+ if (reset) {
|
|
|
+ this.setData({
|
|
|
+ scienceListPage: 1,
|
|
|
+ scienceListHasMore: true,
|
|
|
+ scienceList: [],
|
|
|
+ leftColumnList: [],
|
|
|
+ rightColumnList: [],
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({ scienceListLoading: true });
|
|
|
+
|
|
|
try {
|
|
|
- const { data } = await getShortScienceList();
|
|
|
- this.setData({ scienceList: data });
|
|
|
- console.log(data, "data===scienceList");
|
|
|
- } catch (error) { }
|
|
|
+ const page = reset ? 1 : this.data.scienceListPage;
|
|
|
+ const {
|
|
|
+ data,
|
|
|
+ total,
|
|
|
+ page: currentPage,
|
|
|
+ } = await getShortScienceList(page, this.data.scienceListSize);
|
|
|
+
|
|
|
+ const newList = reset ? data : [...this.data.scienceList, ...data];
|
|
|
+ const hasMore = newList.length < total;
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ scienceList: newList,
|
|
|
+ scienceListTotal: total,
|
|
|
+ scienceListPage: currentPage + 1,
|
|
|
+ scienceListHasMore: hasMore,
|
|
|
+ scienceListLoading: false,
|
|
|
+ });
|
|
|
+
|
|
|
+ // 分配卡片到两列,实现瀑布流布局
|
|
|
+ this.distributeCardsToColumns(newList, reset);
|
|
|
+ } catch (error) {
|
|
|
+ this.setData({ scienceListLoading: false });
|
|
|
+ wx.showToast({
|
|
|
+ title: "加载失败,请重试",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 下拉刷新
|
|
|
+ async onRefreshScienceList() {
|
|
|
+ this.setData({ refreshing: true });
|
|
|
+ await this.loadScienceList(true);
|
|
|
+ this.setData({ refreshing: false });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 上拉加载更多
|
|
|
+ onLoadMoreScienceList() {
|
|
|
+ if (this.data.scienceListHasMore && !this.data.scienceListLoading) {
|
|
|
+ this.loadScienceList(false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 将卡片分配到两列,实现瀑布流布局
|
|
|
+ distributeCardsToColumns(list: AnyArray, reset = false) {
|
|
|
+ // 如果是重置,使用空数组;否则过滤出新增的卡片
|
|
|
+ const itemsToDistribute = reset
|
|
|
+ ? list
|
|
|
+ : list.filter(
|
|
|
+ (item: any) =>
|
|
|
+ !this.data.leftColumnList.some(
|
|
|
+ (existing: any) => existing.id === item.id
|
|
|
+ ) &&
|
|
|
+ !this.data.rightColumnList.some(
|
|
|
+ (existing: any) => existing.id === item.id
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ if (itemsToDistribute.length === 0) return;
|
|
|
+
|
|
|
+ // 计算当前两列的高度(重置时两列已为空,高度为0)
|
|
|
+ let leftHeight = reset
|
|
|
+ ? 0
|
|
|
+ : this.data.leftColumnList.reduce(
|
|
|
+ (sum: number, item: any) => sum + this.estimateCardHeight(item),
|
|
|
+ 0
|
|
|
+ );
|
|
|
+
|
|
|
+ let rightHeight = reset
|
|
|
+ ? 0
|
|
|
+ : this.data.rightColumnList.reduce(
|
|
|
+ (sum: number, item: any) => sum + this.estimateCardHeight(item),
|
|
|
+ 0
|
|
|
+ );
|
|
|
+
|
|
|
+ // 追加新卡片到较短的列(重置时从空数组开始)
|
|
|
+ const leftColumn = reset ? [] : [...this.data.leftColumnList];
|
|
|
+ const rightColumn = reset ? [] : [...this.data.rightColumnList];
|
|
|
+
|
|
|
+ // 智能分配:总是将卡片放到当前高度较短的列
|
|
|
+ itemsToDistribute.forEach((item: any) => {
|
|
|
+ const estimatedHeight = this.estimateCardHeight(item);
|
|
|
+
|
|
|
+ if (leftHeight <= rightHeight) {
|
|
|
+ leftColumn.push(item);
|
|
|
+ leftHeight += estimatedHeight;
|
|
|
+ } else {
|
|
|
+ rightColumn.push(item);
|
|
|
+ rightHeight += estimatedHeight;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ leftColumnList: leftColumn,
|
|
|
+ rightColumnList: rightColumn,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 预估卡片高度(基于内容特征,更准确的预估)
|
|
|
+ estimateCardHeight(item: any): number {
|
|
|
+ let height = 0;
|
|
|
+
|
|
|
+ if (item.briefImg) {
|
|
|
+ const imgMinHeight = 120;
|
|
|
+ const imgMaxHeight = 260;
|
|
|
+ const imgHeightRange = imgMaxHeight - imgMinHeight;
|
|
|
+ const idHash = item.id
|
|
|
+ ? String(item.id)
|
|
|
+ .split("")
|
|
|
+ .reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0)
|
|
|
+ : 0;
|
|
|
+ const imgHeight = imgMinHeight + (idHash % imgHeightRange);
|
|
|
+ height += imgHeight;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 内容区域
|
|
|
+ const title = item.title || "";
|
|
|
+ const titleLength = title.length;
|
|
|
+ const charsPerLine = 12;
|
|
|
+ const titleLines = Math.min(Math.ceil(titleLength / charsPerLine), 3);
|
|
|
+ const titleHeight = titleLines * 24;
|
|
|
+
|
|
|
+ const contentPadding = 24;
|
|
|
+ const metaHeight = 40;
|
|
|
+
|
|
|
+ height += titleHeight + contentPadding + metaHeight;
|
|
|
+
|
|
|
+ height += 12;
|
|
|
+
|
|
|
+ height += 4;
|
|
|
+
|
|
|
+ if (!item.briefImg) {
|
|
|
+ const minContentHeight =
|
|
|
+ titleHeight + contentPadding + metaHeight + 12 + 4;
|
|
|
+ if (height < minContentHeight) {
|
|
|
+ height = minContentHeight;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Math.round(height);
|
|
|
},
|
|
|
|
|
|
observerPatient(model: { patientId: string; sex: "0" | "1" }) {
|
|
|
@@ -703,7 +861,6 @@ Page({
|
|
|
|
|
|
getPatientDescription(model).then((patientDescription) => {
|
|
|
this.setData({ patientDescription });
|
|
|
- // wx.setStorageSync("patientPhone", patientDescription.phone);
|
|
|
});
|
|
|
|
|
|
// 获取未处理随访列表
|
|
|
@@ -736,18 +893,16 @@ Page({
|
|
|
icon: "success",
|
|
|
duration: 1500,
|
|
|
});
|
|
|
- // 无感刷新调养计划,保持展开状态
|
|
|
await this.refreshCareListsWithState();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 无感刷新调养计划,保持展开状态和媒体加载状态
|
|
|
async refreshCareListsWithState() {
|
|
|
// 保存当前的展开状态
|
|
|
const currentExpandedStates = this.data.displayList.map((item: any) => ({
|
|
|
id: item.id,
|
|
|
expanded: item.expanded,
|
|
|
- carouselMediaList: item.carouselMediaList, // 保存媒体列表,避免重新加载
|
|
|
+ carouselMediaList: item.carouselMediaList,
|
|
|
}));
|
|
|
|
|
|
// 获取新数据
|
|
|
@@ -759,7 +914,6 @@ Page({
|
|
|
(state) => state.id === item.id
|
|
|
);
|
|
|
if (oldItem && oldItem.carouselMediaList) {
|
|
|
- // 保持原有的媒体列表,避免重新加载
|
|
|
item.carouselMediaList = oldItem.carouselMediaList;
|
|
|
} else {
|
|
|
item.carouselMediaList = [];
|
|
|
@@ -824,8 +978,7 @@ Page({
|
|
|
* 轮播组件进入/退出全屏时,隐藏/显示底部 tabbar,防止遮挡视频进度条
|
|
|
*/
|
|
|
onCarouselFullscreenChange(e: { detail?: { fullScreen?: boolean } }) {
|
|
|
- console.log(e, "全屏模式");
|
|
|
- const fullScreen = !!(e.detail?.fullScreen);
|
|
|
+ const fullScreen = !!e.detail?.fullScreen;
|
|
|
this.setData({
|
|
|
tabbarHidden: fullScreen,
|
|
|
});
|