Browse Source

Merge branch 'master' of http://120.78.169.79:3000/zhengxiaoyu/datiGame

郑晓宇 6 years ago
parent
commit
e5dfc26b47
1 changed files with 17 additions and 13 deletions
  1. 17 13
      resources/views/home/user.blade.php

+ 17 - 13
resources/views/home/user.blade.php

@@ -111,7 +111,8 @@ layui.use(['form','jquery'], function(){
                   $("#Jvs").html(sum);
                   if(sum<=0){
                     cur_question++;
-                    getQuestion(room_id, cur_question);
+                    //getQuestion(room_id, cur_question);
+                    answer(); 
                     sum=10;
                   }
                 },1000)
@@ -305,20 +306,23 @@ layui.use(['form','jquery'], function(){
           layer.msg("服务器繁忙"); 
               clearInterval(ts)
            })}
+    var answer=function(answerId) {
+      if($(".cur_answer").length > 0){
+        return false;
+      }
+      answerId= answerId?answerId:$("#question .answer").eq(0).attr("data-id");//默认第一题为答案
+      var url = '/Home/Game/Answer';
+      
+      $.post(url, {option_id:answerId,cur_question:cur_question,room_id:room_id,client_id:client_id,is_end:is_end,question_id:question_id}, function(responsedata){
+        console.log(responsedata);
+        //clearInterval(ts)
+      });
+      cur_question = cur_question + 1;
+    }
 
   $("#question").on('click', '.answer',function(){
-    if($(".cur_answer").length > 0){
-      return false;
-    }
-    
-    var url = '/Home/Game/Answer';
-    var answer = $(this).data("id");
-    $(this).addClass("cur_answer");
-    $.post(url, {option_id:answer,cur_question:cur_question,room_id:room_id,client_id:client_id,is_end:is_end,question_id:question_id}, function(responsedata){
-      console.log(responsedata);
-      //clearInterval(ts)
-    });
-    cur_question = cur_question + 1;
+    var answerId = $(this).data("id");
+    answer(answerId);
   });
 
 });