Merge remote-tracking branch 'origin/main'

This commit is contained in:
@jyuhsin
2024-09-23 15:11:10 +08:00
32 changed files with 842 additions and 591 deletions
@@ -86,9 +86,8 @@ layout("/mobile/platform.html"){
.page-control {
padding: 20px;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20px;
display: flex;
column-gap: 20px;
position: fixed;
bottom: 0;
left: 0;
@@ -175,6 +174,9 @@ layout("/mobile/platform.html"){
<div class="score" v-if="finishAnswer && ( currentScore || currentScore===0 )">
{{questionData.calcScoreMode==1?'今日最高成绩':'得分'}}{{currentScore}}
</div>
<div class="timer" v-if="questionData.enableTimer && !finishAnswer">
<span>剩余时间:{{remainder}}</span>
</div>
</div>
<div class="survey-head">
<div class="title">
@@ -194,8 +196,8 @@ layout("/mobile/platform.html"){
{{issue.iisdx?'单选':'多选'}}
</van-tag>
</template>
<!-- <van-tag v-if="issue.fraction" type="primary" size="large">{{issue.fraction}}分-->
<!-- </van-tag>-->
<!-- <van-tag v-if="issue.fraction" type="primary" size="large">{{issue.fraction}}分-->
<!-- </van-tag>-->
</div>
<h2 class="question-title">
<span class="question-seq">
@@ -243,10 +245,12 @@ layout("/mobile/platform.html"){
</section>
</div>
<div class="page-control" v-if="!finishAnswer">
<van-button type="info" block @click="save()">保存</van-button>
<!--非计时模式才能保存 否则没意义了-->
<van-button type="info" block @click="save()" v-if="!questionData.enableTimer">保存</van-button>
<van-button type="info" block @click="submit()">提交</van-button>
</div>
<div class="page-control" style="grid-template-columns: auto" v-if="canAnswerAgain && finishAnswer && moment().format('YYYY-MM-DD') === vue.currentDate">
<div class="page-control" style="grid-template-columns: auto"
v-if="canAnswerAgain && finishAnswer && moment().format('YYYY-MM-DD') === vue.currentDate">
<van-button type="info" block @click="answerAgain">
再答一次
</van-button>
@@ -299,7 +303,14 @@ layout("/mobile/platform.html"){
currentScore: null,
//获取用户已回答的轮数 针对单天随机
userHasAnswerRandomNum: 0
userHasAnswerRandomNum: 0,
//倒计时计时器
timerInterval: null,
//答题时间(使用秒)
countDownSeconds: 0,
//剩余时间
remainder: null
}
},
@@ -461,33 +472,69 @@ layout("/mobile/platform.html"){
const msg = '一旦提交不可修改,您确定要提交吗?'
this.$modal.confirm(msg).then(async () => {
const replies = this.questionData.issues.map(v => {
return {
qid: this.id,
issueId: v.iid,
userSelect: v.userSelect,
}
})
const {code} = await $.post(BASE_URL + '/saveAnswer', {
replies: JSON.stringify(replies),
questionId: this.questionData.qid,
isSave: false,
randomCount: this.randomCount
})
this.$modal.closeLoading()
if (code === 0) {
this.$modal.msg('提交成功')
await this.getUserHasAnswerRandomNum()
await this.checkUserFinishAnswer()
await this.getReply()
await this.assignmentAnswer()
await this.checkUserFinishAnswer()
await this.checkCanAnswerAgain()
await this.getScore()
}
this.autoSubmit()
// const replies = this.questionData.issues.map(v => {
// return {
// qid: this.id,
// issueId: v.iid,
// userSelect: v.userSelect,
// }
// })
//
// const {code} = await $.post(BASE_URL + '/saveAnswer', {
// replies: JSON.stringify(replies),
// questionId: this.questionData.qid,
// isSave: false,
// randomCount: this.randomCount
// })
// this.$modal.closeLoading()
// if (code === 0) {
// this.$modal.msg('提交成功')
// await this.getUserHasAnswerRandomNum()
// await this.checkUserFinishAnswer()
// await this.getReply()
// await this.assignmentAnswer()
// await this.checkUserFinishAnswer()
// await this.checkCanAnswerAgain()
// await this.getScore()
// }
})
},
async autoSubmit() {
const replies = this.questionData.issues.map(v => {
return {
qid: this.id,
issueId: v.iid,
userSelect: v.userSelect,
}
})
let takeTime = null
if (this.questionData.enableTimer) {
takeTime = this.questionData.timerMinute * 60 - this.countDownSeconds
}
const {code} = await $.post(BASE_URL + '/saveAnswer', {
replies: JSON.stringify(replies),
questionId: this.questionData.qid,
isSave: false,
randomCount: this.randomCount,
takeTime: takeTime
})
this.$modal.closeLoading()
if (code === 0) {
this.$modal.msg('提交成功')
await this.getUserHasAnswerRandomNum()
await this.checkUserFinishAnswer()
await this.getReply()
await this.assignmentAnswer()
await this.checkUserFinishAnswer()
await this.checkCanAnswerAgain()
await this.getScore()
}
},
//获取回答信息
async getReply() {
const resp = await $.get(BASE_URL + '/answerInfo/' + this.id, {
@@ -559,16 +606,58 @@ layout("/mobile/platform.html"){
currentDate: this.currentDate
})
this.currentScore = resp.data
}
},
checkTimer() {
if (this.timerInterval) {
clearInterval(this.timerInterval)
}
if (!this.finishAnswer) {
this.$dialog.alert({
title: '提示',
message: '本次答题时间' + this.questionData.timerMinute + '分钟,请尽快完成!'
}).then(() => {
this.countDownSeconds = this.questionData.timerMinute * 60
this.timerInterval = setInterval(() => {
this.updateCountdown()
}, 1000)
});
}
},
updateCountdown() {
// 计算剩余的分钟和秒数
let mins = Math.floor(this.countDownSeconds / 60)
let secs = this.countDownSeconds % 60
// 格式化时间,确保分钟和秒数始终是两位数
mins = mins < 10 ? '0' + mins : mins;
secs = secs < 10 ? '0' + secs : secs;
this.remainder = mins + ':' + secs
// 如果倒计时结束,显示结束信息
if (this.countDownSeconds <= 0) {
this.remainder = '时间到'
clearInterval(this.timerInterval)
this.$dialog.alert({
title: '提示',
message: '答题时间到,请点击确认提交答案!'
}).then(() => {
this.autoSubmit()
})
} else {
this.countDownSeconds = this.countDownSeconds - 1
}
}
},
async created() {
if (this.timerInterval) {
clearInterval(this.timerInterval)
}
this.id = GetQueryString("id")
await this.getQuestionData()
await this.checkCanAnswerAgain()
await this.getUserHasAnswerRandomNum()
await this.checkUserFinishAnswer()
await this.getScore()
await this.checkTimer()
this.mLoading = false
}
})
@@ -590,4 +679,4 @@ layout("/mobile/platform.html"){
<!--#
}
#-->
#-->
@@ -327,12 +327,14 @@ layout("/mobile/platform.html"){
})
const result = (resultScore / source) * 100
if (result >= 80) {
if (result > 95) {
this.reviewResult = '非常满意'
} else if (result > 80 && result <= 94) {
this.reviewResult = '满意'
} else if (result >= 60 && result <= 79) {
this.reviewResult = '基本满意'
} else if (result > 60 && result <= 79) {
this.reviewResult = '良好'
} else {
this.reviewResult = '不满意'
this.reviewResult = '一般'
}
/*this.bzList.forEach(v => {
@@ -345,8 +347,6 @@ layout("/mobile/platform.html"){
} else {
this.reviewResult = '不满意'
}*/
console.log(source)
console.log(resultScore)
console.log(this.reviewResult)
vant.Dialog.alert({
title: '测评结果',
@@ -354,14 +354,26 @@ layout("/mobile/platform.html"){
confirmButtonColor: '#1867b0'
})
} else if (this.commentatorData.assessmentMode === 2) {
const result = this.bzList.filter(v => v.resultScore === '满意' || v.resultScore === '基本满意')
if (result.length >= 8) {
const result = this.bzList.filter(v => v.resultScore === '满意')
const satisfactionPercentage = (result.length / this.bzList.length) * 100;
if (satisfactionPercentage > 95) {
this.reviewResult = '非常满意'
} else if (satisfactionPercentage > 80 && satisfactionPercentage <= 94) {
this.reviewResult = '满意'
} else if (satisfactionPercentage > 60 && satisfactionPercentage <= 79) {
this.reviewResult = '良好'
} else {
this.reviewResult = '一般'
}
/*if (result.length >= 8) {
this.reviewResult = '满意'
} else if (result.length >= 6 && result.length <= 7) {
this.reviewResult = '基本满意'
} else {
this.reviewResult = '不满意'
}
}*/
console.log(result)
console.log(this.reviewResult)
vant.Dialog.alert({