Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new_taobao
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
new_taobao
Commits
59eec3b1
Commit
59eec3b1
authored
Oct 17, 2020
by
zhangjinzhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码暂存
parent
221ae749
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
194 additions
and
133 deletions
+194
-133
pagegamemain.js
taobao_jn/client/pages/pagegamemain/pagegamemain.js
+131
-96
pagepageindex.js
taobao_jn/client/pages/pagepageindex/pagepageindex.js
+63
-37
No files found.
taobao_jn/client/pages/pagegamemain/pagegamemain.js
View file @
59eec3b1
...
...
@@ -115,39 +115,65 @@ Page({
hidetime
:
0
,
othername
:
[],
overequest
:
false
,
laststat
:
""
},
onLoad
(
query
)
{
// console.log("onLoad========>", app, props
);
console
.
log
(
"onLoad========>"
,
query
);
if
(
query
&&
query
.
laststat
)
{
let
laststat
=
query
.
laststat
;
this
.
setData
({
laststat
:
laststat
});
console
.
log
(
"laststat=====>"
,
laststat
);
this
.
getLastGame
(
);
this
.
checkLastGame
(
query
);
return
;
}
else
{
this
.
setData
({
laststat
:
'normal'
});
console
.
log
(
"普通进入"
);
}
let
isnewdata
=
my
.
getStorageSync
({
key
:
'jn_'
+
app
.
openId
+
'_new'
});
let
isnew
=
isnewdata
.
data
?
0
:
1
;
// isnew = 1;
this
.
setData
({
isnew
:
isnew
});
if
(
isnew
!=
0
)
{
my
.
setStorageSync
({
key
:
'jn_'
+
app
.
openId
+
'_new'
,
data
:
1
this
.
initGame
(
query
);
},
//initgame===>
async
initGame
(
query
,
gamestat
=
"normal"
)
{
let
isnew
=
false
;
let
tooltime
=
0
;
console
.
log
(
"initGame"
,
query
,
gamestat
);
let
{
end
,
gl
,
start
,
step
,
toolcd
}
=
query
;
gameatime
=
Math
.
floor
((
Number
(
end
)
-
Number
(
start
))
/
1000
);
if
(
gamestat
==
"normal"
)
{
let
isnewdata
=
my
.
getStorageSync
({
key
:
'jn_'
+
app
.
openId
+
'_new'
});
let
isnew
=
isnewdata
.
data
?
0
:
1
;
// isnew = 1;
this
.
setData
({
isnew
:
isnew
});
if
(
isnew
!=
0
)
{
my
.
setStorageSync
({
key
:
'jn_'
+
app
.
openId
+
'_new'
,
data
:
1
});
}
}
else
{
tooltime
=
query
.
tooless
;
let
nowTime
=
await
getServerTime
().
catch
(()
=>
{
});
if
(
!
nowTime
)
{
nowTime
=
Date
.
now
();
}
gameatime
=
Math
.
floor
((
Number
(
end
)
-
Number
(
nowTime
))
/
1000
);
if
(
gameatime
<
0
)
{
gameatime
=
0
;
}
}
// console.log("新手", isnew, query);
let
{
end
,
gl
,
start
,
step
,
toolcd
}
=
query
;
step
=
Number
(
step
);
// step = 3;
gameatime
=
Math
.
floor
((
Number
(
end
)
-
Number
(
start
))
/
1000
);
gtoolcd
=
Number
(
toolcd
);
console
.
error
(
"道具cd"
,
toolcd
,
gtoolcd
);
let
sucgl
=
Number
(
gl
);
let
nranksuc
=
Math
.
random
();
let
canwin
=
false
;
...
...
@@ -202,6 +228,7 @@ Page({
};
roomdata
.
push
(
idata
);
}
// console.log("onload=========>",roomnums,roomdata);
this
.
setData
({
avatar1
:
app
.
avatar
,
...
...
@@ -213,24 +240,32 @@ Page({
canwin
:
canwin
,
isfirst
:
true
,
gametime
:
gameatime
,
tooltime
:
0
,
tooltime
:
tooltime
,
startime
:
Number
(
start
),
endtime
:
Number
(
end
),
});
this
.
changePashow
();
my
.
__updateWarms
=
()
=>
{
this
.
updateActInfo
();
}
// console.log("my======>",my);
if
(
gamestat
==
"normal"
)
{
this
.
changePashow
();
}
else
{
this
.
updateActInfo
();
this
.
updateAiInfo
()
this
.
changePageShow1
();
this
.
updateAct
();
}
},
startGame
()
{
if
(
this
.
data
.
isnew
>
0
&&
this
.
data
.
isnew
<
7
)
{
return
;
}
my
.
showToast
({
content
:
'请不要关闭APP,会导致本局游戏作废'
,
duration
:
4500
,
});
//
my.showToast({
//
content: '请不要关闭APP,会导致本局游戏作废',
//
duration: 4500,
//
});
// console.log("游戏开始逻辑==canwin", this.data.canwin);
let
attiontxt1
=
"游戏开始啦,共有"
+
this
.
data
.
roomnums
+
"名玩家加入游戏,快来升温队伍拿奖励吧。"
;
this
.
addAttionTxt
(
attiontxt1
);
...
...
@@ -545,27 +580,31 @@ Page({
}
},
onShow
()
{
let
ntime
=
Date
.
now
();
let
hidetime
=
this
.
data
.
hidetime
;
if
(
hidetime
)
{
let
passtime
=
ntime
-
hidetime
;
let
gametime
=
this
.
data
.
gametime
;
gametime
-=
passtime
/
1000
;
if
(
gametime
<
0
)
{
gametime
=
0
;
}
let
laststat
=
this
.
data
.
laststat
;
if
(
laststat
==
"normal"
)
{
let
ntime
=
Date
.
now
();
let
hidetime
=
this
.
data
.
hidetime
;
if
(
hidetime
)
{
let
passtime
=
ntime
-
hidetime
;
let
gametime
=
this
.
data
.
gametime
;
gametime
-=
passtime
/
1000
;
if
(
gametime
<
0
)
{
gametime
=
0
;
}
let
tooltime1
=
this
.
data
.
tooltime
;
tooltime1
-=
passtime
/
1000
;
if
(
tooltime1
<
0
)
{
tooltime1
=
0
;
let
tooltime1
=
this
.
data
.
tooltime
;
tooltime1
-=
passtime
/
1000
;
if
(
tooltime1
<
0
)
{
tooltime1
=
0
;
}
this
.
setData
({
gametime
:
gametime
,
tooltime
:
tooltime1
})
}
this
.
setData
({
gametime
:
gametime
,
tooltime
:
tooltime1
})
}
let
ngametime
=
this
.
data
.
gametime
;
if
((
this
.
data
.
isnew
>
0
&&
this
.
data
.
isnew
<
7
)
||
this
.
data
.
show_v
!=
2
||
ngametime
<=
0
)
{
return
;
...
...
@@ -680,6 +719,11 @@ Page({
},
//游戏结束
async
gameover
()
{
let
key
=
'jn_'
+
app
.
openId
+
'_gamedata'
;
my
.
removeStorage
({
key
:
key
});
this
.
closenordia
();
// console.log("游戏结束");
let
roomnums
=
this
.
data
.
roomnums
;
...
...
@@ -699,7 +743,7 @@ Page({
let
step
=
this
.
data
.
step
;
app
.
curGameWars
=
this
.
data
.
roomdata
[
this
.
data
.
myidx
-
1
].
wd
;
const
overdata
=
await
API
.
gameOver
({
const
{
success
,
data
}
=
await
API
.
gameOver
({
isWin
:
iswin
,
step
:
step
}).
catch
(
res
=>
{
...
...
@@ -708,7 +752,7 @@ Page({
this
.
setData
({
overequest
:
true
});
const
{
success
,
data
}
=
overdata
;
if
(
success
)
{
const
{
warms
,
isWin
,
prize
,
unLockStep
}
=
data
;
// console.log("over", data)
...
...
@@ -787,14 +831,14 @@ Page({
let
tooltime
=
this
.
data
.
tooltime
;
if
(
tooltime
<=
0
)
{
//可使用
let
addwarm
=
toolwarm
;
let
tooldata
=
await
API
.
sendWarmsByCurGame
({
const
{
success
,
data
}
=
await
API
.
sendWarmsByCurGame
({
type
:
"tool"
,
warms
:
addwarm
,
step
:
this
.
data
.
step
}).
catch
(
res
=>
{
commonToast
(
res
&&
res
.
message
);
});
const
{
success
,
data
}
=
tooldata
;
if
(
success
)
{
this
.
updateActInfo
();
this
.
setData
({
...
...
@@ -869,14 +913,14 @@ Page({
let
startime
=
this
.
data
.
startime
;
let
endtime
=
this
.
data
.
endtime
;
let
step
=
this
.
data
.
step
;
let
attiondata
=
await
API
.
getWarmDetailListByCurGame
({
const
{
success
,
data
}
=
await
API
.
getWarmDetailListByCurGame
({
joinGameStartTime
:
startime
,
joinGameEndTime
:
endtime
,
step
:
step
}).
catch
(
res
=>
{
commonToast
(
res
&&
res
.
message
);
})
const
{
success
,
data
}
=
attiondata
;
if
(
success
)
{
const
{
total
,
invite
,
tool
,
follow
,
sign
,
collect
,
browseGoods
}
=
data
;
let
ridx
=
this
.
data
.
myidx
;
...
...
@@ -1047,12 +1091,14 @@ Page({
}).
catch
(
res
=>
{
commonToast
(
res
&&
res
.
message
);
});
const
{
success
,
data
}
=
invitedata
;
if
(
success
)
{
if
(
data
&&
data
.
length
>
this
.
data
.
invitedata
.
length
)
{
this
.
setData
({
invitedata
:
data
});
if
(
invitedata
)
{
const
{
success
,
data
}
=
invitedata
;
if
(
success
)
{
if
(
data
&&
data
.
length
>
this
.
data
.
invitedata
.
length
)
{
this
.
setData
({
invitedata
:
data
});
}
}
}
},
...
...
@@ -1289,8 +1335,7 @@ Page({
FYGE
.
getRequestAnimationFrame
()(
loop
);
}
},
//用上局游戏继续
async
getLastGame
()
{
async
checkLastGame
(
query
)
{
let
key
=
'jn_'
+
app
.
openId
+
'_gamedata'
;
let
lgamedata
=
await
new
Promise
((
res
,
rej
)
=>
{
my
.
getStorage
({
...
...
@@ -1308,27 +1353,28 @@ Page({
});
})
if
(
lgamedata
)
{
let
{
roomdata
,
roomnums
,
tooltime
,
canwin
,
step
,
startime
,
endtime
,
avatar2
,
avatar3
,
avatar4
,
othername
,
overequest
}
=
lgamedata
;
commonToast
(
"正在连接到上一局"
);
if
(
!
overequest
)
{
let
nowTime
=
await
getServerTime
().
catch
(()
=>
{
});
if
(
!
nowTime
)
{
nowTime
=
Date
.
now
();
}
console
.
log
(
"nowtime===>"
,
nowTime
,
endtime
,
nowTime
-
endtime
);
if
(
endtime
>
nowTime
)
{
//继续
this
.
lastgamereset
(
lgamedata
,
nowTime
);
}
else
{
//结算
this
.
lastgameover
(
lgamedata
,
nowTime
);
}
}
else
{
console
.
error
(
"哪里处理问题====》"
,
lgamedata
);
}
let
{
step
,
start
,
end
,
gl
,
toolcd
,
tooless
}
=
query
;
lgamedata
[
"step"
]
=
step
;
lgamedata
[
"startime"
]
=
start
;
lgamedata
[
"endtime"
]
=
end
;
lgamedata
[
"gl"
]
=
gl
;
lgamedata
[
"toolcd"
]
=
toolcd
;
lgamedata
[
"tooltime"
]
=
tooless
;
my
.
removeStorage
({
key
:
key
key
:
key
});
let
nowTime
=
await
getServerTime
().
catch
(()
=>
{
});
if
(
!
nowTime
)
{
nowTime
=
Date
.
now
();
}
if
(
end
>
nowTime
)
{
//继续
this
.
lastgamereset
(
lgamedata
,
nowTime
);
}
else
{
//结算
this
.
lastgameover
(
lgamedata
,
nowTime
);
}
}
else
{
console
.
log
(
"start====query"
,
query
);
this
.
initGame
(
query
,
"spe"
);
}
},
//直接结束
...
...
@@ -1337,13 +1383,6 @@ Page({
let
{
roomdata
,
roomnums
,
tooltime
,
canwin
,
step
,
startime
,
endtime
,
avatar2
,
avatar3
,
avatar4
,
othername
,
overequest
,
hidetime
}
=
lgamedata
;
let
passtime
=
Math
.
floor
((
nowTime
-
hidetime
)
/
1000
);
if
(
passtime
>
0
)
{
tooltime
-=
passtime
;
}
if
(
tooltime
<
0
)
{
tooltime
=
0
;
}
this
.
setData
({
avatar1
:
app
.
avatar
,
avatar2
:
avatar2
,
...
...
@@ -1362,25 +1401,17 @@ Page({
});
this
.
updateActInfo
(
"last"
);
this
.
updateAiInfo
();
console
.
log
(
"更新ai"
);
this
.
changePageShow1
();
console
.
log
(
"aiwdshow"
,
this
.
data
.
roomdata
);
this
.
gameover
();
},
//恢复上局游戏
async
lastgamereset
(
lgamedata
,
nowTime
)
{
let
{
roomdata
,
roomnums
,
tooltime
,
canwin
,
step
,
startime
,
endtime
,
avatar2
,
avatar3
,
avatar4
,
othername
,
overequest
,
hidetime
roomdata
,
roomnums
,
tooltime
,
canwin
,
step
,
startime
,
endtime
,
avatar2
,
avatar3
,
avatar4
,
othername
,
toolcd
,
overequest
,
hidetime
}
=
lgamedata
;
let
passtime
=
Math
.
floor
((
nowTime
-
hidetime
)
/
1000
);
if
(
passtime
>
0
)
{
tooltime
-=
passtime
;
}
if
(
tooltime
<
0
)
{
tooltime
=
0
;
}
let
gameatime
=
Math
.
floor
((
Number
(
endtime
)
-
Number
(
nowTime
))
/
1000
);
gtoolcd
=
Number
(
toolcd
);
this
.
setData
({
avatar1
:
app
.
avatar
,
avatar2
:
avatar2
,
...
...
@@ -1396,7 +1427,11 @@ Page({
showtooltime
:
this
.
changeshowtime
(
tooltime
),
startime
:
Number
(
startime
),
endtime
:
Number
(
endtime
),
})
othername
:
othername
,
overequest
:
overequest
,
hidetime
:
hidetime
});
this
.
updateActInfo
(
"last"
);
this
.
updateAiInfo
();
this
.
changePageShow1
();
...
...
@@ -1455,7 +1490,7 @@ Page({
twd
=
iwd
+
towarm
;
}
}
this
.
updateRolewd
(
i
,
twd
);
this
.
updateRolewd
(
i
+
1
,
twd
);
...
...
taobao_jn/client/pages/pagepageindex/pagepageindex.js
View file @
59eec3b1
...
...
@@ -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
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment