|
@@ -71,19 +71,22 @@ common={
|
|
|
// $("#py1_username").html(data.info.user.name + '(我)');
|
|
|
// }
|
|
|
this.tips(data.info.user.name+"加入了房间")
|
|
|
- if(data.info.user.user_id!=this.userInfo.user_id){
|
|
|
- $("#py2_avatar").html('<img src="' + data.info.user.avatar+ '" class="layui-circle">');
|
|
|
+ for (var i = 0; i < data.info.players.length; i++) {
|
|
|
+ if(data.info.players[i].user_id!=_this.userInfo.user_id){
|
|
|
+ $("#py2_avatar").html('<img src="' + data.info.user.avatar+ '" class="layui-circle">');
|
|
|
$("#py2_username").html(data.info.user.name);
|
|
|
_this.userInfo.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++) {
|
|
|
+
|
|
|
+ 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].option_id;
|
|
@@ -108,13 +111,15 @@ common={
|
|
|
}
|
|
|
|
|
|
})
|
|
|
+
|
|
|
+
|
|
|
clearInterval(this.data.ts);
|
|
|
|
|
|
},game_end:function(){
|
|
|
var _this=this;
|
|
|
-
|
|
|
- var py1_score=$("#py1_score").text();
|
|
|
- var py2_score=$("#py2_score").text();
|
|
|
+ setTimeout(function(){
|
|
|
+ var py1_score= parseInt($("#py1_score").text()) ;
|
|
|
+ var py2_score=parseInt($("#py2_score").text());
|
|
|
if(py1_score > py2_score){
|
|
|
|
|
|
_this.tips('恭喜你获得胜利');
|
|
@@ -136,6 +141,7 @@ common={
|
|
|
}
|
|
|
$(".g-doc .g-inner").addClass("end");
|
|
|
$("#Jvs").hide();
|
|
|
+ },3000)
|
|
|
},onSocket:function(e){
|
|
|
var data=JSON.parse(e.data);
|
|
|
var _this=this;
|
|
@@ -160,9 +166,9 @@ common={
|
|
|
break;
|
|
|
case "answer":
|
|
|
if(_this.userInfo.user_id==data.user_id){
|
|
|
- _this.increment($("#py1_score"),data.score);
|
|
|
+ _this.increment($("#py1_score"),data.total_score);
|
|
|
}else if(_this.userInfo.playerId==data.user_id){
|
|
|
- _this.increment($("#py2_score"),data.score);
|
|
|
+ _this.increment($("#py2_score"),data.total_score);
|
|
|
}
|
|
|
break;
|
|
|
case 'game_end':
|