diff --git a/newPages/appointmentAdd/index.vue b/newPages/appointmentAdd/index.vue index d35fa4a..b110f29 100644 --- a/newPages/appointmentAdd/index.vue +++ b/newPages/appointmentAdd/index.vue @@ -249,6 +249,7 @@ duration: 2000 }) setTimeout(() => { + uni.$emit('refresh'); uni.navigateBack() }, 2000) }) diff --git a/newPages/appointmentDetail/index.vue b/newPages/appointmentDetail/index.vue index fa5d61a..fe379a0 100644 --- a/newPages/appointmentDetail/index.vue +++ b/newPages/appointmentDetail/index.vue @@ -37,7 +37,7 @@ 累计训练时长 - {{ appointmentInfo.allDriveTime }}分钟 + {{ appointmentInfo.allDriveTime }}分钟 训练地址 @@ -81,30 +81,48 @@ export default { console.log(this.appointmentInfo) if (options.type === 'train') { this.isTrain = true - }else { + } else { this.isTrain = false } console.log(this.isTrain) }, methods: { - getAllTrainTime() { - request({ - url: '/app-api/process/getAllByCourseId', - method: 'GET', - params: { - courseId: this.appointmentInfo.courseId - }, - tenantIdFlag: false - }).then(res => { - console.log('获取所有训练时间', res) - const data = res.data.find(item => {item.subject == this.appointmentInfo.subject}) - if (!data.allDriveTime) { - this.appointmentInfo.allDriveTime = data.allDriveTime - }else { - this.appointmentInfo.allDriveTime = '0' + async getAllTrainTime() { + try { + const res = await request({ + url: "/app-api/process/getAllByCourseId", + method: "GET", + params: { + courseId: this.appointmentInfo.courseId, + }, + tenantIdFlag: false, + }); + + console.log("获取所有训练时间", res); + console.log("当前科目:", this.appointmentInfo.subject); + + // 确保 appointmentInfo.subject 已有值 + if (!this.appointmentInfo.subject) { + console.warn("appointmentInfo.subject 为空,等待赋值..."); + await new Promise((resolve) => setTimeout(resolve, 100)); } - }) + const data = res.data.find( + (item) => item.subject == this.appointmentInfo.subject + ); + + console.log("匹配的训练时间数据:", data); + + this.appointmentInfo.allDriveTime = data ? data.trainTime || "0" : "0"; + + console.log( + "this.appointmentInfo.allDriveTime", + this.appointmentInfo.allDriveTime + ); + } catch (error) { + console.error("获取训练时间失败:", error); + } } + } };