|
@@ -79,7 +79,9 @@ layui.use(['form','jquery'], function(){
|
|
|
var room_id = '';
|
|
|
var cur_question = 1;
|
|
|
var is_end = 0;
|
|
|
+ var question_id=0;
|
|
|
var ts;
|
|
|
+ var sum=5;
|
|
|
$.ajaxSetup({
|
|
|
headers: {
|
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
@@ -100,6 +102,18 @@ layui.use(['form','jquery'], function(){
|
|
|
$("#user_id").val(responsedata.info.user_id);
|
|
|
},'json');
|
|
|
|
|
|
+ function daoshu(argument) {
|
|
|
+ clearInterval(ts)
|
|
|
+ ts=setInterval(function(){
|
|
|
+
|
|
|
+ sum= sum-1;
|
|
|
+ $("#Jvs").html(sum);
|
|
|
+ if(sum<=0){
|
|
|
+ getQuestion(room_id, cur_question);
|
|
|
+ sum=5;
|
|
|
+ }
|
|
|
+ },1000)
|
|
|
+ }
|
|
|
//绑定通信
|
|
|
// ws = new WebSocket("ws://www.dt.com:6390");
|
|
|
ws = new WebSocket("ws://183.234.61.252:8282");
|
|
@@ -144,17 +158,9 @@ layui.use(['form','jquery'], function(){
|
|
|
|
|
|
if(data.info.room_id){
|
|
|
room_id = data.info.room_id;
|
|
|
- var sum=5;
|
|
|
+
|
|
|
getQuestion(data.info.room_id, cur_question);
|
|
|
- ts=setInterval(function(){
|
|
|
-
|
|
|
-
|
|
|
- $("#Jvs").html(sum--);
|
|
|
- if(sum==0){
|
|
|
- getQuestion(data.info.room_id, cur_question);
|
|
|
- sum=10;
|
|
|
- }
|
|
|
- },1000)
|
|
|
+ daoshu();
|
|
|
|
|
|
}
|
|
|
break;
|
|
@@ -273,6 +279,7 @@ layui.use(['form','jquery'], function(){
|
|
|
var url = '/Home/Game/Question';
|
|
|
$.get(url, {room_id:room_id, cur_question:index}, function(responsedata){
|
|
|
if(responsedata.code == 0){
|
|
|
+ question_id= responsedata.info.question.question_id;
|
|
|
$("#Jqtitle").html(responsedata.info.question.title );
|
|
|
var question="";
|
|
|
var answers = responsedata.info.options
|
|
@@ -282,7 +289,7 @@ layui.use(['form','jquery'], function(){
|
|
|
$("#question").html(question);
|
|
|
$("#Jpage").html(responsedata.info.questions_count)
|
|
|
// is_end = responsedata.info.question.is_end;
|
|
|
-
|
|
|
+ clearInterval(ts)
|
|
|
}else{
|
|
|
layer.msg(responsedata.msg, {
|
|
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
|
@@ -295,10 +302,11 @@ layui.use(['form','jquery'], function(){
|
|
|
if($(".cur_answer").length > 0){
|
|
|
return false;
|
|
|
}
|
|
|
+ clearInterval(ts)
|
|
|
var url = '/Home/Game/Answer';
|
|
|
var answer = $(this).data("id");
|
|
|
$(this).addClass("cur_answer");
|
|
|
- $.post(url, {answer:answer,cur_question:cur_question,room_id:room_id,client_id:client_id,is_end:is_end}, function(responsedata){
|
|
|
+ $.post(url, {answer: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);
|
|
|
});
|
|
|
cur_question = cur_question + 1;
|