|
|
@@ -70,23 +70,23 @@ Page({
|
|
|
|
|
|
// 轮播媒体列表
|
|
|
carouselMediaList: [
|
|
|
- {
|
|
|
- type: 'image',
|
|
|
- src: "https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/222_20250807164536A813.jpg",
|
|
|
- title: '操作图片'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'image',
|
|
|
- src: "https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/111_20250807164533A812.jpg",
|
|
|
- title: '商品图片'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'video',
|
|
|
- src: 'https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/song_20250807164546A814.mp4',
|
|
|
- title: '操作视频'
|
|
|
- },
|
|
|
+ // {
|
|
|
+ // type: 'image',
|
|
|
+ // src: "https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/222_20250807164536A813.jpg",
|
|
|
+ // title: '操作图片'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // type: 'image',
|
|
|
+ // src: "https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/111_20250807164533A812.jpg",
|
|
|
+ // title: '商品图片'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // type: 'video',
|
|
|
+ // src: 'https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/song_20250807164546A814.mp4',
|
|
|
+ // title: '操作视频'
|
|
|
+ // },
|
|
|
] as Array<{
|
|
|
- type: 'image' | 'video';
|
|
|
+ type: "image" | "video";
|
|
|
src: string;
|
|
|
poster?: string;
|
|
|
title?: string;
|
|
|
@@ -100,48 +100,76 @@ Page({
|
|
|
// 获取调养计划
|
|
|
async getCareLists() {
|
|
|
const res = await getCareList();
|
|
|
- console.log(res, "res==careList");
|
|
|
if (res && res.length > 0) {
|
|
|
- res.forEach((item: any) => {
|
|
|
- item.carouselMediaList = [];
|
|
|
-
|
|
|
- // 添加photo
|
|
|
- if (item.photo) {
|
|
|
- item.carouselMediaList.push({
|
|
|
- type: 'image',
|
|
|
- src: item.photo,
|
|
|
- title: '商品图片'
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 添加itemImgFirst
|
|
|
- if (item?.itemImgFirst) {
|
|
|
- item.carouselMediaList.push({
|
|
|
- type: 'image',
|
|
|
- src: item.itemImgFirst,
|
|
|
- title: '操作图片'
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 添加itemVideoFirst
|
|
|
- if (item?.itemVideoFirst) {
|
|
|
- item.carouselMediaList.push({
|
|
|
- type: 'video',
|
|
|
- src: item.itemVideoFirst,
|
|
|
- poster: item.photo || item.itemImgFirst, // 使用photo或itemImgFirst作为视频封面
|
|
|
- title: '操作视频'
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 添加调试信息
|
|
|
- console.log(`调养计划 ${item.conditioningProgramName} 的轮播数据:`, {
|
|
|
- photo: item.photo,
|
|
|
- itemImgFirst: item.itemImgFirst,
|
|
|
- itemVideoFirst: item.itemVideoFirst,
|
|
|
- carouselMediaList: item.carouselMediaList
|
|
|
- });
|
|
|
+ res.forEach((item: any, index: number) => {
|
|
|
+ item.carouselMediaList = [];
|
|
|
+ item._mediaLoaded = false; // 添加媒体加载状态
|
|
|
+
|
|
|
+ // 确保 item.id 存在且为数字类型
|
|
|
+ if (!item.id && item.id !== 0) {
|
|
|
+ item.id = index;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保 id 是数字类型
|
|
|
+ item.id = Number(item.id);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 添加photo
|
|
|
+ if (item.photo) {
|
|
|
+ item.carouselMediaList.push({
|
|
|
+ type: "image",
|
|
|
+ src: item.photo,
|
|
|
+ title: "商品图片",
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加itemImgFirst
|
|
|
+ if (item?.itemImgFirst) {
|
|
|
+ item.carouselMediaList.push({
|
|
|
+ type: "image",
|
|
|
+ src: item.itemImgFirst,
|
|
|
+ title: "操作图片",
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加itemVideoFirst
|
|
|
+ if (item?.itemVideoFirst) {
|
|
|
+ item.carouselMediaList.push({
|
|
|
+ type: "video",
|
|
|
+ src: item.itemVideoFirst,
|
|
|
+ poster: item.photo || item.itemImgFirst, // 使用photo或itemImgFirst作为视频封面
|
|
|
+ title: "操作视频",
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有媒体内容,直接标记为已加载,避免一直显示加载状态
|
|
|
+ if (item.carouselMediaList.length === 0) {
|
|
|
+ item._mediaLoaded = true;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // 模拟加载过程,3秒后自动标记为已加载(防止一直显示加载状态)
|
|
|
+ setTimeout(() => {
|
|
|
+ if (!item._mediaLoaded) {
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ [`careList[${index}]._mediaLoaded`]: true,
|
|
|
+ });
|
|
|
+ // 同时更新 displayList
|
|
|
+ const displayIndex = this.data.displayList.findIndex(
|
|
|
+ (displayItem: any) => displayItem.id === item.id
|
|
|
+ );
|
|
|
+ if (displayIndex !== -1) {
|
|
|
+ this.setData({
|
|
|
+ [`displayList[${displayIndex}]._mediaLoaded`]: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 3000);
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
this.setData({
|
|
|
careList: res,
|
|
|
});
|
|
|
@@ -155,17 +183,10 @@ Page({
|
|
|
if (query.ys) wx.setStorageSync("doctorId", query.ys);
|
|
|
|
|
|
this.initFabAnimated();
|
|
|
-
|
|
|
- // this.calculatePageHeight();
|
|
|
},
|
|
|
async onShow() {
|
|
|
wx.showShareMenu({ withShareTicket: true, menus }).then();
|
|
|
this.load();
|
|
|
- // // 获取未处理随访列表
|
|
|
- // this.getNotDealList();
|
|
|
- // // 获取调养计划
|
|
|
- // await this.getCareLists();
|
|
|
- // await this.updateDisplayList();
|
|
|
},
|
|
|
onHide() {
|
|
|
wx.hideShareMenu({ menus }).then();
|
|
|
@@ -178,7 +199,6 @@ Page({
|
|
|
);
|
|
|
},
|
|
|
onShareAppMessage(opts): WechatMiniprogram.Page.ICustomShareContent {
|
|
|
- // console.log(opts.target);
|
|
|
return {
|
|
|
title: `健康为基,从容赏生活之美`,
|
|
|
imageUrl: `https://wx.hzliuzhi.com/media/healthManager/wx/share.jpg`,
|
|
|
@@ -197,7 +217,6 @@ Page({
|
|
|
displayList:
|
|
|
allExpanded || careList.length <= 4 ? careList : careList.slice(0, 4),
|
|
|
});
|
|
|
- console.log(this.data.displayList, "展示的调养计划");
|
|
|
},
|
|
|
toggleAll() {
|
|
|
this.setData(
|
|
|
@@ -213,7 +232,6 @@ Page({
|
|
|
// 核销记录
|
|
|
onRecord(e: any) {
|
|
|
const id = e.currentTarget.dataset.id;
|
|
|
- // console.log(id, "id");
|
|
|
if (id) {
|
|
|
wx.navigateTo({
|
|
|
url: `/module/care/pages/care/verifyRecord?id=${id}`,
|
|
|
@@ -233,8 +251,9 @@ Page({
|
|
|
// 打卡
|
|
|
pushCard(e: any) {
|
|
|
const id = e.currentTarget.dataset.id;
|
|
|
- console.log("pushCard",id);
|
|
|
- wx.navigateTo({ url: `/module/article/pages/punch-card/punch-card?id=${id}` });
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/module/article/pages/punch-card/punch-card?id=${id}`,
|
|
|
+ });
|
|
|
},
|
|
|
calculatePageHeight() {
|
|
|
const systemInfo = wx.getSystemInfoSync();
|
|
|
@@ -280,24 +299,25 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
// 诊疗随访提醒
|
|
|
- goComplete(e: { currentTarget: { dataset: { page: string; id: number; title: string } } }) {
|
|
|
+ goComplete(e: {
|
|
|
+ currentTarget: { dataset: { page: string; id: number; title: string } };
|
|
|
+ }) {
|
|
|
const { title } = e.currentTarget.dataset;
|
|
|
let page = e.currentTarget.dataset.page;
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
// let page = '/module/chats/pages/index/index';
|
|
|
// let id = 1;
|
|
|
if (page === "/module/chats/pages/index/index") {
|
|
|
- if(title === "健康评估"){
|
|
|
+ if (title === "健康评估") {
|
|
|
wx.setStorageSync("isAnalysis", 4);
|
|
|
- toChats('questionnaire',2)
|
|
|
- }else{
|
|
|
+ toChats("questionnaire", 2);
|
|
|
+ } else {
|
|
|
wx.setStorageSync("isAnalysis", 2);
|
|
|
wx.setStorageSync("workId", id);
|
|
|
wx.navigateTo({
|
|
|
url: `${page}?component=questionnaire&messageType=1&id=${id}`,
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
wx.navigateTo({ url: `${page}?id=${id}` });
|
|
|
// wx.navigateTo({ url: `/module/follow/pages/evaluation/report?id=${id}` });
|
|
|
@@ -314,11 +334,10 @@ Page({
|
|
|
const { patient } = await getPatients(/*this.data.patientId*/);
|
|
|
// if (!patient) await toCertificationPage();
|
|
|
if (!patient) {
|
|
|
- console.log("没有患者");
|
|
|
- if(wx.getStorageSync("doctorId")){
|
|
|
+ if (wx.getStorageSync("doctorId")) {
|
|
|
toCertificationPage();
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
this.setData({ patient });
|
|
|
this.observerPatient(patient);
|
|
|
}
|
|
|
@@ -364,11 +383,29 @@ Page({
|
|
|
});
|
|
|
let arr2 = [
|
|
|
[
|
|
|
- { title: "健康状态", value: data?.willillStateName?`${data?.willillStateName}`:"" },
|
|
|
- { title: "程度", value: data?.willillDegreeName?`${data?.willillDegreeName}`:"" },
|
|
|
+ {
|
|
|
+ title: "健康状态",
|
|
|
+ value: data?.willillStateName ? `${data?.willillStateName}` : "",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "程度",
|
|
|
+ value: data?.willillDegreeName ? `${data?.willillDegreeName}` : "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ {
|
|
|
+ title: "中医证素",
|
|
|
+ value: data?.factorItemSummary ? `${data?.factorItemSummary}` : "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ {
|
|
|
+ title: "体质",
|
|
|
+ value: data?.constitutionGroupName
|
|
|
+ ? `${data?.constitutionGroupName}`
|
|
|
+ : "",
|
|
|
+ },
|
|
|
],
|
|
|
- [{ title: "中医证素", value: data?.factorItemSummary?`${data?.factorItemSummary}`:"" }],
|
|
|
- [{ title: "体质", value: data?.constitutionGroupName?`${data?.constitutionGroupName}`:"" }],
|
|
|
];
|
|
|
this.setData({
|
|
|
statusList: arr2,
|
|
|
@@ -378,7 +415,6 @@ Page({
|
|
|
// this.setData({
|
|
|
// statusList: arr,
|
|
|
// });
|
|
|
- // console.log("获取健康报告", data);
|
|
|
} catch (error) {
|
|
|
this.setData({
|
|
|
"healthReport.data": [],
|
|
|
@@ -393,7 +429,6 @@ Page({
|
|
|
this.setData({ "healthIndex.loading": true });
|
|
|
try {
|
|
|
const data = await healthIndexMethod();
|
|
|
- // console.log(data, "heindex");
|
|
|
this.setData({
|
|
|
"healthIndex.data": data
|
|
|
.map((item: AnyObject) => item.abnormalDesc)
|
|
|
@@ -409,7 +444,6 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
onBodyModel(event: WechatMiniprogram.TouchEvent) {
|
|
|
- // console.log(event, "获取数据");
|
|
|
if (event.detail?.position === "LB") {
|
|
|
this.toReportPage();
|
|
|
} else if (event.detail?.position === "item0") {
|
|
|
@@ -463,7 +497,6 @@ Page({
|
|
|
});
|
|
|
this.showDraggableSheet();
|
|
|
} else if (event.detail?.position === "CT") {
|
|
|
- // console.log(this.data.healthIndex, "heaindex");
|
|
|
this.setData({
|
|
|
position: {
|
|
|
CT: this.data.healthIndex.data.map(
|
|
|
@@ -475,7 +508,6 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
tabValue() {
|
|
|
- // console.log(this.data.healthIndex, "heaindex111111");
|
|
|
this.setData({
|
|
|
position: {
|
|
|
CT: this.data.healthIndex.data.map(
|
|
|
@@ -631,51 +663,98 @@ Page({
|
|
|
// 获取调养计划
|
|
|
this.getCareLists();
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 轮播相关事件处理方法
|
|
|
- onCarouselChange(e: any) {
|
|
|
- const { current, total } = e.detail;
|
|
|
- console.log('轮播切换:', current, total);
|
|
|
- },
|
|
|
-
|
|
|
+ // 图片加载成功
|
|
|
onImageLoad(e: any) {
|
|
|
- const { index, item } = e.detail;
|
|
|
- console.log('图片加载成功:', index, item);
|
|
|
+ const { item, itemId } = e.detail;
|
|
|
+ // 如果有itemId,直接更新对应项的状态
|
|
|
+ if (itemId) {
|
|
|
+ this.updateMediaLoadedStateById(itemId);
|
|
|
+ } else {
|
|
|
+ // 兼容旧版本,通过查找来匹配
|
|
|
+ this.updateMediaLoadedState(item);
|
|
|
+ }
|
|
|
},
|
|
|
-
|
|
|
+ // 图片加载失败
|
|
|
onImageError(e: any) {
|
|
|
- const { index, item } = e.detail;
|
|
|
- console.log('图片加载失败:', index, item);
|
|
|
+ const { item, itemId } = e.detail;
|
|
|
wx.showToast({
|
|
|
- title: '图片加载失败',
|
|
|
- icon: 'none'
|
|
|
+ title: "图片加载失败",
|
|
|
+ icon: "none",
|
|
|
});
|
|
|
+ // 即使加载失败也要标记为已加载,避免一直显示加载状态
|
|
|
+ if (itemId) {
|
|
|
+ this.updateMediaLoadedStateById(itemId);
|
|
|
+ } else {
|
|
|
+ this.updateMediaLoadedState(item);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- onVideoPlay(e: any) {
|
|
|
- const { index, item } = e.detail;
|
|
|
- console.log('视频开始播放:', index, item);
|
|
|
- },
|
|
|
+ // 通过ID更新媒体加载状态的辅助方法
|
|
|
+ updateMediaLoadedStateById(itemId: string | number) {
|
|
|
+ const { careList, displayList } = this.data;
|
|
|
+
|
|
|
+ // 查找对应的 careList 项
|
|
|
+ const careListIndex = careList.findIndex((item: any) => item.id == itemId);
|
|
|
|
|
|
- onVideoPause(e: any) {
|
|
|
- const { index, item } = e.detail;
|
|
|
- console.log('视频暂停:', index, item);
|
|
|
+ // 查找对应的 displayList 项
|
|
|
+ const displayListIndex = displayList.findIndex(
|
|
|
+ (item: any) => item.id == itemId
|
|
|
+ );
|
|
|
+
|
|
|
+ if (careListIndex !== -1) {
|
|
|
+ this.setData({
|
|
|
+ [`careList[${careListIndex}]._mediaLoaded`]: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (displayListIndex !== -1) {
|
|
|
+ this.setData({
|
|
|
+ [`displayList[${displayListIndex}]._mediaLoaded`]: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- onVideoEnded(e: any) {
|
|
|
- const { index, item } = e.detail;
|
|
|
- console.log('视频播放结束:', index, item);
|
|
|
+ // 更新媒体加载状态的辅助方法(兼容旧版本)
|
|
|
+ updateMediaLoadedState(mediaItem: any) {
|
|
|
+ const { careList, displayList } = this.data;
|
|
|
+ // 查找对应的 careList 项
|
|
|
+ const careListIndex = careList.findIndex(
|
|
|
+ (item: any) =>
|
|
|
+ item.carouselMediaList &&
|
|
|
+ item.carouselMediaList.some((media: any) => media.src === mediaItem.src)
|
|
|
+ );
|
|
|
+ // 查找对应的 displayList 项
|
|
|
+ const displayListIndex = displayList.findIndex(
|
|
|
+ (item: any) =>
|
|
|
+ item.carouselMediaList &&
|
|
|
+ item.carouselMediaList.some((media: any) => media.src === mediaItem.src)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (careListIndex !== -1) {
|
|
|
+ this.setData({
|
|
|
+ [`careList[${careListIndex}]._mediaLoaded`]: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (displayListIndex !== -1) {
|
|
|
+ this.setData({
|
|
|
+ [`displayList[${displayListIndex}]._mediaLoaded`]: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
+ // 视频播放失败
|
|
|
onVideoError(e: any) {
|
|
|
- const { index, item } = e.detail;
|
|
|
- console.log('视频播放错误:', index, item);
|
|
|
+ const { item, itemId } = e.detail;
|
|
|
wx.showToast({
|
|
|
- title: '视频播放失败',
|
|
|
- icon: 'none'
|
|
|
+ title: "视频播放失败",
|
|
|
+ icon: "none",
|
|
|
});
|
|
|
+ // 视频播放错误时也要标记为已加载,避免一直显示加载状态
|
|
|
+ if (itemId) {
|
|
|
+ this.updateMediaLoadedStateById(itemId);
|
|
|
+ } else {
|
|
|
+ this.updateMediaLoadedState(item);
|
|
|
+ }
|
|
|
},
|
|
|
});
|