This commit is contained in:
许允枞 2025-04-03 17:33:17 +08:00
parent 0b6b6f6bbc
commit fb65aee3d0
2 changed files with 37 additions and 18 deletions

View File

@ -249,6 +249,7 @@
duration: 2000 duration: 2000
}) })
setTimeout(() => { setTimeout(() => {
uni.$emit('refresh');
uni.navigateBack() uni.navigateBack()
}, 2000) }, 2000)
}) })

View File

@ -37,7 +37,7 @@
<view style="width: 90%; height: 1px; background-color: #e0e0e0; margin: 20px 10rpx auto;"></view> <view style="width: 90%; height: 1px; background-color: #e0e0e0; margin: 20px 10rpx auto;"></view>
<view class="text-wrapper_5 flex-row justify-between" v-if="!isTrain"> <view class="text-wrapper_5 flex-row justify-between" v-if="!isTrain">
<text class="text_12">累计训练时长</text> <text class="text_12">累计训练时长</text>
<text class="text_13" >{{ appointmentInfo.allDriveTime }}分钟</text> <text class="text_13">{{ appointmentInfo.allDriveTime }}分钟</text>
</view> </view>
<view class="text-wrapper_6 flex-row justify-between" v-if="isTrain"> <view class="text-wrapper_6 flex-row justify-between" v-if="isTrain">
<text class="text_14">训练地址</text> <text class="text_14">训练地址</text>
@ -81,30 +81,48 @@ export default {
console.log(this.appointmentInfo) console.log(this.appointmentInfo)
if (options.type === 'train') { if (options.type === 'train') {
this.isTrain = true this.isTrain = true
}else { } else {
this.isTrain = false this.isTrain = false
} }
console.log(this.isTrain) console.log(this.isTrain)
}, },
methods: { methods: {
getAllTrainTime() { async getAllTrainTime() {
request({ try {
url: '/app-api/process/getAllByCourseId', const res = await request({
method: 'GET', url: "/app-api/process/getAllByCourseId",
params: { method: "GET",
courseId: this.appointmentInfo.courseId params: {
}, courseId: this.appointmentInfo.courseId,
tenantIdFlag: false },
}).then(res => { tenantIdFlag: false,
console.log('获取所有训练时间', res) });
const data = res.data.find(item => {item.subject == this.appointmentInfo.subject})
if (!data.allDriveTime) { console.log("获取所有训练时间", res);
this.appointmentInfo.allDriveTime = data.allDriveTime console.log("当前科目:", this.appointmentInfo.subject);
}else {
this.appointmentInfo.allDriveTime = '0' // 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);
}
} }
} }
}; };
</script> </script>