From 33413c6be7f338ba1ee92b3218e5c078364675dc Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期三, 24 七月 2024 17:29:07 +0800
Subject: [PATCH] 提交

---
 pages/tabBar/wearhouse/questions.vue |  120 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 87 insertions(+), 33 deletions(-)

diff --git a/pages/tabBar/wearhouse/questions.vue b/pages/tabBar/wearhouse/questions.vue
index 0a7553f..96a200d 100644
--- a/pages/tabBar/wearhouse/questions.vue
+++ b/pages/tabBar/wearhouse/questions.vue
@@ -27,7 +27,7 @@
         </view>
         <view class="content">
           <u-checkbox-group
-              v-if="currentQ.questionType==2"
+              v-if="(type == 1 || type == 2)&& currentQ.questionType==2"
               v-model="currentB"
               placement="column"
               iconPlacement="right"
@@ -45,7 +45,28 @@
             >
             </u-checkbox>
           </u-checkbox-group>
-          <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="currentQ.questionType==1||currentQ.questionType==3" :disabled="type==3?true:false">
+
+          <u-checkbox-group
+              v-if="type == 3 && currentQ.questionType==2"
+              v-model="currentB"
+              placement="column"
+              iconPlacement="right"
+              @change="checkboxChange"
+              :disabled="type==3?true:false"
+              class="myRadio"
+          >
+            <u-checkbox
+                :customStyle="{marginBottom: '15px'}"
+                v-for="(item, index) in currentQ.content.items"
+                :key="index"
+                :label="item.prefix +':'+ item.content"
+                :name="item.prefix"
+                :class="{'picked': currentQ.answer.includes(item.prefix),'wronged': currentB.includes(item.prefix) && !currentQ.answer.includes(item.prefix)}"
+            >
+            </u-checkbox>
+          </u-checkbox-group>
+
+          <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="(type == 1 || type == 2)&&(currentQ.questionType==1||currentQ.questionType==3)" :disabled="type==3?true:false">
             <u-radio
                 :customStyle="{marginBottom: '15px'}"
                 v-for="(item, index) in currentQ.content.items"
@@ -59,9 +80,23 @@
             </u-radio>
           </u-radio-group>
 
-          <u-button style="width: 80%;margin: 30px auto"
+          <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="type == 3 && (currentQ.questionType==1||currentQ.questionType==3)" :disabled="type==3?true:false">
+            <u-radio
+                :customStyle="{marginBottom: '15px'}"
+                v-for="(item, index) in currentQ.content.items"
+                :key="index"
+                shape="square"
+                :label="item.prefix +':'+ item.content"
+                :name="item.prefix"
+                @change="radioChange"
+                :class="{'picked': currentQ.answer == item.prefix, 'wronged': currentA == item.prefix && currentA != currentQ.answer}"
+            >
+            </u-radio>
+          </u-radio-group>
+
+          <u-button style="width: 80%;margin: 5px auto 15px"
                     v-if="currentQ.questionType==2 && currentB.length>0 && type !== 3"
-                    type="primary" shape="circle" text="确认答案" @click="confirmAnswer"></u-button>
+                    type="primary" shape="circle" text="确认答案" @click="confirmAnswer(2)"></u-button>
           <view class="answers" v-if="currentA !==''||currentB.length>0">
             <view>你的答案:
               <span v-if="currentQ.questionType==2" :class="currentQ.answer == currentB.join(',')?'right':'wrong'">{{currentB.join(',')}}</span>
@@ -85,7 +120,7 @@
       >
       </u-empty>
     </view>
-    <u-popup :show="showPanel" :round="40" mode="right" @close="close" @open="open">
+    <u-popup :show="showPanel" :round="40" mode="bottom" @close="close" @open="open">
       <view class="panel">
         <view :class="item.passed==1?'right-a':item.passed==0?'wrong-a':''" v-for="(item,index) in idList" @click="toQuestion(item,index)">
           {{index + 1}}
