瀏覽代碼

真实模拟考试UI改版,增加模拟考试题目的字体大小,滑动下一题

zhangyujun 3 年之前
父節點
當前提交
e6f15f9b4d

+ 61 - 14
src/App.vue

@@ -1,22 +1,69 @@
 <script>
+export default {
+  onLaunch: function () {
+    let updateManager = uni.getUpdateManager();
+    if (!updateManager) {
+      return;
+    } else {
+      //新版本更新
+      if (uni.canIUse("getUpdateManager")) {
+        //判断当前微信版本是否支持版本更新
+
+        updateManager.onCheckForUpdate(function (res) {
+          if (res.hasUpdate) {
+            // 请求完新版本信息的回调
+            updateManager.onUpdateReady(function () {
+              uni.showModal({
+                title: "更新提示",
+                content: "新版本已经准备好,是否重启应用?",
+                success: function (res) {
+                  if (res.confirm) {
+                    // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+                    updateManager.applyUpdate();
+                  }
+                },
+              });
+            });
+            updateManager.onUpdateFailed(function () {
+              uni.showModal({
+                // 新的版本下载失败
+                title: "已经有新版本了哟~",
+                content:
+                  "新版本已经上线啦~,请您删除当前小程序,重新搜索(极速生活圈)打开哟~",
+              });
+            });
+          } else {
+          }
+        });
+      } else {
+        uni.showModal({
+          // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
+          title: "提示",
+          content:
+            "当前微信版本过低,部分功能无法使用,请升级到最新微信版本后重试。",
+        });
+      }
+    }
+  },
+};
 </script>
 
 <style>
-	@import "/wxcomponents/vant/common/index.wxss";
-	@import "@/common/css/animation.css";
+@import "/wxcomponents/vant/common/index.wxss";
+@import "@/common/css/animation.css";
 
-	/*每个页面公共css */
-	view {
-		margin: 0;
-		padding: 0;
-		box-sizing: border-box;
-	}
+/*每个页面公共css */
+view {
+  margin: 0;
+  padding: 0;
+  box-sizing: border-box;
+}
 
-	html {
-		background-color: #F1F1F1;
-	}
+html {
+  background-color: #f1f1f1;
+}
 
-	.night {
-		filter: invert(1) hue-rotate(180deg);
-	}
+.night {
+  filter: invert(1) hue-rotate(180deg);
+}
 </style>

+ 8 - 1
src/api/modules/buy.js

@@ -22,7 +22,14 @@ const buy={
             url:'/system/dict/data/type/'+dictType,
             method:'GET'
         })
-    }
+    },
+	//查询是否开启ios支付的接口
+	systemConfigConfigKeyIos_vip_open(){
+		return request({
+			url:"system/config/configKey/ios_vip_open",
+			method:"GET"
+		})
+	}
 }
 
 export default buy

二進制
src/assets/img/aprilExam.png


+ 46 - 18
src/otherPages/buyVip/index.vue

@@ -12,7 +12,11 @@
             class="radio-item"
             :class="{ select: index === goodsIndex }"
             :key="index"
-            @click="()=>{goodsIndex = index}"
+            @click="
+              () => {
+                goodsIndex = index;
+              }
+            "
           >
             <span>{{ item.dictLabel }}</span>
             <div v-if="index === 1" class="radio-item-recom">推荐</div>
@@ -30,7 +34,9 @@
         </div>
       </div>
       <div class="button-box">
-        <div class="button" @click="buy">立即开通</div>
+        <div v-if="!isIos" class="button" @click="buy">立即开通</div>
+        <div v-if="isIos&&!ios_vip_open" class="button_gray">ios不支持</div>
+        <div v-if="isIos&&ios_vip_open" class="button" @click="buy">立即开通</div>
       </div>
       <div style="height: 60px"></div>
     </div>
@@ -39,10 +45,12 @@
 
 <script>
 import topImg from "./top-background.png";
