Commit 59eec3b1 authored by zhangjinzhou's avatar zhangjinzhou

代码暂存

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