|
@@ -66,14 +66,16 @@ common={
|
|
|
// $("#avatar").html('<img src="' + responsedata.info.user.avatar + '" class="layui-circle">');
|
|
|
// }
|
|
|
|
|
|
- if(data.info.user){
|
|
|
- $("#py1_avatar").html('<img src="' + data.info.user.avatar+ '" class="layui-circle">');
|
|
|
- $("#py1_username").html(data.info.user.name + '(我)');
|
|
|
- }else if(data.info.players){
|
|
|
- $("#py2_avatar").html('<img src="' + data.info.players.avatar + '" class="layui-circle">');
|
|
|
- $("#py2_username").html(data.info.players.name);
|
|
|
- $(".g-doc .g-inner").removeClass("gstart");
|
|
|
- $(".g-doc .g-inner").addClass("doing");
|
|
|
+ // if(data.info.user.user_id){
|
|
|
+ // $("#py1_avatar").html('<img src="' + data.info.user.avatar+ '" class="layui-circle">');
|
|
|
+ // $("#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">');
|
|
|
+ $("#py2_username").html(data.info.user.name);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
},onSocket:function(e){
|
|
@@ -109,6 +111,8 @@ common={
|
|
|
},startGame:function(){
|
|
|
if(this.data.isReady=="1")
|
|
|
this.Join(function(res){
|
|
|
+ $(".welcome").hide();
|
|
|
+ $(".gstart").show();
|
|
|
common.tips(res.msg);
|
|
|
});
|
|
|
else this.tips("登录失败");
|
|
@@ -121,6 +125,9 @@ common={
|
|
|
|
|
|
},loadQuestion(responsedata) {
|
|
|
console.log(responsedata);
|
|
|
+
|
|
|
+ var _this=this;
|
|
|
+ _this.data.isAnswer=false;
|
|
|
_this.data.question_id= responsedata.info.question.question_id;
|
|
|
$("#Jqtitle").html(responsedata.info.question.title );
|
|
|
var question="";
|
|
@@ -129,7 +136,9 @@ common={
|
|
|
question += '<li class="btn-2 item item'+i+' answer layui-btn layui-btn-primary" data-option_id="'+answers[i].option_id+'">'+answers[i].title+'</li>';
|
|
|
}
|
|
|
$("#question").html(question);
|
|
|
- $("#Jpage").html(responsedata.info.questions_count+"/5")
|
|
|
+ $("#Jpage").html(responsedata.info.questions_count+"/5");
|
|
|
+
|
|
|
+ $(".g-doc .g-inner").addClass("doing");
|
|
|
// is_end = responsedata.info.question.is_end;
|
|
|
this.daoshu();
|
|
|
|
|
@@ -147,13 +156,16 @@ common={
|
|
|
$("#question .item").on("touchend",function(){
|
|
|
var l = $("#question .item.cur_answer").length;
|
|
|
if(l>0)return;
|
|
|
- _this.data.option_id=this.attr("data-option_id");
|
|
|
this.addClass("cur_answer");
|
|
|
- _this.Answer();
|
|
|
+ _this.data.option_id=this.attr("data-option_id");
|
|
|
+ _this.Answer(function(){
|
|
|
+ _this.data.isAnswer=true;
|
|
|
+ });
|
|
|
})
|
|
|
|
|
|
},daoshu:function(argument) {
|
|
|
- clearInterval(ts);
|
|
|
+ var _this=this;
|
|
|
+ clearInterval(this.data.ts);
|
|
|
this.data.sum = 9;
|
|
|
this.data.angle = 0;
|
|
|
var leftContent = document.querySelector(".left-content");
|
|
@@ -162,22 +174,23 @@ common={
|
|
|
leftContent.setAttribute('style', 'transform: rotate(0deg)');
|
|
|
rightContent.setAttribute('style', 'transform: rotate(0deg)');
|
|
|
this.data.ts = setInterval(function() {
|
|
|
- if (sum >= 0) textCircle.innerHTML = sum;
|
|
|
- sum = sum - 1;
|
|
|
+ if (_this.data.sum >= 0) textCircle.innerHTML = _this.data.sum;
|
|
|
+ _this.data.sum = _this.data.sum - 1;
|
|
|
$("#Jvs .con").show();
|
|
|
$("#Jvs .tit").html("抢答中");
|
|
|
- angle += 36;
|
|
|
- if (angle <= 360) {
|
|
|
- if (angle > 180) {
|
|
|
- rightContent.setAttribute('style', 'transform: rotate(' + (angle - 180) + 'deg)')
|
|
|
+ _this.data.angle += 36;
|
|
|
+ if (_this.data.angle <= 360) {
|
|
|
+ if (_this.data.angle > 180) {
|
|
|
+ rightContent.setAttribute('style', 'transform: rotate(' + (_this.data.angle - 180) + 'deg)')
|
|
|
} else {
|
|
|
- leftContent.setAttribute('style', 'transform: rotate(' + angle + 'deg)')
|
|
|
+ leftContent.setAttribute('style', 'transform: rotate(' + _this.data.angle + 'deg)')
|
|
|
}
|
|
|
}
|
|
|
- if (sum < -1) {
|
|
|
- answer();
|
|
|
- sum = 9;
|
|
|
- angle = 0;
|
|
|
+ if (_this.data.sum < -1) {
|
|
|
+ if(!_this.data.isAnswer)
|
|
|
+ _this.Answer();
|
|
|
+ _this.data.sum = 9;
|
|
|
+ _this.data.angle = 0;
|
|
|
leftContent.setAttribute('style', 'transform: rotate(0deg)');
|
|
|
rightContent.setAttribute('style', 'transform: rotate(0deg)')
|
|
|
}
|
|
@@ -212,6 +225,8 @@ common={
|
|
|
}
|
|
|
this.getUserInfo(function(res){
|
|
|
_this.userInfo=res.info;
|
|
|
+ $("#py1_username").html(res.info.name);
|
|
|
+ $("#py1_avatar").html('<img src="' + res.info.avatar + '" class="layui-circle">');
|
|
|
_this.initSocket();
|
|
|
|
|
|
})
|