|
@@ -163,6 +163,7 @@ export default {
|
|
|
memberId: null,
|
|
memberId: null,
|
|
|
isSelfCheckin: false,
|
|
isSelfCheckin: false,
|
|
|
submitting: false,
|
|
submitting: false,
|
|
|
|
|
+ pendingSubmit: false,
|
|
|
syncingSteps: false,
|
|
syncingSteps: false,
|
|
|
syncedStepText: '',
|
|
syncedStepText: '',
|
|
|
isRecording: false,
|
|
isRecording: false,
|
|
@@ -228,9 +229,12 @@ export default {
|
|
|
sttTranscribe(res.tempFilePath).then(function(text) {
|
|
sttTranscribe(res.tempFilePath).then(function(text) {
|
|
|
self.form.voiceText = text
|
|
self.form.voiceText = text
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
|
|
+ // 保存时停止录音 → 语音已就绪,继续提交
|
|
|
|
|
+ if (self.pendingSubmit) { self.pendingSubmit = false; self.doCheckin() }
|
|
|
}).catch(function(err) {
|
|
}).catch(function(err) {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.warn('STT 转写失败:', err)
|
|
console.warn('STT 转写失败:', err)
|
|
|
|
|
+ if (self.pendingSubmit) { self.pendingSubmit = false; self.doCheckin() }
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
this.recorderManager.onError(() => {
|
|
this.recorderManager.onError(() => {
|
|
@@ -401,11 +405,26 @@ export default {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- async doCheckin() {
|
|
|
|
|
|
|
+ doCheckin: function() {
|
|
|
|
|
+ var self = this
|
|
|
|
|
+ if (self.submitting) return
|
|
|
|
|
+ // 保存时正在录音 → 先停止录音,等待 onStop 完成语音后继续提交
|
|
|
|
|
+ if (self.isRecording) {
|
|
|
|
|
+ self.pendingSubmit = true
|
|
|
|
|
+ self.recorderManager.stop()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ self.submitCheckin()
|
|
|
|
|
+ },
|
|
|
|
|
+ submitCheckin: async function() {
|
|
|
var self = this
|
|
var self = this
|
|
|
if (!self.form.exerciseType) { uni.showToast({ title: '请选择运动类型', icon: 'none' }); return }
|
|
if (!self.form.exerciseType) { uni.showToast({ title: '请选择运动类型', icon: 'none' }); return }
|
|
|
|
|
+ // 内容校验:运动时长、图片、语音 至少有一项
|
|
|
var durationNum = parseInt(self.form.durationMinutes)
|
|
var durationNum = parseInt(self.form.durationMinutes)
|
|
|
- if (!self.form.durationMinutes || isNaN(durationNum) || durationNum <= 0) { uni.showToast({ title: '请填写有效的运动时长', icon: 'none' }); return }
|
|
|
|
|
|
|
+ var hasDuration = self.form.durationMinutes && !isNaN(durationNum) && durationNum > 0
|
|
|
|
|
+ var hasPhoto = self.form.photos && self.form.photos.length > 0
|
|
|
|
|
+ var hasVoice = self.form.voicePath || (self.form.voiceText && self.form.voiceText.trim())
|
|
|
|
|
+ if (!hasDuration && !hasPhoto && !hasVoice) { uni.showToast({ title: '请填写运动时长或添加图片/语音', icon: 'none' }); return }
|
|
|
if (!self.memberId) { uni.showToast({ title: '孩子ID无效', icon: 'none' }); return }
|
|
if (!self.memberId) { uni.showToast({ title: '孩子ID无效', icon: 'none' }); return }
|
|
|
self.submitting = true
|
|
self.submitting = true
|
|
|
try {
|
|
try {
|
|
@@ -427,7 +446,7 @@ export default {
|
|
|
data: {
|
|
data: {
|
|
|
memberId: self.memberId,
|
|
memberId: self.memberId,
|
|
|
exerciseType: self.form.exerciseType,
|
|
exerciseType: self.form.exerciseType,
|
|
|
- durationMinutes: parseInt(self.form.durationMinutes),
|
|
|
|
|
|
|
+ durationMinutes: self.form.durationMinutes ? parseInt(self.form.durationMinutes) : null,
|
|
|
intensity: self.form.intensity,
|
|
intensity: self.form.intensity,
|
|
|
caloriesBurned: self.form.caloriesBurned ? parseInt(self.form.caloriesBurned) : null,
|
|
caloriesBurned: self.form.caloriesBurned ? parseInt(self.form.caloriesBurned) : null,
|
|
|
remark: self.form.remark || '',
|
|
remark: self.form.remark || '',
|