@@ -154,7 +189,8 @@
       if(res.code == 200){
         let list = res.data || []
         if(list.length>0){
-          t.idList = list.sort((a, b) => a.id - b.id)
+          // t.idList = list.sort((a, b) => a.id - b.id)
+          this.idList = list
         }else{
           t.idList = []
           uni.showToast({
@@ -172,7 +208,7 @@
       const curIdList = this.idList.slice(this.curTotalIndex,this.curTotalIndex + 20)
       this.currentId = this.idList[this.curTotalIndex].id
       await this.getQuestionsByIds(curIdList)
-      this.currentQ = this.questionList[0]
+      this.currentQ = this.questionList.find(i=>i.id == this.currentId)
       this.showAnswer()
       this.showPanel = false
     },
@@ -189,12 +225,13 @@
       if(res.code == 200){
         let list = res.data || []
         if(list.length>0){
-          this.idList = list.sort((a, b) => a.id - b.id)
+          // this.idList = list.sort((a, b) => a.id - b.id)
+          this.idList = list
           this.curTotalIndex = this.bank.questionId ? this.idList.findIndex(i=>i.id == this.bank.questionId):0
           const curIdList = this.idList.slice(this.curTotalIndex,this.curTotalIndex + 20)
           this.currentId = this.idList[this.curTotalIndex].id
           await this.getQuestionsByIds(curIdList)
-          this.currentQ = this.questionList[0]
+          this.currentQ = this.questionList.find(i=>i.id == this.currentId)
           this.showAnswer()
         }else{
           this.idList = []
@@ -213,12 +250,13 @@
       if(res.code == 200){
         let list = res.data || []
         if(list.length>0){
-          this.idList = list.sort((a, b) => a - b)
+          // this.idList = list.sort((a, b) => a - b)
+          this.idList = list
           this.curTotalIndex = 0
           const curIdList = this.idList.slice(0,20)
-          this.currentId = this.idList[0].id
+          this.currentId = this.idList[0]
           await this.getQuestionsByIds(curIdList)
-          this.currentQ = this.questionList[0]
+          this.currentQ = this.questionList.find(i=>i.id == this.currentId)
           this.showAnswer()
         }else{
           this.idList = []
@@ -255,14 +293,14 @@
     },
     groupChange(n) {
       if(this.currentA !== ''){
-        this.confirmAnswer()
+        this.confirmAnswer(1)
       }
     },
     radioChange(n) {
       console.log('radioChange', n);
     },
 
-    confirmAnswer(){
+    confirmAnswer(type){
       const data = {
         answer: this.currentQ.questionType==2?this.currentB.join(','):this.currentA,
         bankId: this.bank.id,
@@ -272,6 +310,9 @@
         if(res.code == 200){
           this.currentQ.exExerciseAnswer.passed = res.data.passed
           this.currentQ.exExerciseAnswer.answer = res.data.answer
+          if(type == 2){
+            this.nextQ()
+          }
           // uni.$u.toast('答案已提交')
         }else{
           uni.$u.toast(res.message)
@@ -282,13 +323,13 @@
     prevQ(){
       if(this.curTotalIndex - 1>=0){
         this.curTotalIndex--
-        if(this.curTotalIndex == 0){
-          this.getQuestionsByIds([this.idList[0]]).then(()=>{
-            // this.currentQ = this.questionList[this.questionList.length-1]
-            this.$set(this, 'currentQ', this.questionList[this.questionList.length-1])
-            this.showAnswer()
-          })
-        }else{
+        // if(this.curTotalIndex == 0){
+        //   this.getQuestionsByIds([this.idList[0]]).then(()=>{
+        //     this.currentQ = this.questionList[this.questionList.length-1]
+        //     // this.$set(this, 'currentQ', this.questionList.find(i=>i.id == this.currentId))
+        //     this.showAnswer()
+        //   })
+        // }else{
           if(this.type == 3){
             this.currentId = this.idList[this.curTotalIndex]
           }else{
@@ -302,11 +343,11 @@
             const curIdList = this.idList.slice(startIndex, this.curTotalIndex+1);
             this.getQuestionsByIds(curIdList).then(()=>{
               // this.currentQ = this.questionList[this.questionList.length-1]
-              this.$set(this, 'currentQ', this.questionList[this.questionList.length-1])
+              this.$set(this, 'currentQ', this.questionList.find(i=>i.id == this.currentId))
               this.showAnswer()
             })
           }
-        }
+        // }
       }else{
         uni.showToast({
           title: '已经是第一题了',
@@ -329,7 +370,7 @@
         }else{
           const curIdList = this.idList.slice(this.curTotalIndex,this.curTotalIndex + 20)
           this.getQuestionsByIds(curIdList).then(()=>{
-            this.$set(this, 'currentQ', this.questionList[0])
+            this.$set(this, 'currentQ', this.questionList.find(i=>i.id == this.currentId))
             // this.currentQ = this.questionList[0]
             this.showAnswer()
           })
@@ -417,8 +458,7 @@
 }
 
 .panel{
-  height: 100vh;
-  width: 60vw;
+  height: 60vh;
   background: #f2f2f2;
   overflow-y: auto;
   padding: 15px;
@@ -430,7 +470,8 @@
 
   &>view{
     padding: 5px;
-    min-width: calc(20% - 12px);
+    box-sizing: border-box;
+    min-width: 33px;
     border-radius: 4px;
     text-align: center;
     background: rgba(41,121,255,0);
@@ -438,7 +479,7 @@
     color: #333;
     background: #f2f2f2;
     transition: all 100ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
-    box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.15);
+    box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.1);
     cursor: pointer;
 
     &:active {
@@ -488,7 +529,7 @@
       border-radius: 4px;
       color: #2979ff;
       background: #f5f7fa;
-      border: 1px solid rgba(41,121,255,.4);
+      border: 1px solid rgba(41,121,255,.2);
       box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.1);
       transition: box-shadow .25s ease !important;
     }
@@ -535,7 +576,7 @@
   align-items: center;
   justify-content: space-around;
   z-index: 99;
-  bottom: 60px;
+  bottom: 20px;
   left: 0;
 }
 
@@ -551,14 +592,14 @@
   box-sizing: border-box;
   border-radius: 8px;
   background: #f5f7fa;
-  border: 1px solid #fff;
+  border: 1.5px solid #fff;
   box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.1);
-  transition: box-shadow .25s ease !important;
+  transition: box-shadow .25s ease,box-width .25s ease !important;
 }
 
 .myRadio{
   /deep/ .picked{
-    border: 2px solid #2979ff;
+    border: 1.5px solid #2979ff;
 
     .u-radio__icon-wrap,.u-checkbox__icon-wrap{
       border-color: #fff !important;
@@ -570,6 +611,19 @@
       color: #2979ff
     }
   }
+  /deep/ .wronged{
+    border: 1.5px solid #ed6464;
+
+    .u-radio__icon-wrap,.u-checkbox__icon-wrap{
+      border-color: #fff !important;
+      span{
+        color: #fff !important;
+      }
+    }
+    span{
+      color: #ed6464
+    }
+  }
 }
 
 /deep/ .u-checkbox:active {

--
Gitblit v1.9.2