-import api from '@/api/index'
+import api from "@/api/index";
 export default {
   data() {
     return {
+      isIos:false,
+      ios_vip_open:0,
       goodsList: [
         {
           searchValue: null,
@@ -102,28 +110,33 @@ export default {
           default: false,
         },
       ],
-      goodsIndex:1,
-      topImg
+      goodsIndex: 1,
+      topImg,
     };
   },
   methods: {
     buy(e) {
-        api.buy.studentXcxWxPrepareOrder({
-            dictCode:this.goodsList[this.goodsIndex].dictCode
-        }).then(res=>{
-            uni.requestPayment({
-                ...res.data
-            })
+      api.buy
+        .studentXcxWxPrepareOrder({
+          dictCode: this.goodsList[this.goodsIndex].dictCode,
         })
-
-
+        .then((res) => {
+          uni.requestPayment({
+            ...res.data,
+          });
+        });
     },
   },
-  mounted () {
-      api.buy.systemDictDataType("vip_type_price").then(res=>{
-          this.goodsList = res.data
-
-      })
+  mounted() {
+    const systemInfo = wx.getSystemInfoSync()
+    console.log(systemInfo)
+    api.buy.systemConfigConfigKeyIos_vip_open().then(res=>{
+      this.ios_vip_open = Number(res.data)
+    })
+    this.isIos = systemInfo.platform=='ios'
+    api.buy.systemDictDataType("vip_type_price").then((res) => {
+      this.goodsList = res.data;
+    });
   },
 };
 // import { getVipPrice, prepareOrder } from "@/api";
@@ -254,6 +267,20 @@ export default {
     display: flex;
     justify-content: center;
     align-items: center;
+    .button_gray {
+      width: 152px;
+      height: 40px;
+      background: #b1b1b1;
+      border-radius: 30px;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      font-size: 15px;
+      font-family: PingFang SC;
+      font-weight: 500;
+      color: #fff;
+      letter-spacing: 0px;
+    }
     .button {
       width: 152px;
       height: 40px;
@@ -267,6 +294,7 @@ export default {
       font-weight: 500;
       color: #91540f;
       letter-spacing: 0px;
+
       &:active {
         background-color: red;
       }

+ 79 - 15
src/otherPages/mockExam/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <view class="box">
+  <view class="box" @touchstart="touchStart" @touchend="touchEnd">
     <nav-bar :title="navTitle"> </nav-bar>
     <view style="text-align: center">
       <van-count-down :time="time"></van-count-down>
@@ -10,7 +10,9 @@
         problemList[problemListIndex].questionType | questionType
       }}</span>
       <!-- <text>{{ problemListIndex + 1 }}、</text> -->
-      <text class="">{{ problemList[problemListIndex].issue }}</text>
+      <text class="problem-issue">{{
+        problemList[problemListIndex].issue
+      }}</text>
       <view v-if="problemList[problemListIndex].image" class="problem-img">
         <image
           mode="widthFix"
@@ -19,9 +21,7 @@
       </view>
       <!-- 单项选择 -->
       <view
-        v-if="
-          problemList[problemListIndex].questionType < 3
-        "
+        v-if="problemList[problemListIndex].questionType < 3"
         class="problem-ops"
       >
         <van-radio-group
@@ -58,9 +58,7 @@
 
       <!-- 多项选择 -->
       <view
-        v-if="
-          problemList[problemListIndex].questionType == 3
-        "
+        v-if="problemList[problemListIndex].questionType == 3"
         class="problem-ops"
       >
         <van-checkbox-group
@@ -169,6 +167,8 @@ export default {
         subject: "",
         title: "",
       },
+      examTimer: 0,
+      examTimeUse: 0,
       time: 45 * 60 * 1000,
       problemListTotal: 1,
       problemList: [
@@ -225,6 +225,8 @@ export default {
           userAnswer: [],
         },
       ],
+      touchx: 0,
+      touchy: 0,
       problemListIndex: 0,
     };
   },
@@ -249,22 +251,66 @@ export default {
     },
   },
   methods: {
+    touchStart(e) {
+      var that = this;
+
+      (this.touchx = e.changedTouches[0].clientX),
+        (this.touchy = e.changedTouches[0].clientY);
+    },
+    touchEnd(e) {
+      console.log(e);
+      var that = this;
+      let x = e.changedTouches[0].clientX;
+      let y = e.changedTouches[0].clientY;
+      let turn = "";
+      if (x - that.touchx > 50 && Math.abs(y - that.touchy) < 50) {
+        //右滑
+        turn = "right";
+        this.problemListIndex <= 0
+          ? uni.showToast({
+              title: "到底了",
+              icon: "none",
+            })
+          : this.problemListIndex--;
+      } else if (x - that.touchx < -50 && Math.abs(y - that.touchy) < 50) {
+        //左滑
+        turn = "left";
+        this.problemListIndex >= this.problemList.length - 1
+          ? uni.showToast({
+              title: "到底了",
+              icon: "none",
+            })
+          : this.problemListIndex++;
+      }
+      if (y - that.touchy > 50 && Math.abs(x - that.touchx) < 50) {
+        //下滑
+        turn = "down";
+      } else if (y - that.touchy < -50 && Math.abs(x - that.touchx) < 50) {
+        //上滑
+        turn = "up";
+      }
+      //根据方向进行操作
+      if (turn == "down") {
+        //下滑触发操作
+      }
+      console.log(turn);
+    },
     submitExam(e) {
       let score = 0;
       let query = this.query;
+      let that = this;
       this.problemList.forEach((item, index) => {
         if (
           typeof item.userAnswer == "object" &&
           Array.isArray(item.userAnswer)
         ) {
           let answerArr = item.answer.split("-");
-          answerArr.sort((a, b) => {
-            return a - b;
-          });
-          item.userAnswer.sort((a, b) => {
-            return a - b;
-          });
-          if (answerArr.join("-") === item.userAnswer.join("-")) {
+          answerArr = answerArr.sort();
+          let userAnswer = item.userAnswer.sort();
+          if (index > 39) {
+            console.log(answerArr, userAnswer);
+          }
+          if (answerArr.join("-") === userAnswer.join("-")) {
             score = score + 1;
           }
         } else if (typeof item.userAnswer == "string") {
@@ -276,11 +322,16 @@ export default {
         content: "交卷后不可再修改了",
         success(res) {
           if (res.confirm) {
+            let useTime = "";
+            let useTimer = new Date(that.examTimeUse);
+            clearInterval(that.examTimer);
+            useTime = `${useTimer.getMinutes()}:${useTimer.getSeconds()}`;
             uni.navigateTo({
               url:
                 "/otherPages/mockExamEnd/index?" +
                 utils.mapToUrlQuery({
                   score,
+                  useTime,
                   ...query,
                 }),
             });
@@ -348,6 +399,13 @@ export default {
         that.problemListTotal = res.total;
         that.problemList = res.rows;
       });
+    this.examTimer = setInterval(() => {
+      this.examTimeUse = this.examTimeUse + 1000;
+      if (this.examTimeUse > this.time) {
+        this.submitExam();
+        clearInterval(this.examTimer);
+      }
+    }, 1000);
   },
   computed: {
     //liceCar=1&liceTruck=&liceBus=&liceMoto=&name=科目一&cert=C1/C2/C3&vehicle=轿车&subject=1&title=顺序练习&sort=3
@@ -356,6 +414,9 @@ export default {
       return `(${this.query.cert})/${subjectName}/${this.query.title}`;
     },
   },
+  destroyed() {
+    clearInterval(examTimeUse);
+  },
 
   components: {
     navBar,
@@ -408,6 +469,9 @@ export default {
     /deep/ .van-radio {
       padding-bottom: 15rpx;
     }
+    .problem-issue {
+      font-size: 42rpx;
+    }
     .problem-type {
       padding-left: 10rpx;
       padding-right: 10rpx;

+ 0 - 0
src/otherPages/mockExamEnd/考试不合格.png → src/otherPages/mockExamEnd/buhege.png


+ 0 - 0
src/otherPages/mockExamEnd/考试合格.png → src/otherPages/mockExamEnd/hege.png


+ 36 - 18
src/otherPages/mockExamEnd/index.vue

@@ -1,7 +1,7 @@
 <template>
   <view>
-    <div class="result-box" v-if="score>=90">
-      <img class="img" src="./考试合格.png" />
+    <div class="result-box" v-if="score >= 90">
+      <img class="img" :src="hege" />
       <span class="text">恭喜你,测试通过~</span>
       <div class="fraction-box">
         <span class="fraction">{{ score }}</span
@@ -14,10 +14,10 @@
       >
     </div>
     <div class="result-box" v-else>
-      <img class="img" src="./考试不合格.png" />
+      <img class="img" :src="buhege" />
       <span class="text">抱歉,测试未通过~</span>
       <div class="fraction-box">
-        <span class="fraction">{{ score }}</span
+        <span class="fraction">{{ subject == 1 ? score : score * 2 }}</span
         >分
       </div>
       <span class="hint">(满分:100;合格:90)</span>
@@ -27,26 +27,44 @@
       >
     </div>
     <div class="btn-box">
-      <m-button width="180rpx" height="60rpx" @click="goWrongPreview" class="btn1" text="错题重做" />
-      <m-button width="180rpx" height="60rpx" @click="againTest" class="btn2" text="重新测试" />
+      <m-button
+        width="180rpx"
+        height="60rpx"
+        @click="goWrongPreview"
+        class="btn1"
+        text="错题重做"
+      />
+      <m-button
+        width="180rpx"
+        height="60rpx"
+        @click="againTest"
+        class="btn2"
+        text="重新测试"
+      />
     </div>
   </view>
 </template>
 
 <script>
+import hege from "./hege.png";
+import buhege from "./buhege.png";
 export default {
-    data() {
-        return {
-            score: 0,
-            useTime:""
-
-        }
-    },
-    onLoad(op){
-      this.score = op.score
-      this.useTime = op.useTime
-    }
-}
+  data() {
+    return {
+      hege,
+      buhege,
+      score: 0,
+      useTime: "",
+      subject: 1,
+      query: {},
+    };
+  },
+  onLoad(query) {
+    this.score = query.score;
+    this.useTime = query.useTime;
+    this.subject = query.subject;
+  },
+};
 //提交考试成绩
 // createTestScores({
 // 	type: query.vehicle as string,

二進制
src/otherPages/mockExamEnd/mockExamEnd.zip


+ 2 - 2
src/pages/carVideo/index.vue

@@ -229,7 +229,7 @@ export default {
       {
         img: "https://t1-1305573081.file.myqcloud.com/wxapp/static/imgs/home/RealExaminationRoomSimulation@2x.png",
         text: "真实模拟考试",
-        path: "/pages/mockExam/begin?username=张宇&subject=1&type=liceCar&headimg=https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTL42T648KSueEiaibrIt0jgEmgBUlRvbu1ES3VnKoBicK4GOnuYK8oeSLL0V0gmeGaWwONo78oPpvzUQ/132",
+        path: "/pages/mockExam/begin",
       },
 
       {
@@ -287,7 +287,7 @@ export default {
       {
         img: "https://t1-1305573081.file.myqcloud.com/wxapp/static/imgs/home/RealExaminationRoomSimulation@2x.png",
         text: "真实模拟考试",
-        path: "/pages/mockExam/begin?username=张宇&subject=1&type=liceCar&headimg=https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTL42T648KSueEiaibrIt0jgEmgBUlRvbu1ES3VnKoBicK4GOnuYK8oeSLL0V0gmeGaWwONo78oPpvzUQ/132",
+        path: "/pages/mockExam/begin",
       },
 
       {

+ 12 - 5
src/pages/mockExam/begin.vue

@@ -27,7 +27,7 @@
             </view>
             <view class="box2-space1"></view>
             <view class="box2-name" style="color: #ba2f35">
-              考生姓名:{{ query.username || "张三" }}
+              考生姓名:{{ nickName || "张三" }}
             </view>
             <view class="pl124 exam-container">
               <view
@@ -69,6 +69,8 @@ export default {
       subject4Img,
       subjectImg: subject1Img,
       backButton,
+      nickName:"",
+      headImage:"",
       query: {
         username: "",
         headimg: "",
@@ -81,8 +83,10 @@ export default {
     this.query.subject == 4
       ? (this.subjectImg = this.subject4Img)
       : (this.subjectImg = this.subject1Img);
-    this.query.username = decodeURIComponent(option.username);
-    this.query.headimg = decodeURIComponent(option.headimg);
+    // this.query.username = decodeURIComponent(option.username);
+    // this.query.headimg = decodeURIComponent(option.headimg);
+    this.nickName = uni.getStorageSync('userInfo').nickName
+    this.headImage = uni.getStorageSync('userInfo').headImage
   },
   methods: {
     backView(){
@@ -91,10 +95,13 @@ export default {
     },
     goExam() {
       let page = getCurrentPages()[0];
-
+      let query = {
+        ...this.query,
+  
+      }
       let params = page.$page.fullPath.split("?")[1];
       uni.navigateTo({
-        url: "/pages/mockExam/test?" + utils.mapToUrlQuery(this.query),
+        url: "/pages/mockExam/test?" + utils.mapToUrlQuery(query),
       });
     },
   },

+ 195 - 0
src/pages/mockExam/components/correctAnswerMask.vue

@@ -0,0 +1,195 @@
+<template>
+  <div class="mask">
+    <div>
+      <div class="dialog">
+        <div class="title">
+          <span>答案提示</span>
+        </div>
+        <div class="mid">
+          <!-- <div class="mid-line1">亲爱的考生:</div> -->
+          <div class="mid-line2">
+              解释:{{explainJs}}
+          </div>
+          <!-- <div class="mid-line3" v-if="correctScore >= 90">再接再励</div> -->
+          <div class="mid-line3">技巧:{{explainJq}}</div>
+        </div>
+        <div class="bottom">
+          <button
+            @click="
+              () => {
+                $emit('close')
+              }
+            "
+          >
+            关闭
+          </button>
+      
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      option: {},
+    };
+  },
+  methods: {
+    back() {
+      let page = getCurrentPages()[0];
+      let params = page.$page.fullPath.split("?")[1];
+      uni.navigateTo({
+        url: `/pages/mockExam/begin?${params}`,
+      });
+    },
+  },
+  // setup(props, { emit }) {
+  //   const state = reactive({
+  //     count: 0,
+  //   });
+  //   const phone = new Phone();
+  //   const backView = phone.backView.bind(phone);
+  //   const time = ref(8);
+  //   const timer = window.setInterval((e) => {
+  //     time.value = time.value - 1;
+  //     if (time.value === 0) {
+  //       window.clearInterval(timer);
+  //       // backView()
+  //       router.push({
+  //         name: 'examBegin',
+  //         query: {
+  //           ...router.currentRoute.value.query,
+  //         },
+  //       });
+  //     }
+  //   }, 1000);
+  //   const sendPaper = () => {
+  //     emit('confirm');
+  //   };
+  //   const cancelSubmit = () => {
+  //     emit('cancel');
+  //   };
+
+  //   return {
+  //     ...toRefs(state),
+  //     props,
+  //     sendPaper,
+  //     cancelSubmit,
+  //     time,
+  //     timer,
+  //     router,
+  //     backView,
+  //   };
+  // },
+  //correct
+  destroyed() {
+    window.clearInterval(this.timer);
+  },
+  mounted() {
+
+  },
+  props: {
+    explainJs:{
+      type:String,
+      default:""
+    },
+    explainJq:{
+      type:String,
+      default:""
+    },
+    correctScore: {
+      type: Number,
+      required: true,
+      default: 0,
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+button {
+  border-radius: 0;
+  border: none;
+}
+.mask {
+  position: fixed;
+  top: 0;
+  left: 0;
+  width: 750rpx;
+  height: 100vh;
+  background-color: rgba(0, 0, 0, 0.65);
+  z-index: 10;
+  display: flex;
+  align-content: center;
+  align-items: center;
+  justify-content: center;
+  .dialog {
+    width: 400rpx;
+    background: #fff;
+    .title {
+      width: 100%;
+      line-height: 40rpx;
+      height: 40rpx;
+      background: #306ace;
+      color: #fff;
+      font-size: 12rpx;
+      text-align: center;
+    }
+    .mid {
+      width: 100%;
+      background: #fff;
+
+      padding-left: 10rpx;
+      padding-right: 10rpx;
+      font-size: 14rpx;
+      .mid-line1 {
+        line-height: 25rpx;
+        height: 25rpx;
+        text-align: left;
+      }
+      .mid-line2 {
+        text-align: left;
+        line-height: 30rpx;
+      }
+      .mid-line3 {
+        text-align: left;
+        line-height: 30rpx;
+      }
+      .mid-line4 {
+        text-align: left;
+        line-height: 30rpx;
+      }
+    }
+    .bottom {
+      background: #306ace;
+      width: 100%;
+      height: 70rpx;
+      display: flex;
+      justify-content: center;
+      flex-wrap: wrap;
+      align-items: flex-start;
+      align-content: flex-start;
+
+      button:nth-child(1) {
+        height: 30rpx;
+        margin-top: 10rpx;
+        line-height: 30rpx;
+      }
+      .bottom-line {
+        width: 100%;
+        text-align: center;
+        color: #fff;
+        font-size: 12rpx;
+        margin-top: 5rpx;
+      }
+      button:nth-child(2) {
+        height: 30rpx;
+        line-height: 30rpx;
+      }
+    }
+  }
+}
+</style>

+ 104 - 29
src/pages/mockExam/test.vue

@@ -19,6 +19,16 @@
       "
     ></beforeSubmitMask>
     <submitMask v-if="submitVisible" :correctScore="correctScore"></submitMask>
+    <correctAnswerMask
+      :explainJq="list[listIndex].explainJq"
+      :explainJs="list[listIndex].explainJs"
+      @close="
+        () => {
+          correctAnswer = false;
+        }
+      "
+      v-if="correctAnswer"
+    ></correctAnswerMask>
     <div class="box">
       <div class="main">
         <div class="container1">
@@ -29,11 +39,11 @@
           <div class="student">
             <div class="student-header">考生信息</div>
             <div class="mt10">
-              <img class="driver" :src="headimg" />
+              <img class="driver" :src="headImage" />
               <div class="driverInfo">
-                <div>姓名:{{ username }}</div>
+                <div>姓名:{{ nickName }}</div>
                 <div>性别:{{ sex }}</div>
-                <div>类型:{{ carType }}</div>
+                <div>类型:{{ vehicle }}</div>
                 <div>科目:{{ subject }}</div>
               </div>
             </div>
@@ -72,7 +82,8 @@
                     class="answer-list-item"
                     @click="selectExamAnswer(item)"
                     :class="{
-                      answer_selected: list[listIndex].userAnswer == item,
+                      answer_selected:
+                        list[listIndex].userAnswer.includes(item),
                     }"
                   >
                     {{ letter[index] }}
@@ -85,7 +96,9 @@
           <div class="container2-row2">
             <div class="operate">
               <div class="w-half">
-                <div class="left-line1">操作提示:判断题</div>
+                <div class="left-line1">
+                  操作提示:{{ list[listIndex].questionType | questionType }}
+                </div>
                 <div class="left-line2">
                   请在备选答案中选择你认为正确的答案!
                 </div>
@@ -162,25 +175,30 @@
                 </td>
               </tr> -->
 
-              <tr class="coll-table-topicTr" :key="index" v-for="(item, index) in list.length / 10">
+              <tr
+                class="coll-table-topicTr"
+                :key="index"
+                v-for="(item, index) in list.length / rowNum"
+              >
                 <!-- <td class="coll-table-topic-item bg-498ef5">
                   <div style="white-space: nowrap">{{ index + 1 }}行</div>
                 </td> -->
                 <td
-                  v-for="(_item, _index) in 10"
+                  class="coll-table-topicTr-td"
+                  v-for="(_item, _index) in rowNum"
                   :class="{
-                    collselected: index * 10 + _index == listIndex,
+                    collselected: index * rowNum + _index == listIndex,
                   }"
-                  :data-key="index * 10 + _index + 1"
+                  :data-key="index * rowNum + _index + 1"
                   :key="_index"
                   @click="changeListIndex"
                 >
                   <div
                     style="white-space: nowrap"
-                    :data-key="index * 10 + _index + 1"
+                    :data-key="index * rowNum + _index + 1"
                     class="coll-table-topic-item"
                   >
-                    {{ index * 10 + _index + 1 }}
+                    {{ index * rowNum + _index + 1 }}
                   </div>
                 </td>
               </tr>
@@ -213,16 +231,20 @@
 import api from "@/api/index.js";
 import beforeSubmitMask from "./components/beforeSubmitMask.vue";
 import submitMask from "./components/submitMask.vue";
+import correctAnswerMask from "./components/correctAnswerMask.vue";
 export default {
   data() {
     return {
       sex: "男",
+      vehicle: "",
+      rowNum: 10,
       beforeSubmitVisible: false,
       submitVisible: false,
-      username: "",
+      correctAnswer: false,
+      nickName: "",
       subject: "",
       subjectMap: ["科目零", "科目一", "科目二", "科目三", "科目四"],
-      headimg: "",
+      headImage: "",
       carType: "",
       listIndex: 0,
       letter: ["A", "B", "C", "D", "E", "F"],
@@ -702,6 +724,25 @@ export default {
       },
     };
   },
+  filters: {
+    questionType: function (questionType) {
+      questionType = Number(questionType);
+      let questionTypeName = "";
+      switch (questionType) {
+        case 1:
+          questionTypeName = "判断题";
+          break;
+        case 2:
+          questionTypeName = "选择题";
+          break;
+        case 3:
+          questionTypeName = "多选题";
+          break;
+      }
+
+      return questionTypeName;
+    },
+  },
   methods: {
     getTimeStr(timeStrap) {
       let timer = new Date(timeStrap);
@@ -728,10 +769,33 @@ export default {
       this.listIndex = this.listIndex + 1;
     },
     selectExamAnswer(item) {
-      this.$set(this.list, this.listIndex, {
-        ...this.list[this.listIndex],
-        userAnswer: item,
-      });
+      if (this.list[this.listIndex].isComplete) {
+        return;
+      }
+      if (this.list[this.listIndex].questionType < 3) {
+        this.correctAnswer = this.list[this.listIndex].answer !== item;
+        this.$set(this.list[this.listIndex], "isComplete", true);
+      }
+
+      if (this.list[this.listIndex].questionType < 3) {
+        this.$set(this.list, this.listIndex, {
+          ...this.list[this.listIndex],
+          userAnswer: item,
+        });
+      } else {
+        let userAnswer = [];
+        userAnswer = [...this.list[this.listIndex].userAnswer];
+        userAnswer.includes(item)
+          ? (userAnswer = userAnswer.filter((_item) => {
+              return item !== _item;
+            }))
+          : userAnswer.push(item);
+        this.$set(this.list, this.listIndex, {
+          ...this.list[this.listIndex],
+          userAnswer: userAnswer,
+        });
+      }
+
       // this.list[this.listIndex] = { ...this.list[this.listIndex], userAnswer: item };
       // console.log(list.value[listIndex.value], item);
     },
@@ -754,20 +818,26 @@ export default {
   components: {
     beforeSubmitMask,
     submitMask,
+    correctAnswerMask,
   },
   onLoad(option) {
-    this.username = decodeURIComponent(option.username);
-    this.headimg = decodeURIComponent(option.headimg);
+    this.nickName =
+      uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo").nickName;
+    this.headImage =
+      uni.getStorageSync("userInfo") &&
+      uni.getStorageSync("userInfo").headImage;
+    this.rowNum = option.subject == 1 ? 10 : 5;
     this.carType = option.carType;
     this.subject = this.subjectMap[Number(option.subject)];
     this.carType = this.carTypeMap[option.type];
+    this.vehicle = option.vehicle;
     api.open
-      .questionInfoSelectTestQuestionInfo ({
+      .questionInfoSelectTestQuestionInfo({
         subject: Number(option.subject),
-        liceBus: option.type == "liceBus" ? "1" : "",
-        liceCar: option.type == "liceCar" ? "1" : "",
-        liceTruck: option.type == "liceTruck" ? "1" : "",
-        liceMoto: option.type == "liceMoto" ? "1" : "",
+        liceBus: option.liceBus,
+        liceCar: option.liceCar,
+        liceTruck: option.liceTruck,
+        liceMoto: option.liceMoto,
       })
       .then((res) => {
         res.rows.forEach((item) => {
@@ -779,7 +849,6 @@ export default {
       });
 
     //开始倒计时
-
     this.countdownTimer = setInterval(() => {
       this.beginTimeStrap = this.beginTimeStrap - 1000;
       this.countdownTime = this.getTimeStr(this.beginTimeStrap);
@@ -874,7 +943,7 @@ export default {
     width: 100%;
     align-content: center;
     align-items: center;
-    border-top:  1rpx solid #b8c0cc;
+    border-top: 1rpx solid #b8c0cc;
     border-left: 1rpx solid #b8c0cc;
     text-align: left;
     font-size: 11rpx;
@@ -958,7 +1027,6 @@ export default {
       border-right: 1rpx solid #b8c0cc;
       font-size: 10rpx;
       white-space: nowrap;
-
     }
     // .coll-header1-row_border{
     //   border-bottom: 1px solid #fff;
@@ -998,7 +1066,14 @@ export default {
       display: flex;
       flex-direction: row;
       flex-wrap: wrap;
-      width: 185rpx;
+      width: 100%;
+
+      .coll-table-topicTr-td {
+        flex: 1;
+        text-align: center;
+        display: flex;
+        justify-content: center;
+      }
     }
     .coll-table-topicTd {
       width: 20rpx;
@@ -1012,7 +1087,7 @@ export default {
 
       div {
         font-size: 8rpx;
-        width: 18rpx;
+    
         height: 20rpx;
         line-height: 20rpx;
         text-align: center;

+ 1 - 1
src/pages/user/index.vue

@@ -75,7 +75,7 @@ export default {
         nickName: userInfo.userInfo.nickName,
       });
       if (updateRes.code == 200) {
-        uni.setStorageSync("userInfo", userInfo.userInfo);
+        
         this.$store.state.user.userInfo.headImage = userInfo.userInfo.avatarUrl;
         this.$store.state.user.userInfo.nickName = userInfo.userInfo.nickName;
       }

+ 1 - 0
src/store/modules/user.js

@@ -94,6 +94,7 @@ const user = {
 		 */
 		async GetInfo(store) {
 			let res = await userApi.getInfo()
+			uni.setStorageSync("userInfo", res.data);
 			store.commit('SET_USERINFO', res.data)
 			return res
 		}