专项练习联调

This commit is contained in:
2025-11-05 11:23:57 +08:00
parent 9a706c1275
commit 3565339fd7

View File

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