Commit ed040e8b authored by Mac's avatar Mac
parents 184ba6eb 71f1a744
......@@ -21,8 +21,8 @@
<div class="mask"></div>
<div class="gold"></div>
<div id="touchBox"></div>
<input type="button" value="开始" id="Start" style="z-index:9999;position: fixed;top:0;">
<input type="button" value="重置" id="reset" style="z-index:9999;position: fixed;top:0;left:40px;">
<!-- <input type="button" value="开始" id="Start" style="z-index:9999;position: fixed;top:0;">
<input type="button" value="重置" id="reset" style="z-index:9999;position: fixed;top:0;left:40px;"> -->
<div class="time">
<div class="time-txt">倒计时</div>
......@@ -51,24 +51,87 @@
<div class="my_rank">
<p class="my_rankTop" style="padding:1.5rem 0 0.2rem 0">
<span class="my-rank-title">您当前排名为</span>&nbsp;&nbsp;
<span class="rank_myTop" id="myTop">1</span>&nbsp;&nbsp;
<span class="rank_myTop" id="myTop"></span>&nbsp;&nbsp;
</p>
</div>
<div class="rank" id="rankBox" style="height: 27rem;">
<div class="rank-row">
<span class="rank-num num1"></span>
<img src="img/money/back_ico.png"/>
<span class="rank-name">张三</span>
<span class="rank-score">10400</span>
</div>
</div>
<div class="rank" id="rankBox" style="height: 29rem;"></div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="../../js/jquery-1.10.2.js"></script>
<script src="../../js/moveJs/jquery.signalR.min.js"></script>
<script>
let conn;
let proxy;
let status=0;
let clock=null;
function getMyRank(){
proxy.invoke('GetUserRank','Money').done(r=>{
if(r!=-1){
$('#myTop').html(r);
}else{
$('#myTop').html('未上榜');
}
})
}
function GetStatus(){
proxy.invoke("GetMenuStatus", "Money").done(m => {
if (m.status == -1) {
getMyRank();
proxy.invoke('GetGameResult','Money').done(d=>{
var html=''
if(d && d.length>0){
for (var i=0;i<d.length;i++) {
html+='<div class="rank-row"><span class="rank-num num'+(i+1)+'">'+(i>2?(i+1)+"":"")+'</span><img src="'+d[i].p+'"/>'
html+='<span class="rank-name">'+d[i].n+'</span><span class="rank-score">'+d[i].s+'</span></div>'
}
}
$("#rankBox").html(html);
$('.play_tips').css('display','none');
$('.tipsDiv').text('游戏已经结束咯');
//$('.rank_mask').css('display','block');
});
}else if(m.status==2){
$('.play_tips').css('display','none');
$('.tipsDiv').text('你来晚了,游戏已经开始了');
proxy.on("notifyGamerResult",function(d){
var html=''
if(d && d.length>0){
for (var i=0;i<d.length;i++) {
html+='<div class="rank-row"><span class="rank-num num'+(i+1)+'">'+(i>2?i+"":"")+'</span><img src="'+d[i].p+'"/>'
html+='<span class="rank-name">'+d[i].n+'</span><span class="rank-score">'+d[i].s+'</span></div>'
}
}
$("#rankBox").html(html);
getMyRank();
});
}
});
}
function initConnection(){
conn = $.hubConnection("http://localhost:7838/signalr", {
qs: `i=1951_Money&n=张建国&p=${encodeURIComponent(
"http://imgfile.oytour.com/Upload/User/636738107265395640.jpg"
)}`
});
proxy = conn.createHubProxy("annualLeaveHub");
conn.start().done(data => {
console.log('connection 链接成功');
GetStatus();
winning();
}).fail(data => {
console.log('链接失败:'+data)
});
}
function winning(){
proxy.on("notifyWinning",function(d){
alert("恭喜你中奖了:"+d);
})
}
this.initConnection()
$(function () {
var music=document.getElementById('music');
var money_en = $("body");
......@@ -77,7 +140,28 @@
var off =true;
var Count=3;
var Count2=30;
proxy.on("notifyGamerResult",function(d){
console.log(d)
var html=''
if(d && d.length>0){
for (var i=0;i<d.length;i++) {
html+='<div class="rank-row"><span class="rank-num num'+(i+1)+'">'+(i>2?i+"":"")+'</span><img src="'+d[i].p+'"/>'
html+='<span class="rank-name">'+d[i].n+'</span><span class="rank-score">'+d[i].s+'</span></div>'
}
}
$("#rankBox").html(html);
getMyRank();
});
// proxy.on("notifyGamerResult",function(d){
// var html=''
// if(d && d.length>0){
// for (var i=0;i<d.length;i++) {
// html+='<div class="rank-row"><span class="rank-num num'+(i+1)+'">'+(i>2?i+"":"")+'</span><img src="'+d[i].p+'"/>'
// html+='<span class="rank-name">'+d[i].n+'</span><span class="rank-score">'+d[i].s+'</span></div>'
// }
// }
// $("#rankBox").html(html);
// });
//点击关闭统计弹窗
$('.close').click(function(){
$('.rank_mask').css('display','none');
......@@ -86,15 +170,29 @@
$('#rankBtn').click(function(){
$('.rank_mask').css('display','block');
});
//模拟监听到再来一次重置事件
$("#reset").click(function(){
location.reload();
//StartGame();
});
//模拟监听到开始事件
$("#Start").click(function(){
StartGame();
});
proxy.on("getChangeMenu", function(data) {
if (data.code == "Money") {
if(data.status==2){
StartGame();
}else if(data.status==1){
//conn.disconnect();
//initConnection();
$('.play_tips').css('display','block');
$('.tipsDiv').text('保存体力,等待开始');
proxy.invoke('JoinGame','Money').done(data=>{
});
}else if(data.status==-1){
window.clearInterval(clock);
clock=null;
getMyRank();
//显示统计窗口
$('.rank_mask').css('display','block');
$('.play_tips').css('display','none');
$('.tipsDiv').text('游戏已经结束咯');
}
}
})
//游戏开始
function StartGame(){
//3秒倒计时
......@@ -104,13 +202,13 @@
$('.circleCount').css('display','block');
$('.tipsDiv').css('display','block');
$('.play_tips').css('display','none');
var clock = window.setInterval(function(){
var clockReady = window.setInterval(function(){
Count--;
$('.circleCount').html(Count);
if(Count==0){
$('.circleCount').css('display','none');
$('.tipsDiv').css('display','none');
window.clearInterval(clock);
window.clearInterval(clockReady);
Count30();
startMove();
}
......@@ -119,7 +217,7 @@
//30秒倒计时
function Count30(){
$("#time").html(30);
let clock = window.setInterval(function() {
clock = window.setInterval(function() {
Count2--;
$("#time").html(Count2);
if (Count2 === 0) {
......@@ -130,6 +228,8 @@
}, 1000)
}
function startMove(){
let startX=0;
let startY=0;
money_en.on("touchstart", function(e) {
if (e.cancelable) {
// 判断默认行为是否已经被禁用
......@@ -173,6 +273,10 @@
},400, function () {
$(this).remove();
i+=100;
proxy.invoke("SetGameScore","Money", 100).done(msg => {
// dosomething
});
//$(".money_add span").html("¥"+i)
});
setTimeout(function () {
......
......@@ -323,15 +323,15 @@ body {
background: url(../img/money/new-number1.png) no-repeat center;
background-size: contain;
}
/*.rank_mask .rank-num.num2 {*/
/*background: url("../img/mobile_img/rank_num2.png") no-repeat center;*/
/*background-size: contain;*/
/*}*/
.rank_mask .rank-num.num2 {
background: url("../img/mobile_img/rank_num2.png") no-repeat center;
background-size: contain;
}
/*.rank_mask .rank-num.num3 {*/
/*background: url("../img/mobile_img/rank_num3.png") no-repeat center;*/
/*background-size: contain;*/
/*}*/
.rank_mask .rank-num.num3 {
background: url("../img/mobile_img/rank_num3.png") no-repeat center;
background-size: contain;
}
.rank_mask .rank-num {
width: 22px;
height: 28px;
......@@ -380,6 +380,6 @@ body {
vertical-align: middle;
border-radius: 50%;
position: relative;
top: -3px;
margin-left: 4px;
top: -1px;
margin-left: 15px;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment