This commit is contained in:
2025-11-05 11:25:40 +08:00

View File

@@ -67,8 +67,8 @@
</div>
</div>
<div class="problemBtns">
<div v-if="analysis&&judgWhether!=''&&questionIndex!=problemData.length" @click="questionIndex.value+=1">下一题</div>
<div v-else :class="(radio==''&&radio2==''&&checkList.length==0&&isRunning)?'events':''">提交答案</div>
<div v-if="analysis&&judgWhether!=''&&questionIndex!=problemData.length" @click="questionIndex+=1">下一题</div>
<div v-else :class="((radio==''&&radio2==''&&checkList.length==0&&isRunning)||analysis)?'events':''" @click="submit()">提交答案</div>
</div>
</template>
</div>
@@ -86,7 +86,7 @@
<div>取消</div>
</div>
</div>
<div class="footerBtn">完成练习</div>
<div class="footerBtn" @click="exit()">完成练习</div>
<div class="footerLeft">
<div>
<div class="icons" style="background-color: #1CADF5;"></div>
@@ -120,7 +120,7 @@
<script setup>
import { reactive, inject, watch, ref, onMounted,onBeforeUnmount,computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
const { $api,urls , navTo, vacanciesTo, formatTotal, config } = inject('globalFunction');
const { $api,urls , navTo,navBack , vacanciesTo, formatTotal, config } = inject('globalFunction');
import useUserStore from '@/stores/useUserStore';
import useDictStore from '@/stores/useDictStore';
const userInfo = ref({});
@@ -161,9 +161,8 @@ watch(questionIndex, (newVal, oldVal) => {
// });
onLoad((options) => {
userInfo.value = uni.getStorageSync('userInfo') || {};
Authorization.value=uni.getStorageSync('Padmin-Token')||''
queryData();
getHeart();
});
onShow(()=>{
@@ -174,6 +173,28 @@ onBeforeUnmount(() => {
timer = null; // 防止内存泄漏,确保下次不会再误用已清除的定时器
}
});
function getHeart() {
const raw =Authorization.value;
const token = typeof raw === "string" ? raw.trim() : "";
const headers = token ? { 'Authorization': raw.startsWith("Bearer ") ? raw : `Bearer ${token}` }: {}
$api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, headers).then((resData) => {
if (resData.code == 200) {
getUserInfo();
} else {
navTo('/packageB/login')
}
});
};
function getUserInfo(){
let header={
'Authorization':Authorization.value
}
$api.myRequest('/system/user/login/user/info', {},'get',10100,header).then((resData) => {
userInfo.value = resData.info || {};
// userId.value=resData.info.userId
queryData()
});
};
function queryData(){
problemData.value=[]
let header={
@@ -198,7 +219,7 @@ function collect(is){
}
$api.myRequest('/train/public/questionUser/addOrUpdateCollect', {
userId: userInfo.value.userId,
questionId:problemData.value[this.questionIndex-1].questionId,
questionId:problemData.value[questionIndex.value-1].questionId,
collect:is
},'post',9100,header).then((resData) => {
problemData.value[questionIndex.value-1].isCollect=is
@@ -213,8 +234,7 @@ function accuracyRates(){
$api.myRequest('/train/public/trainPractice/getCount', {
userId: userInfo.value.userId,
},'post',9100,header).then((resData) => {
// debugger
// accuracyRate.value=resData.truePresent
accuracyRate.value=resData.truePresent
});
};
//提交答案
@@ -223,29 +243,32 @@ function submit(){
let parm={
questionId:problemData.value[indexs].questionId,
userId:userInfo.value.userId,
answer:this.problemData.value[indexs].answer
answer:problemData.value[indexs].answer
}
if(problemData.value[indexs].type=='single'){
parm.submitAnswer=radio.value
}else if(this.problemData[indexs].type=='multiple'){
parm.submitAnswer=this.checkList.join(',')
}else if(this.problemData[indexs].type=='judge'){
parm.submitAnswer=this.radio2
}else if(problemData.value[indexs].type=='multiple'){
parm.submitAnswer=checkList.value.join(',')
}else if(problemData.value[indexs].type=='judge'){
parm.submitAnswer=radio2.value
}
startTrainingApi.submitAnswer(parm).then((res)=>{
if(res&&res.code==200){
this.analysis=true
this.judgWhether=res.msg
this.problemList[indexs].whether=res.msg
if(res.msg=='正确'){
this.correctIndex++
}else if(res.msg=='错误'){
this.errorsIndex++
let header={
'Authorization':Authorization.value,
'Content-Type':"application/json"
}
$api.myRequest('/train/public/trainPractice/submitAnswer', parm,'post',9100,header).then((resData) => {
if(resData&&resData.code==200){
analysis.value=true
judgWhether.value=resData.msg
problemList.value[indexs].whether=resData.msg
if(resData.msg=='正确'){
correctIndex.value++
}else if(resData.msg=='错误'){
errorsIndex.value++
}
accuracyRates()
}
this.accuracyRates()
}
})
});
};
function selected(i){
radio.value=i
@@ -312,6 +335,9 @@ function switchs(i){
questionIndex.value=(i+1)
dialogVisible.value=false
};
function exit(){
navBack()
}
</script>
<style lang="stylus" scoped>