修改提交按钮为返回值可点击

This commit is contained in:
zhangsir
2024-05-09 16:56:33 +08:00
parent b6be7e8f34
commit 15ed2923ad

View File

@@ -31,7 +31,7 @@
</view> </view>
<view style="height: 50px;"></view> <view style="height: 50px;"></view>
<view v-if="!stop" class="bottom-btns"> <view v-if="!stop" class="bottom-btns">
<u-button type="success" text="提交" class="sub" @click="debouncedPresent"></u-button> <u-button type="success" text="提交" class="sub" :disabled="!thisTrue" @click="present"></u-button>
<u-button type="info" text="上一题" @click="prevSub" class="next" v-if="curIndex>0"></u-button> <u-button type="info" text="上一题" @click="prevSub" class="next" v-if="curIndex>0"></u-button>
<u-button type="primary" text="下一题" @click="nextSub" class="next" v-if="curIndex<(total-1)"></u-button> <u-button type="primary" text="下一题" @click="nextSub" class="next" v-if="curIndex<(total-1)"></u-button>
</view> </view>
@@ -65,6 +65,7 @@
export default { export default {
data() { data() {
return { return {
thisTrue: true,
studyId:'', studyId:'',
examId:'', examId:'',
ctype:10, ctype:10,
@@ -92,8 +93,8 @@
if(this.examId){ if(this.examId){
this.loadExamInfo(); this.loadExamInfo();
} }
this.debouncedPresent = this.throttle(this.present, 30000); // this.debouncedPresent = this.debounce(this.present, 500);
this.confirmStop = this.throttle(this.submitTest,30000) // this.confirmStop = this.debounce(this.submitTest,500)
}, },
methods: { methods: {
changeTimer(){ changeTimer(){
@@ -232,9 +233,9 @@
} }
} }
}, },
// confirmStop(){ confirmStop(){
// this.submitTest() this.submitTest()
// }, },
cancelStop(){ cancelStop(){
//应该返回课程面页 //应该返回课程面页
this.confirmFinish(); this.confirmFinish();
@@ -343,7 +344,9 @@
var dateDiff = now.getTime() - this.startTime.getTime();//时间差的毫秒数 var dateDiff = now.getTime() - this.startTime.getTime();//时间差的毫秒数
var minutes=Math.floor(dateDiff/(1000))//计算相差秒数分钟记录的太大经常为0 var minutes=Math.floor(dateDiff/(1000))//计算相差秒数分钟记录的太大经常为0
postData.testDuration=minutes; postData.testDuration=minutes;
this.thisTrue = false
apiCourseStudy.saveExam(postData).then(res=>{ apiCourseStudy.saveExam(postData).then(res=>{
this.thisTrue = true
if(res.status == 200) { if(res.status == 200) {
this.studyItemId=res.result.studyItemId; this.studyItemId=res.result.studyItemId;
this.scoreShow=true; this.scoreShow=true;
@@ -352,14 +355,14 @@
} }
}) })
}, },
throttle(func, delay) { debounce(func, delay) {
let lastExecTime = 0; let timerId;
return function (...args) { return function (...args) {
const now = Date.now(); if (timerId) clearTimeout(timerId);
if (now - lastExecTime >= delay) { timerId = setTimeout(() => {
func.apply(this, args); func.apply(this, args);
lastExecTime = now; timerId = null;
} }, delay);
}; };
}, },
present(){ present(){