Browse Source

服务端刷题

mzx16822 6 years ago
parent
commit
cfd5c90141
1 changed files with 20 additions and 15 deletions
  1. 20 15
      resources/views/home/user.blade.php

+ 20 - 15
resources/views/home/user.blade.php

@@ -225,13 +225,13 @@ var textCircle   = document.querySelector(".text-circle");
                 $("#duishou").val(data.info.players[0]['user_id']);
               }
             
-              if(data.info.room_id){
-                room_id = data.info.room_id;
+              // if(data.info.room_id){
+              //   room_id = data.info.room_id;
                 
-                getQuestion(data.info.room_id, cur_question);
+              //   getQuestion(data.info.room_id, cur_question);
                 
                 
-              }
+              // }
               $("#py1_score").html(0);
               $("#py2_score").html(0);
               break;
@@ -290,19 +290,21 @@ var textCircle   = document.querySelector(".text-circle");
                  
                   return false;
                 }
-                if(data.cur_quc == 2&&data.is_end!=1){
-                  if(a)clearTimeout(a)
-                  var a =setTimeout(function(argument) {
-                    getQuestion(room_id, cur_question);
-                  },1000)
-                  clearInterval(ts)
+                // if(data.cur_quc == 2&&data.is_end!=1){
+                //   if(a)clearTimeout(a)
+                //   var a =setTimeout(function(argument) {
+                //     getQuestion(room_id, cur_question);
+                //   },1000)
+                //   clearInterval(ts)
                   
-                }
+                // }
                 
             
               //设置player值
               break;
           // 当mvc框架调用GatewayClient发消息时直接alert出来
+          case "question":
+            loadQuestion(data);
           default :
               alert(e.data);
       }
@@ -351,10 +353,8 @@ var textCircle   = document.querySelector(".text-circle");
   });
 
   //获取题目
-  var getQuestion = function getQuestion(room_id, index) {
-    var url = '/Home/Game/Question';
-    $.get(url, {room_id:room_id, cur_question:index}, function(responsedata){
-      if(responsedata.code == 0){
+  function loadQuestion(responsedata) {
+    if(responsedata.code == 0){
        question_id= responsedata.info.question.question_id;
         $("#Jqtitle").html(responsedata.info.question.title );
         var question="";
@@ -371,6 +371,11 @@ var textCircle   = document.querySelector(".text-circle");
           time: 1000 //2秒关闭(如果不配置,默认是3秒)
         }); 
       }
+  }
+  var getQuestion = function getQuestion(room_id, index) {
+    var url = '/Home/Game/Question';
+    $.get(url, {room_id:room_id, cur_question:index}, function(responsedata){
+       loadQuestion(responsedata);
     },'json').fail(function () {
           layer.msg("服务器繁忙"); 
               clearInterval(ts)