xtz %!s(int64=4) %!d(string=hai) anos
pai
achega
91534813c3
Modificáronse 2 ficheiros con 20 adicións e 8 borrados
  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')