Bläddra i källkod

Merge branch 'master' of http://120.78.169.79:3000/zhengxiaoyu/datiGame

郑晓宇 6 år sedan
förälder
incheckning
8b52aa5c10
3 ändrade filer med 42 tillägg och 26 borttagningar
  1. 2 1
      public/h5/datigame/css/main.css
  2. 2 2
      public/h5/datigame/index.html
  3. 38 23
      public/h5/datigame/js/common.js

+ 2 - 1
public/h5/datigame/css/main.css

@@ -106,7 +106,8 @@ body{
 .cov1{left: 50%;top: 3.3rem;width: 2.4rem;margin-left: -1.2rem;/* border: solid #71a3fd 2px; */border-radius: 50%;}
 .cov2{left: 50%;top: 10.5rem;margin-left: -1.5rem;width: 3rem;font-size: .3rem;text-align: center;}
 .cov1 .userface{width: 2.2rem;height: 2.2rem;margin: 0 auto;}
-.cov3{left: 50%;top: 7rem;width: 2rem;height: 1rem;line-height: 1rem;margin-left: -1rem;text-align: center;font-size: .5rem;color: #FFF;font-weight: bold;border-radius: .2rem;}
+.gstart .cov3{}
+.cov3{left: 50%;top: 9rem;width: 2rem;height: 1rem;line-height: 1rem;margin-left: -1rem;text-align: center;font-size: .5rem;color: #FFF;font-weight: bold;border-radius: .2rem;}
 .cov4{right: 50%;top: 8.5rem;width: 2rem;margin-right: -1rem;}
  .userface{border-radius: 50%;overflow: hidden;background-color: #000;display: block;}
 .cov4 .userface{width: 2.0rem;height: 2.0rem;float: right;opacity: 0;}

+ 2 - 2
public/h5/datigame/index.html

@@ -55,8 +55,8 @@
         </div>
       </div>
 
-      <div class="cov cov1 amt"><span class="userface" id="avatar"></span>
-        <b id="username" class="name"></b>
+      <div class="cov cov1 amt"><span class="userface" id="py1_avatar"></span>
+        <b id="py1_username" class="name"></b>
         <span class="num amt" id="py1_score">0</span>
       </div>
       <div class="cov cov2 amt">

+ 38 - 23
public/h5/datigame/js/common.js

@@ -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();
 
  		})