|
@@ -73,8 +73,33 @@ common={
|
|
if(data.info.user.user_id!=this.userInfo.user_id){
|
|
if(data.info.user.user_id!=this.userInfo.user_id){
|
|
$("#py2_avatar").html('<img src="' + data.info.user.avatar+ '" class="layui-circle">');
|
|
$("#py2_avatar").html('<img src="' + data.info.user.avatar+ '" class="layui-circle">');
|
|
$("#py2_username").html(data.info.user.name);
|
|
$("#py2_username").html(data.info.user.name);
|
|
|
|
+ _this.data.playerId=data.info.user.user_id;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ },round_end:function(data){
|
|
|
|
+ var _this=this;
|
|
|
|
+ // if(data.info.anwser==_this.data.option_id){
|
|
|
|
+ // $(".cur_answer").addClass("cur_true");
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ for (var i = 0; i < data.info.players_answer.length; i++) {
|
|
|
|
+ if(data.info.players_answer[i].user_id==_this.userInfo.playerId){
|
|
|
|
+ //对方的答案id
|
|
|
|
+ _this.data.player_answerId=data.info.players_answer[i].question_id;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $("#question .item").each(function(){
|
|
|
|
+ if($(this).attr("option_id")==data.info.anwser){
|
|
|
|
+ $(this).addClass("cur_true");
|
|
|
|
+ }
|
|
|
|
+ if($(this).attr("option_id")==_this.data.player_answerId){
|
|
|
|
+ //对方答案
|
|
|
|
+ $(this).addClass("player_cur");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
},onSocket:function(e){
|
|
},onSocket:function(e){
|
|
var data=JSON.parse(e.data);
|
|
var data=JSON.parse(e.data);
|
|
var _this=this;
|
|
var _this=this;
|
|
@@ -94,8 +119,16 @@ common={
|
|
_this.loadQuestion(data);
|
|
_this.loadQuestion(data);
|
|
break;
|
|
break;
|
|
case 'round_end':
|
|
case 'round_end':
|
|
|
|
+ _this.round_end(data);
|
|
console.log("答题结束");
|
|
console.log("答题结束");
|
|
break;
|
|
break;
|
|
|
|
+ case "answer":
|
|
|
|
+ if(_this.userInfo.user_id==data.user_id){
|
|
|
|
+ _this.increment($("#py1_score"),data.score);
|
|
|
|
+ }else if(_this.data.playerId==data.user_id){
|
|
|
|
+ _this.increment($("#py2_score"),data.score);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
case 'game_end':
|
|
case 'game_end':
|
|
$(".g-doc .g-inner").addClass("end");
|
|
$(".g-doc .g-inner").addClass("end");
|
|
$("#Jvs").hide();
|
|
$("#Jvs").hide();
|
|
@@ -124,9 +157,9 @@ common={
|
|
},loadQuestion(responsedata) {
|
|
},loadQuestion(responsedata) {
|
|
console.log(responsedata);
|
|
console.log(responsedata);
|
|
|
|
|
|
- var _this=this;
|
|
|
|
|
|
+ var _this=this;
|
|
_this.data.isAnswer=false;
|
|
_this.data.isAnswer=false;
|
|
- _this.data.question_id= responsedata.info.question.question_id;
|
|
|
|
|
|
+ _this.data.question_id= responsedata.info.question.question_id;
|
|
$("#Jqtitle").html(responsedata.info.question.title );
|
|
$("#Jqtitle").html(responsedata.info.question.title );
|
|
var question="";
|
|
var question="";
|
|
var answers = responsedata.info.options
|
|
var answers = responsedata.info.options
|
|
@@ -162,6 +195,9 @@ common={
|
|
$("#start_game").on("touchend",function(){
|
|
$("#start_game").on("touchend",function(){
|
|
_this.startGame();
|
|
_this.startGame();
|
|
})
|
|
})
|
|
|
|
+ $("#Jagain").on("touchend",function(){
|
|
|
|
+ window.location.href=window.location.href;
|
|
|
|
+ })
|
|
|
|
|
|
|
|
|
|
},increment:function(bdclass,num){
|
|
},increment:function(bdclass,num){
|