Kaynağa Gözat

小程序部分题目未答,提交出现null,改为每个题都需要解答

hanchong 1 yıl önce
ebeveyn
işleme
f48d395fb0
2 değiştirilmiş dosya ile 151 ekleme ve 30 silme
  1. 135 25
      pages/testSAS/testSAS.js
  2. 16 5
      pages/testSAS/testSAS.wxml

+ 135 - 25
pages/testSAS/testSAS.js

@@ -23,6 +23,12 @@ Page({
 	changeValue:'',//
 	comScore: 0,
 	comScoreStatus: '',
+	input1Value: '',
+	input2Value: '',
+	input3Value: '',
+	input4Value: '',
+	input5Value: '',
+	input6Value: '',
   },
   // drawCircle: function() {  
   //     // 创建 canvas 上下文  
@@ -132,6 +138,34 @@ bindInput2: function(e) {
 	this.setData({  
 	  input2Value: e.detail.value  
 	})
+},
+bindInput3: function(e) {  
+    // 你可以通过 e.detail.value 获取到输入框的值  
+    // 使用 this.setData() 方法更新数据  
+    this.setData({  
+      input3Value: e.detail.value  
+    })
+}, 
+bindInput4: function(e) {  
+	// 你可以通过 e.detail.value 获取到输入框的值  
+	// 使用 this.setData() 方法更新数据  
+	this.setData({  
+	  input4Value: e.detail.value  
+	})
+},
+bindInput5: function(e) {  
+    // 你可以通过 e.detail.value 获取到输入框的值  
+    // 使用 this.setData() 方法更新数据  
+    this.setData({  
+      input5Value: e.detail.value  
+    })
+}, 
+bindInput6: function(e) {  
+	// 你可以通过 e.detail.value 获取到输入框的值  
+	// 使用 this.setData() 方法更新数据  
+	this.setData({  
+	  input6Value: e.detail.value  
+	})
 },
   nextq: function (e) {
 	if (!this.data.checkboxes[0].checked) {
@@ -141,18 +175,74 @@ bindInput2: function(e) {
 		 });  
 		 return;  
 	} 
+	let idInput = e.currentTarget.dataset.id;
+	console.log('idInput====='+idInput)
 	console.log('input1Value=='+this.data.input1Value);
 	console.log('input2Value=='+this.data.input2Value);
-	// let input1 = e.detail.value.input1;
-	// let input2 = e.detail.value.input2;
+	console.log('input3Value=='+this.data.input3Value);
+	console.log('input4Value=='+this.data.input4Value);
+	console.log('input5Value=='+this.data.input5Value);
+	console.log('input6Value=='+this.data.input6Value);
 	let input1 = this.data.input1Value;
 	let input2 = this.data.input2Value;
-	if(!input1 || !input2){
-		wx.showToast({
-		title: '输入框不能为空',  
-		icon: 'none'  
-		});  
-		return;
+	let input3 = this.data.input3Value;
+	let input4 = this.data.input4Value;
+	let input5 = this.data.input5Value;
+	let input6 = this.data.input6Value;
+	if(idInput == 0){
+		if(!input1 || !input2){
+			wx.showToast({
+			title: '输入框不能为空',  
+			icon: 'none'  
+			});  
+			return;
+		}
+		if(input1){
+			if(!(input1>=0 && input1<=24) || !(input2>=0 && input2<=60)){
+				wx.showToast({
+				title: '输入框时间填写错误',  
+				icon: 'none'  
+				});  
+				return;
+			}
+		}
+	}
+	
+	if(idInput == 2){
+		if(!input3 || !input4){
+			wx.showToast({
+			title: '输入框不能为空',  
+			icon: 'none'  
+			});  
+			return;
+		}
+		if(input1){
+			if(!(input3>=0 && input3<=24) || !(input4>=0 && input4<=60)){
+				wx.showToast({
+				title: '输入框时间填写错误',  
+				icon: 'none'  
+				});  
+				return;
+			}
+		}
+	}
+	if(idInput == 3){
+		if(!input5 || !input6){
+			wx.showToast({
+			title: '输入框不能为空',  
+			icon: 'none'  
+			});  
+			return;
+		}
+		if(input1){
+			if(!(input5>=0 && input5<=24) || !(input6>=0 && input6<=60)){
+				wx.showToast({
+				title: '输入框时间填写错误',  
+				icon: 'none'  
+				});  
+				return;
+			}
+		}
 	}
 	
     if (this.data.id < 23) {
@@ -202,28 +292,48 @@ bindInput2: function(e) {
 	// let input2 = e.detail.value.input2;
 	let input1 = this.data.input1Value;
 	let input2 = this.data.input2Value;
-	if(!input1 || !input2){
-		wx.showToast({
-		title: '输入框不能为空',  
-		icon: 'none'  
-		});  
-		return;
-	}
-	if(!(input1>=0 && input1<=24) || !(input2>=0 && input2<=60)){
-		wx.showToast({
-		title: '输入框时间填写错误',  
-		icon: 'none'  
-		});  
-		return;
-	}
+	let input3 = this.data.input3Value;
+	let input4 = this.data.input4Value;
+	let input5 = this.data.input5Value;
+	let input6 = this.data.input6Value;
+	// if(!input1 || !input2){
+	// 	wx.showToast({
+	// 	title: '输入框不能为空',  
+	// 	icon: 'none'  
+	// 	});  
+	// 	return;
+	// }
+	
     var a = "";
 	let _id = e.currentTarget.dataset.id;
+	var id = this.data.id-1;
+	console.log('id==+=='+id);
 	if(e.detail.value.answer){
 		a = e.detail.value.answer;
 	}else{
-		a = input1+":"+input2
+		if(id == 0){
+			if(input1 && input2){
+				a = input1+":"+input2
+			}else{
+				// a = "";
+			}
+		}
+		if(id == 2){
+			if(input3 && input4){
+				a = input3+":"+input4
+			}else{
+				// a = "";
+			}
+		}
+		if(id == 3){
+			if(input5 && input6){
+				a = input5+":"+input6
+			}else{
+				// a = "";
+			}
+		}
 	}
-    var id = this.data.id-1;
+    
 	var obj = {};
 	obj.type = e.detail.value.answer?'answer':'input'
 	obj.value = a
@@ -290,7 +400,7 @@ bindInput2: function(e) {
           success (res) {
             _this.answer2db(_this.data.answerJson);
             wx.navigateBack({
-              delta: 1
+              delta: i
             })
           }
         })

+ 16 - 5
pages/testSAS/testSAS.wxml

@@ -72,11 +72,22 @@
 				<view class='question'>{{item.question}}</view>
 			    <view class="sleep-time-container">  
 			      <text>{{item.option.a}}</text>  
-			      <input name='input1' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{inputValue}}"  data-id="{{id}}" bindinput="bindInput1"/>  
-			      <text wx:if="{{item.option.b != '' && item.option.b != null}}">{{item.option.b}}</text>  
-				  <input name='input2' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{inputValue}}"  data-id="{{id}}" bindinput="bindInput2"/>
-				  <text wx:if="{{item.option.c != '' && item.option.c != null}}">{{item.option.c}}</text>  
-			    </view>
+			      <input wx:if="{{id == 0}}" name='input1' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{input1Value}}"  data-id="{{id}}" bindinput="bindInput1"/>  
+			      <text wx:if="{{id == 0 && item.option.b != '' && item.option.b != null}}">{{item.option.b}}</text>  
+				  <input wx:if="{{id == 0}}" name='input2' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{input2Value}}"  data-id="{{id}}" bindinput="bindInput2"/>
+				  <text wx:if="{{id == 0 && item.option.c != '' && item.option.c != null}}">{{item.option.c}}</text>  
+				  
+				  <input wx:if="{{id == 2}}" name='input3' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{input3Value}}"  data-id="{{id}}" bindinput="bindInput3"/>
+				  <text wx:if="{{id == 2 && item.option.b != '' && item.option.b != null}}">{{item.option.b}}</text>  
+				  <input wx:if="{{id == 2}}" name='input4' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{input4Value}}"  data-id="{{id}}" bindinput="bindInput4"/>
+				  <text wx:if="{{id == 2 && item.option.c != '' && item.option.c != null}}">{{item.option.c}}</text>  
+				  
+				  <input wx:if="{{id == 3}}" name='input5' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{input5Value}}"  data-id="{{id}}" bindinput="bindInput5"/>
+				  <text wx:if="{{id == 3 && item.option.b != '' && item.option.b != null}}">{{item.option.b}}</text>  
+				  <input wx:if="{{id == 3}}" name='input6' type="number" style="border: none;border-bottom: 1px solid #000000;width:30rpx;" class="input-underline" placeholder=""  value="{{input6Value}}"  data-id="{{id}}" bindinput="bindInput6"/>
+				  <text wx:if="{{id == 3 && item.option.c != '' && item.option.c != null}}">{{item.option.c}}</text>  
+				  
+				</view>
 				<!-- <view class='question_2' wx:if="{{id==3 && BMI != null}}">体重:{{item.BMI}}</view> -->
 			</view>
             <view class='button-group'>