Commit 59eec3b1 authored by zhangjinzhou's avatar zhangjinzhou

代码暂存

parent 221ae749
......@@ -262,8 +262,6 @@ Page({
app.openId = data.openId;
// app.step = data.inviteStep;
this.getActivityBaseInfoById();
this.checkLastGameStat();
}
},
/*
......@@ -369,6 +367,11 @@ Page({
this.canOpenGamePage = true;
this.start = true;
my.hideLoading();
let lastGameInfo = data.lastGameInfo;
lastGameInfo["step"] = data.step;
this.checkLastGameStat(lastGameInfo);
}
},
......@@ -510,44 +513,67 @@ Page({
}
},
//检测上局的状态
async checkLastGameStat() {
console.log("checkLastGameStat======>", 1);
let key = 'jn_' + app.openId + '_gamedata';
let lgamedata = await new Promise((res, rej) => {
my.getStorage({
key: key,
success: (result) => {
console.log("checkLastGameStat======>suc", result);
res(result.data);
},
fail: () => {
rej(false);
},
complete: () => {
async checkLastGameStat(data) {
//纯本地的
// let key = 'jn_' + app.openId + '_gamedata';
// let lgamedata = await new Promise((res, rej) => {
// my.getStorage({
// key: key,
// success: (result) => {
// res(result.data);
// },
// fail: () => {
// rej(false);
// },
// complete: () => {
}
});
})
// }
// });
// })
console.log("checkLastGameStat======>", 2, lgamedata);
if (lgamedata) {
const { endtime, overequest } = lgamedata;
//上局结算过了,不用管
if (!overequest) {
let querystr = "";
let { roomdata, roomnums, tooltime, canwin, step, startime, avatar2, avatar3, avatar4, othername, overequest } = lgamedata;
const nowTime = await getServerTime().catch(() => { });
console.log("checkLastGameStat======>", 3, endtime-nowTime);
console.log("checkLastGameStat======>",4,endtime,nowTime);
if (nowTime && endtime > nowTime) {//上局未结束,继续游戏
querystr += "laststat=go";
} else {//上局结束,未结算,去结算
querystr = "laststat=over";
}
my.redirectTo({
url: '/pages/pagegamemain/pagegamemain?' + querystr
});
// if (lgamedata) {
// const { endtime, overequest } = lgamedata;
// //上局结算过了,不用管
// if (!overequest) {
// let querystr = "";
// let { roomdata, roomnums, tooltime, canwin, step, startime, avatar2, avatar3, avatar4, othername, overequest } = lgamedata;
// const nowTime = await getServerTime().catch(() => { });
// if (nowTime && endtime > nowTime) {//上局未结束,继续游戏
// querystr += "laststat=go";
// } else {//上局结束,未结算,去结算
// querystr = "laststat=over";
// }
// my.redirectTo({
// url: '/pages/pagegamemain/pagegamemain?' + querystr
// });
// }
// }
//服务器的
let { joinGameStartTime, joinGameEndTime, toolStartTime, toolEndTime, winRate, propsCD ,step} = data;
if (joinGameStartTime && joinGameEndTime) {
let nowTime = await getServerTime().catch(() => { });
if(!nowTime){
nowTime = Date.now();
}
let toolcd = Math.ceil((toolEndTime-toolStartTime)/1000);
let tooless = Math.ceil((toolEndTime-nowTime)/1000);
if(tooless<0){
tooless = 0;
}
let querystr = "step=" + step + "&start=" + joinGameStartTime +
"&end=" + joinGameEndTime + "&gl=" + winRate + "&toolcd=" + toolcd+"&tooless="+tooless;
if (nowTime && joinGameEndTime > nowTime) {//上局未结束,继续游戏
querystr += "&laststat=go";
} else {//上局结束,未结算,去结算
querystr += "&laststat=over";
}
my.redirectTo({
url: '/pages/pagegamemain/pagegamemain?' + querystr
});
}
}
......
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