xtz 4 年之前
父節點
當前提交
91534813c3
共有 2 個文件被更改,包括 20 次插入8 次删除
  1. 17 1
      answer/src/views/contest.vue
  2. 3 7
      answer/src/views/info.vue

+ 17 - 1
answer/src/views/contest.vue

@@ -79,11 +79,27 @@ export default {
     }
   },
   methods: {
+    // 数组乱序
+    shuffle (arr) {
+      let length = arr.length
+      let r = length
+      let rand = 0
+
+      while (r) {
+        rand = Math.floor(Math.random() * r--);
+        [arr[r], arr[rand]] = [arr[rand], arr[r]]
+      }
+      return arr
+    },
     getAttendContest () {
       this.$api.post('/mCompetition/attendContest', {
         userId: 6
       }).then(r => {
-        this.questions = r.object.questions
+        this.questions = this.shuffle(r.object.questions)
+          .map(item => {
+            item.options = this.shuffle(item.options)
+            return item
+          })
         this.paperId = r.object.paperId
       })
     },

+ 3 - 7
answer/src/views/info.vue

@@ -27,7 +27,7 @@
             </div>
             <div class="form-item">
                 <div class="item-label">学校</div>
-                <el-select v-model="form.school" filterable :filter-method="filterMethod" placeholder="请选择">
+                <el-select v-model="form.school" filterable placeholder="请选择">
                     <el-option v-for="item in schoolList" :key="item.value" :label="item.label" :value="item.value">
                     </el-option>
                 </el-select>
@@ -67,7 +67,6 @@ export default {
         value: 2
       }],
       schoolList: [],
-      schoolData: [],
       areaList: []
     }
   },
@@ -86,16 +85,13 @@ export default {
           id: val
         }
       }).then(r => {
-        this.schoolData = r.list.map(item => ({
+        this.schoolList = r.list.map(item => ({
           label: item.schoolName,
           value: item.id
         }))
-        this.schoolList = this.schoolData
+        this.$set(this.form, 'school', null)
       })
     },
-    filterMethod (val) {
-      this.schoolList = this.schoolData.filter(item => item.label.includes(val))
-    },
     submit (e) {
       // let {actualName,age,area,grade,other,school} = this.data.form
       // let id = wx.getStorageSync('id')