| 
					
				 | 
			
			
				@@ -6,6 +6,7 @@ let app = getApp() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   data: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     list: [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    redo: false, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     preList:["A","B","C", "D"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     info:{}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     timer: null, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -19,21 +20,25 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   onLoad: function(options) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let groupId = +options.id||3 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let redo = !!options.redo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.setData({redo}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let method =  redo?'Exam.examreStart':'Exam.examStart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let _this = this 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    app.formPost('Exam.examStart', {groupId}).then(res => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      let list = res.data.list.map(item=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        delete( item["select"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return item 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }).sort( (i,j) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return i.type > j.type?1:-1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    app.formPost(method, {groupId}).then(res => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       if (res.code ==200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let {startTime, info, list} = res.data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let duration = list.length * 60; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        list = list.map(item=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          delete( item["select"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          return item 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }).sort( (i,j) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          return i.type > j.type?1:-1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         _this.setData({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           list: list, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          info: res.data.info, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          startTime: res.data.startTime, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          remainTime: res.data.info.duration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          info: info, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          startTime: startTime, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          remainTime: duration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         _this.timeReduce() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -61,9 +66,15 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     clearInterval(this.data.timer) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   returnRecord() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    wx.reLaunch({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      url: '/pages/record/index', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if( this.data.redo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      wx.reLaunch({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        url: '/pages/exam/error/index', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      wx.reLaunch({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        url: '/pages/record/index', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   timeOut() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     clearInterval(this.data.timer) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,16 +105,17 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let info = this.data.info; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let param ={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.groupId = info.groupId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    param.paperId = info.paperId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.answers = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.result  = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.correct = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    param.errIds = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.counter = this.data.list.length 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.groupName = info.title; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.useTime =  this.data.doTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.duration = info.duration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.startTime = this.data.startTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let errIds = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for( let i=0; i< this.data.list.length; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let item = this.data.list[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         param.answers.push( item.answerId ); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -117,7 +129,7 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if( param.result[i] == item.result){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           param.correct += 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          param.errIds.push( item.answerId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          errIds.push( item.answerId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if( !item.select ) isFinish = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -126,26 +138,23 @@ Page({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       wx.hideLoading() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       return  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (this.data.timer) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      clearInterval(this.data.timer) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.result = param.result.join(",") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     param.answers = param.answers.join(",") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    app.formPost('Exam.ExamSubmit', param) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      .then(res => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (res.code === 200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          _this.setData({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            modalShow: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            result:param, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          app.message(res.data, 'error') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    param.errors = errIds.join(",") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    param.isRedo = this.data.redo?1:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    app.formPost('Exam.ExamSubmit', param).then(res => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (res.code === 200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        _this.setData({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          modalShow: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          result:param, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (this.data.timer) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          clearInterval(this.data.timer) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wx.hideLoading() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }).catch(e => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wx.hideLoading() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        app.message(e, 'error') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        app.message(res.msg, 'error') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      wx.hideLoading() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 |