2022-09-08 18:22:18 +08:00
|
|
|
|
let urlPrefix = getUrlPrefix()
|
|
|
|
|
let browser = checkVersion()
|
2022-10-24 17:48:31 +08:00
|
|
|
|
// 获取用户的游戏记录
|
|
|
|
|
let recordList = []
|
|
|
|
|
let page = 1
|
|
|
|
|
let pageSize = 10
|
|
|
|
|
let canNext = true;
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
2022-10-24 17:48:31 +08:00
|
|
|
|
|
|
|
|
|
var lisIndex = 0;
|
|
|
|
|
const toastMsg = (content = '', time = 2) => {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
layer.open({
|
|
|
|
|
content,
|
|
|
|
|
time,
|
|
|
|
|
skin: 'msg'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 17:48:31 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
getInfoFromClient()
|
|
|
|
|
if (EnvCheck() === 'test') { new VConsole }
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
getUserRecord()
|
|
|
|
|
}, 100)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
2022-10-24 17:48:31 +08:00
|
|
|
|
const getUserRecord = () => {
|
|
|
|
|
canNext = false
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/listDrawRecord',
|
|
|
|
|
data: {
|
|
|
|
|
page,
|
|
|
|
|
pageSize
|
|
|
|
|
},
|
|
|
|
|
success (res) {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
if (res.data.length != 0) {
|
|
|
|
|
// 能够继续请求下一页
|
|
|
|
|
canNext = true
|
|
|
|
|
} else {
|
|
|
|
|
canNext = false
|
|
|
|
|
}
|
|
|
|
|
recordList.push(...res.data)
|
|
|
|
|
renderRecord(res)
|
2022-10-12 14:16:57 +08:00
|
|
|
|
} else {
|
2022-10-24 17:48:31 +08:00
|
|
|
|
canNext = true
|
|
|
|
|
toastMsg(res.message)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-24 17:48:31 +08:00
|
|
|
|
},
|
|
|
|
|
error (err) {
|
|
|
|
|
canNext = true
|
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-24 17:48:31 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 渲染游戏记录
|
|
|
|
|
const renderRecord = (res) => {
|
|
|
|
|
if (recordList.length === 0) {
|
|
|
|
|
$('.record-list').hide();
|
|
|
|
|
$('.img').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.record-list').show();
|
|
|
|
|
$('.img').hide();
|
|
|
|
|
var str = '';
|
|
|
|
|
let str2 = '';
|
|
|
|
|
let drawId = [];;
|
|
|
|
|
var results = [];
|
|
|
|
|
var lisIndexId = 0;
|
|
|
|
|
console.log(res.data)
|
|
|
|
|
res.data.forEach((res, index) => {
|
|
|
|
|
drawId.push(res.drawId);
|
|
|
|
|
str += `
|
|
|
|
|
<li style="margin-bottom: 0.8rem;">
|
|
|
|
|
<h3>${dateFormat(res.drawTime, 'yy-MM-dd hh:mm:ss')}</h3>
|
|
|
|
|
<div class="goldBox">
|
|
|
|
|
<span>遊戲獎勵:</span>
|
|
|
|
|
<span class="gold">${res.reward}鉆石</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="marine_organism"></div>
|
|
|
|
|
<p style="display: ${res.drawStatus == 1 ? 'none' : 'block'};" class="fasle">哎呀~猜錯了 o(╥﹏╥)o</p>
|
|
|
|
|
<p style="display: ${res.drawStatus == 1 ? 'block' : 'none'};" class="true">厲害~猜對了 ୧(๑•̀◡•́๑)૭</p>
|
|
|
|
|
</li>
|
|
|
|
|
`
|
|
|
|
|
results.push(res.results);
|
|
|
|
|
});
|
|
|
|
|
$('.record-list').append(str)
|
|
|
|
|
results.forEach((res, index) => {
|
|
|
|
|
res.forEach(val => {
|
|
|
|
|
$('.record-list li').eq(lisIndex).children('.marine_organism').append(`<span class='${drawId[lisIndexId] == val.itemId ? 'active' : ''}'><img src="${val.itemUrl}" alt=""><b>+${val.costPiece}</b></span>`)
|
|
|
|
|
})
|
|
|
|
|
lisIndex = lisIndex + 1;
|
|
|
|
|
lisIndexId = lisIndexId + 1;
|
|
|
|
|
});
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-20 16:28:50 +08:00
|
|
|
|
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-10-24 17:48:31 +08:00
|
|
|
|
})
|
|
|
|
|
$(window).scroll(function () {
|
|
|
|
|
if ($(window).scrollTop() + $(window).height() > $(document).height() - 10) {
|
|
|
|
|
// 请求下一页
|
|
|
|
|
if (canNext) {
|
|
|
|
|
getUserRecord(page++)
|
|
|
|
|
} else {
|
|
|
|
|
console.log('无数据被锁定');
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-24 17:48:31 +08:00
|
|
|
|
}
|
|
|
|
|
});
|