2022-09-08 18:22:18 +08:00
|
|
|
|
|
|
|
|
|
let urlPrefix = getUrlPrefix()
|
|
|
|
|
let browser = checkVersion()
|
|
|
|
|
let env = EnvCheck();
|
|
|
|
|
if (env == 'test') {
|
|
|
|
|
new VConsole();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
let lock = false //防止用戶暴力點擊加的鎖
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 封裝layer消息提醒框
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let layerIndex
|
2022-10-20 16:28:50 +08:00
|
|
|
|
const showLoading = (content = '加載中...') => {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
layer.open({
|
|
|
|
|
type: 2,
|
|
|
|
|
shadeClose: false,
|
|
|
|
|
content,
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (e) {
|
2023-03-07 11:30:20 +08:00
|
|
|
|
layerIndex = $(e).attr('index');
|
|
|
|
|
$('.layui-m-layer').css("z-index", '9999');
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const hideLoading = (index) => {
|
|
|
|
|
layer.close(index)
|
|
|
|
|
}
|
|
|
|
|
const toastMsg = (content = '操作完成', time = 2) => {
|
|
|
|
|
layer.open({
|
|
|
|
|
content,
|
|
|
|
|
time,
|
|
|
|
|
skin: 'msg'
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-02-23 10:11:40 +08:00
|
|
|
|
if (false) { //!browser.app
|
2022-10-12 14:16:57 +08:00
|
|
|
|
toastMsg('請在app內打開!');
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.wrap').removeClass('no-in-app')
|
|
|
|
|
}
|
2023-03-06 17:15:23 +08:00
|
|
|
|
console.log(document.body.clientWidth);
|
|
|
|
|
console.log(document.body.clientHeight);
|
2023-03-07 11:30:20 +08:00
|
|
|
|
if (document.body.clientHeight <= 700) {
|
|
|
|
|
$('body,html').css({ "height": '19.2rem' });
|
|
|
|
|
}
|
|
|
|
|
if (document.body.clientWidth >= 365) {
|
2023-03-06 17:15:23 +08:00
|
|
|
|
$('body,html').css({ "height": '19.2rem' });
|
|
|
|
|
}
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 獲取用戶相關信息
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let myFragment
|
|
|
|
|
const getUserInfo = (param) => {
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/getUserActInfo',
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
2022-10-28 11:29:03 +08:00
|
|
|
|
|
2022-12-08 17:10:30 +08:00
|
|
|
|
$('.info-bottom .info-wrap .fragment-num span').text(res.data.todayReward);
|
|
|
|
|
$('.info-bottom .info-wrap .diamond-num span').text(res.data.diamonds);
|
|
|
|
|
$('.info-bottom .avatar img').attr('src', res.data.avatar);
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.info-bottom').find('.avatar img').attr('src', res.data.avatar)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
|
|
|
|
if (res.data.todayReward.toString().length >= 5) {
|
|
|
|
|
res.data.todayReward = (res.data.todayReward / 10000).toFixed(2) + 'w'
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-20 16:28:50 +08:00
|
|
|
|
$('.info-bottom').find('.award span').html(res.data.todayReward)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.info-bottom').find('.fragment span').html(res.data.diamonds)
|
|
|
|
|
myFragment = res.data.diamonds
|
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
return toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 獲取用戶碎片信息
|
2022-09-08 18:22:18 +08:00
|
|
|
|
const getUserPieceNum = () => {
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/getUserActInfo',
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
$('.info-bottom').find('.fragment span').html(res.data.diamonds)
|
|
|
|
|
myFragment = res.data.diamonds;
|
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
return toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
lock = !lock
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 獲取遊戲模式 1普通模式 2禮物模式
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let modelType
|
|
|
|
|
const getGameMode = () => {
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/getTimeConfig',
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
modelType = res.data.modelType
|
|
|
|
|
getNewestAct()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
return toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
let userComeinTime //用戶進入遊戲界面時間,後端返回的timestamp
|
|
|
|
|
let startTime, drawStageStartTime, showResultStageStartTime, endTime //4個時間戳判斷落於哪個界面
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let timer2
|
|
|
|
|
let roundId
|
|
|
|
|
let roundIdArr = []
|
|
|
|
|
let arrTime = [], arrTime2 = [], arrTime3 = []
|
|
|
|
|
|
|
|
|
|
const getNewestAct = () => {
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/getNewestAct',
|
2022-12-15 16:00:23 +08:00
|
|
|
|
timeout: 8000,
|
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
if ($.isEmptyObject(res.data) || res.data.status === 4) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
return showLoading('服務器正在維護中...')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
console.log(res.timestamp > res.data.endTime);
|
|
|
|
|
if (res.timestamp >= res.data.endTime) { //請求的還是上一輪的數據,重新請求
|
2022-10-20 16:28:50 +08:00
|
|
|
|
console.log('請求的還是上一輪的數據,必須重新請求');
|
2022-09-08 18:22:18 +08:00
|
|
|
|
showLoading()
|
|
|
|
|
timer2 = setTimeout(() => {
|
|
|
|
|
getNewestAct()
|
|
|
|
|
}, 600);
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
clearTimeout(timer2)
|
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
roundId = res.data.roundId
|
2022-12-27 14:08:50 +08:00
|
|
|
|
$('.game-area .roundId').html(roundId)
|
2022-10-12 14:16:57 +08:00
|
|
|
|
getListItem(roundId, modelType)
|
2023-03-07 11:30:20 +08:00
|
|
|
|
getPreviousResults(20, roundId)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 進行下一輪時,arrTime重新置為空數組,不然在下一輪開始的時候也會執行location.reload()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (roundIdArr.length < 2) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
roundIdArr = [roundId, roundId]
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
roundIdArr[0] = roundIdArr[1]
|
|
|
|
|
roundIdArr[1] = roundId
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (roundIdArr[0] != roundIdArr[1]) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
arrTime = []
|
|
|
|
|
arrTime2 = []
|
|
|
|
|
arrTime3 = []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userComeinTime = res.timestamp
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
2022-09-08 18:22:18 +08:00
|
|
|
|
startTime = res.data.startTime
|
|
|
|
|
drawStageStartTime = res.data.drawStageStartTime
|
|
|
|
|
showResultStageStartTime = res.data.showResultStageStartTime
|
|
|
|
|
endTime = res.data.endTime
|
2022-10-22 20:08:44 +08:00
|
|
|
|
console.log('獲取5個時間戳的值-----', 'timestamp:', userComeinTime, 'startTime:', startTime, 'drawStageStartTime:', drawStageStartTime, 'showResultStageStartTime:', showResultStageStartTime, 'endTime:', endTime);
|
2022-09-08 18:22:18 +08:00
|
|
|
|
showView()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
return toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-12-15 16:00:23 +08:00
|
|
|
|
},
|
|
|
|
|
complete: function (XMLHttpRequest, status) {
|
|
|
|
|
if (status == 'timeout') {
|
|
|
|
|
XMLHttpRequest.abort()// 超时后中断请求
|
|
|
|
|
toastMsg('网络开小差,请退出重进,开奖结果可通过【游戏记录】/【往轮结果】查看~')
|
|
|
|
|
}
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
//不為3繼續請求 為3拿數據 為4彈窗
|
2022-10-22 20:08:44 +08:00
|
|
|
|
let status
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 顯示哪個界面
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let $countDown
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
//區分倒計時到0時的區別處理的字段,處於第二階段時isStatus2為真,處於第三階段時isStatus3為真
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let isStatus2
|
|
|
|
|
let isStatus3
|
|
|
|
|
|
|
|
|
|
let isSelectTab = false
|
|
|
|
|
let mySelect
|
|
|
|
|
let fragmentNum
|
|
|
|
|
let reg = /^[0-9]*$/
|
|
|
|
|
|
|
|
|
|
const showView = () => {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (startTime <= userComeinTime && userComeinTime < drawStageStartTime) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 第一階段
|
|
|
|
|
console.log('進入第一階段');
|
2022-09-08 18:22:18 +08:00
|
|
|
|
isSelectTab = false
|
|
|
|
|
$('.select-time').show().siblings().hide()
|
2022-12-27 14:08:50 +08:00
|
|
|
|
$('.roundId').show()
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$countDown = $('.select-time .count-down .count-down-num')
|
|
|
|
|
|
2022-10-22 20:08:44 +08:00
|
|
|
|
mySelect = sessionStorage.getItem("mySelect")
|
|
|
|
|
if (reg.test(mySelect)) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.btn-wrap div').eq(mySelect).addClass('active').siblings().removeClass('active')
|
2022-10-12 14:16:57 +08:00
|
|
|
|
fragmentNum = parseInt($('.btn-wrap div').eq(mySelect).html())
|
|
|
|
|
isSelectTab = true
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.btn-wrap div').eq(0).addClass('active').siblings().removeClass('active')
|
|
|
|
|
fragmentNum = parseInt($('.btn-wrap div').eq(0).html())
|
2022-09-08 18:22:18 +08:00
|
|
|
|
isSelectTab = true
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.award-wrap').html('').show()
|
2022-12-09 19:35:35 +08:00
|
|
|
|
// $('.award-info .desc').html('')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
showCountDown(userComeinTime, startTime, drawStageStartTime)
|
|
|
|
|
getUserInfo()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else if (drawStageStartTime <= userComeinTime && userComeinTime < showResultStageStartTime) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 第二階段
|
|
|
|
|
console.log('進入第二階段');
|
|
|
|
|
|
2022-10-12 14:16:57 +08:00
|
|
|
|
sessionStorage.removeItem("mySelect")
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
|
|
|
|
$('.wait-time').show().siblings().hide()
|
2022-12-27 14:08:50 +08:00
|
|
|
|
$('.roundId').show()
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$countDown = $('.wait-time .count-down .count-down-num')
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
clearTimeout(timer2s) //清除第一階段的2s氣泡定時器
|
2022-09-08 18:22:18 +08:00
|
|
|
|
time2sIndex = 0
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
isStatus2 = true //處於第二階段的標識
|
2022-09-08 18:22:18 +08:00
|
|
|
|
console.log('isStatus2的值------------', isStatus2);
|
|
|
|
|
|
|
|
|
|
// $('.btn-wrap').find('div').removeClass('active')
|
|
|
|
|
showCountDown(userComeinTime, drawStageStartTime, showResultStageStartTime)
|
|
|
|
|
judgeStatus()
|
|
|
|
|
getUserInfo()
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 播放5s動畫
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let player = new SVGA.Player('.wait-time');
|
|
|
|
|
let parser = new SVGA.Parser('.wait-time');
|
2023-03-06 17:15:23 +08:00
|
|
|
|
parser.load('./images/wait1.svga', function (videoItem) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
// player.loops = 2;
|
|
|
|
|
player.clearsAfterStop = false;
|
|
|
|
|
player.setVideoItem(videoItem);
|
|
|
|
|
player.startAnimation();
|
|
|
|
|
})
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else if (showResultStageStartTime <= userComeinTime && userComeinTime < endTime) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 第三階段
|
|
|
|
|
console.log('進入第三階段');
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.draw-time').show().siblings().hide()
|
2022-12-27 14:08:50 +08:00
|
|
|
|
$('.roundId').show()
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$countDown = $('.draw-time .count-down .count-down-num')
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
isStatus3 = true //處於第三階段的標識
|
2022-09-08 18:22:18 +08:00
|
|
|
|
console.log('isStatus3的值------------', isStatus3);
|
|
|
|
|
|
|
|
|
|
showCountDown(userComeinTime, showResultStageStartTime, endTime)
|
|
|
|
|
judgeStatus()
|
|
|
|
|
getUserInfo()
|
|
|
|
|
}
|
2023-03-07 11:30:20 +08:00
|
|
|
|
$('.game-area').show();
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 顯示倒計時
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let countDownTime
|
|
|
|
|
let deltaT
|
|
|
|
|
let timer
|
|
|
|
|
let delayTime
|
|
|
|
|
let interval
|
|
|
|
|
const showCountDown = (timestamp, startTime, endTime) => {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
deltaT = ((endTime - startTime) - (timestamp - startTime)) / 1000 //12.361
|
|
|
|
|
if (deltaT >= 1) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
interval = 1
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
interval = 0
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
console.log('deltaT----------', deltaT);
|
|
|
|
|
countDownTime = Math.floor(deltaT) //12.361 => 12
|
2022-10-20 16:28:50 +08:00
|
|
|
|
delayTime = deltaT - countDownTime //請求接口的延遲時間
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
|
|
|
|
$countDown.html(countDownTime)
|
|
|
|
|
|
|
|
|
|
timer = setInterval(() => {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (browser.ios) {
|
|
|
|
|
if (!isStatus3 && !isStatus2) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 處理第一階段
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (arrTime.length < 2) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
arrTime = [new Date().getTime(), new Date().getTime()]
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
arrTime[0] = arrTime[1]
|
|
|
|
|
arrTime[1] = new Date().getTime()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if ((arrTime[1] - arrTime[0]) / 1000 > 1.5) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
window.location.reload()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else if (isStatus2) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 第二階段也要處理
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (arrTime2.length < 2) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
arrTime2 = [new Date().getTime(), new Date().getTime()]
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
arrTime2[0] = arrTime2[1]
|
|
|
|
|
arrTime2[1] = new Date().getTime()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if ((arrTime2[1] - arrTime2[0]) / 1000 > 1.5) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
window.location.reload()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else if (isStatus3) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 第三階段也要處理
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (arrTime3.length < 2) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
arrTime3 = [new Date().getTime(), new Date().getTime()]
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
arrTime3[0] = arrTime3[1]
|
|
|
|
|
arrTime3[1] = new Date().getTime()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if ((arrTime3[1] - arrTime3[0]) / 1000 > 1.5) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
window.location.reload()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
countDownTime--
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (countDownTime <= 0) {
|
|
|
|
|
$countDown.html(0)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
clearInterval(timer)
|
|
|
|
|
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (isStatus2) { // 倒計時為0時,處於第二階段的處理
|
|
|
|
|
if (status) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
// hideLoading(layerIndex)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
getNewestAct()
|
|
|
|
|
}, delayTime * 1000)
|
|
|
|
|
isStatus2 = false
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
showLoading()
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// toastMsg('服務器繁忙,請稍等')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
console.log('status的值-----------', status);
|
2022-09-08 18:22:18 +08:00
|
|
|
|
judgeStatus()
|
|
|
|
|
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else if (isStatus3) { //倒計時為0時,處於第三階段的處理
|
2022-09-08 18:22:18 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
getNewestAct()
|
|
|
|
|
// getListItem(roundId)
|
|
|
|
|
}, delayTime * 1000)
|
|
|
|
|
// getNewestAct()
|
|
|
|
|
// getListItem()
|
|
|
|
|
isStatus3 = false
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
getNewestAct()
|
|
|
|
|
}, delayTime * 1000)
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
|
|
|
|
// else {
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// getNewestAct()
|
|
|
|
|
// }, delayTime * 1000)
|
|
|
|
|
// }
|
|
|
|
|
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$countDown.html(countDownTime)
|
|
|
|
|
}
|
|
|
|
|
}, interval * 1000)
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
//判斷status的狀態
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let timer4
|
|
|
|
|
let drawInfo
|
2022-10-20 16:28:50 +08:00
|
|
|
|
let img //第三階段的中獎動物img
|
2022-09-08 18:22:18 +08:00
|
|
|
|
|
|
|
|
|
const judgeStatus = () => {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
console.log('進入二階段時輪詢查看結果是否已經出了');
|
2022-09-08 18:22:18 +08:00
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/getNewestAct',
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
console.log('res.data的值------------', res.data);
|
|
|
|
|
if ($.isEmptyObject(res.data) || res.data.status === 4) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
console.log('程序崩了!!!');
|
2022-10-20 16:28:50 +08:00
|
|
|
|
return showLoading('服務器正在維護中...')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else if (res.data.status === 3) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
clearTimeout(timer4)
|
|
|
|
|
status = true
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (isStatus2 && countDownTime <= 0) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
showCountDown(userComeinTime, drawStageStartTime, showResultStageStartTime)
|
|
|
|
|
}
|
|
|
|
|
// hideLoading(layerIndex)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
console.log('status為3時返回的數據--------------', res.data);
|
2022-09-08 18:22:18 +08:00
|
|
|
|
drawInfo = res.data
|
|
|
|
|
img = res.data.drawImageUrl
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (isStatus3) {
|
2023-03-06 17:15:23 +08:00
|
|
|
|
getPreviousResults(20, roundId)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
renderDrawInfo()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
timer4 = setTimeout(() => {
|
|
|
|
|
judgeStatus()
|
|
|
|
|
}, 1000)
|
|
|
|
|
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 渲染開獎信息
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let topThreeArr = []
|
|
|
|
|
const renderDrawInfo = () => {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.draw-time .current-tip .current-result').html(drawInfo.drawName)
|
2023-03-06 17:15:23 +08:00
|
|
|
|
// $('.draw-pic img').attr('src', drawInfo.drawImageUrl)
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic').remove();
|
|
|
|
|
var lenght = drawInfo.drawItemList.length;
|
|
|
|
|
var drawStr = '';
|
|
|
|
|
drawInfo.drawItemList.forEach(res => {
|
|
|
|
|
drawStr += `
|
|
|
|
|
<div class="draw-pic">
|
|
|
|
|
<img src="${res.drawImageUrl}" alt="">
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
$('.wrap .game-area .draw-time').append(drawStr);
|
|
|
|
|
if (lenght == 1) {
|
|
|
|
|
$('.wrap .game-area .draw-time').css({ "width": "55%", })
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic').css({ "width": "50%", "height": "100%", });
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic img').css({ "width": "45%" });
|
|
|
|
|
} else if (lenght == 2) {
|
|
|
|
|
$('.wrap .game-area .draw-time').css({ "width": "55%", })
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic').css({ "width": "50%", "height": "100%", });
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic img').css({ "width": "45%" });
|
|
|
|
|
} else if (lenght == 3) {
|
|
|
|
|
$('.wrap .game-area .draw-time').css({ "width": "70%", })
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic').css({ "width": "33.3333%", "height": "75%", });
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic img').css({ "width": "40%" });
|
|
|
|
|
} else if (lenght == 4) {
|
|
|
|
|
$('.wrap .game-area .draw-time').css({ "width": "80%", })
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic').css({ "width": "25%", "height": "65%", });
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic img').css({ "width": "38%" });
|
|
|
|
|
} else if (lenght > 4) {
|
|
|
|
|
$('.wrap .game-area .draw-time').css({ "width": "55%", })
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic').css({ "width": "1.3466666667rem", "height": "1.3466666667rem", });
|
|
|
|
|
$('.wrap .game-area .draw-time .draw-pic img').css({ "width": "0.8rem" });
|
|
|
|
|
}
|
|
|
|
|
// if()
|
2022-12-09 19:35:35 +08:00
|
|
|
|
// if (isStatus3) {
|
|
|
|
|
// if (drawInfo.userDrawResult.drawStatus === 1) {
|
|
|
|
|
// $('.award-info .desc').html('恭喜你,猜中了!')
|
|
|
|
|
// // if (modelType === 1) {
|
|
|
|
|
// // $('.award-wrap').html(`獲得 <span class="award-total">${drawInfo.userDrawResult.prizeDiamonds} </span>鉆石`)
|
|
|
|
|
// // } else {
|
|
|
|
|
// // $('.award-wrap').html(`獲得 <span class="award-name">${drawInfo.userDrawResult.prizeName} </span>(<span class="awrad-price">${drawInfo.userDrawResult.prizePrice}</span>鉆)*<span class="award-num">${drawInfo.userDrawResult.prizeCount}</span>個 累計<span class="award-total">${drawInfo.userDrawResult.prizeDiamonds}</span>鉆石`)
|
|
|
|
|
// // }
|
|
|
|
|
// } else if (drawInfo.userDrawResult.drawStatus === 2) {
|
|
|
|
|
// $('.award-info .desc').html('很遺憾,本輪未猜中')
|
|
|
|
|
// $('.award-wrap').hide()
|
|
|
|
|
// } else if (drawInfo.userDrawResult.drawStatus === 3) {
|
|
|
|
|
// $('.award-info .desc').html('本輪未參與')
|
|
|
|
|
// $('.award-wrap').hide()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
$('.put-wrap .list .item').remove()
|
|
|
|
|
// 渲染投入列表
|
|
|
|
|
let list = ''
|
|
|
|
|
drawInfo.userDrawResult.drawRecords.map(res => {
|
|
|
|
|
list += `
|
|
|
|
|
<div class="item">
|
|
|
|
|
<p><img src="${res.imgUrl}" class="gift" alt=""></p>
|
|
|
|
|
<div>
|
2023-02-23 10:11:40 +08:00
|
|
|
|
<img src="./images/diamond.png" class="diamond" alt="">
|
2022-12-09 19:35:35 +08:00
|
|
|
|
<span class="in">${res.costPieceNum}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
});
|
|
|
|
|
$('.put-wrap .list').append(list)
|
|
|
|
|
$('.award-info .award-wrap').html(drawInfo.userDrawResult.prizeDiamonds)
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-09-08 18:22:18 +08:00
|
|
|
|
// 渲染前三名
|
|
|
|
|
topThreeArr = drawInfo.rankUserList
|
|
|
|
|
let str = ''
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (topThreeArr.length === 0) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.topthree-desc').html('本輪無人猜中')
|
2022-12-09 19:35:35 +08:00
|
|
|
|
$('.top-three-list').css('display', 'none')
|
|
|
|
|
$('.top-three').css('line-height', '4rem')
|
|
|
|
|
// $('.top-three-list p img').attr('src', './images/default-hui.png')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-12-09 19:35:35 +08:00
|
|
|
|
$('.topthree-desc').html('本輪MVP')
|
|
|
|
|
$('.top-three-list').css('display', 'block')
|
|
|
|
|
$('.top-three').css('line-height', '0rem')
|
|
|
|
|
if (topThreeArr.length < 3) {
|
|
|
|
|
let arr = new Array(3 - topThreeArr.length).fill({
|
|
|
|
|
avatar: './images/default-hui.png',
|
|
|
|
|
nick: '虚位以待',
|
|
|
|
|
uid: null,
|
|
|
|
|
num: 0
|
|
|
|
|
})
|
|
|
|
|
topThreeArr.push(...arr)
|
|
|
|
|
};
|
2022-10-22 20:08:44 +08:00
|
|
|
|
topThreeArr.map((item, index) => {
|
2022-12-09 19:35:35 +08:00
|
|
|
|
$(`.top-three-list .no${index + 1} .tx`).attr('uid', item.uid)
|
|
|
|
|
$(`.top-three-list .no${index + 1} .tx`).attr('src', item.avatar)
|
2023-03-07 11:30:20 +08:00
|
|
|
|
$(`.top-three-list .no${index + 1} .nick`).text(item.nick)
|
|
|
|
|
$(`.top-three-list .no${index + 1} .num span`).text(item.prizeDiamonds ? item.prizeDiamonds : '')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2022-12-09 19:35:35 +08:00
|
|
|
|
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 獲取每一輪抽獎的相關配置
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let listItem = []
|
2022-10-12 14:16:57 +08:00
|
|
|
|
const getListItem = (roundId, type) => {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/listItem',
|
|
|
|
|
data: {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
roundId,
|
|
|
|
|
type
|
2022-09-08 18:22:18 +08:00
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
listItem = res.data
|
|
|
|
|
renderListItem()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 2s氣泡定時器
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let timer2s
|
2022-10-22 20:08:44 +08:00
|
|
|
|
let time2sIndex = 0
|
2022-09-08 18:22:18 +08:00
|
|
|
|
const setTimeout2s = () => {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
clearTimeout(timer2s)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.bubble-2s').eq(time2sIndex).fadeIn(50)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
timer2s = setTimeout(function () {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.bubble-2s').eq(time2sIndex).fadeOut(50)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (time2sIndex >= listItem.length - 1) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
time2sIndex = 0
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
time2sIndex++;
|
|
|
|
|
}
|
|
|
|
|
setTimeout2s()
|
|
|
|
|
}, 2000)
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 渲染每一輪抽獎的選項
|
2022-09-08 18:22:18 +08:00
|
|
|
|
const renderListItem = () => {
|
|
|
|
|
let str = ''
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (modelType === 1) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
listItem.map((item) => {
|
|
|
|
|
str += `
|
|
|
|
|
<li data-total-num={"number":"${item.costPieceNum}","id":"${item.id}"}>
|
|
|
|
|
<img src="${item.imgUrl}" alt="">
|
|
|
|
|
<div class="multiple">x${item.multiple}</div>
|
|
|
|
|
<div class="name general">${item.name}</div>
|
|
|
|
|
<div class="bubble-2s">
|
2022-10-20 16:28:50 +08:00
|
|
|
|
<p class="first-line">點擊選取</p>
|
|
|
|
|
<p class="second-line">賺 <span>${item.multiple}</span> 倍獎勵</p>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="select-num">${item.costPieceNum === 0 ? '' : '+ ' + item.costPieceNum}</div>
|
|
|
|
|
</li>
|
|
|
|
|
`
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
listItem.map((item) => {
|
|
|
|
|
str += `
|
|
|
|
|
<li data-total-num={"number":"${item.costPieceNum}","id":"${item.id}"}>
|
|
|
|
|
<img src="${item.imgUrl}" alt="">
|
|
|
|
|
<div class="multiple">x${item.multiple}</div>
|
2022-10-22 20:08:44 +08:00
|
|
|
|
<div class="name">${item.name} <p class="gift-price">${item.price ? `(${item.price}鉆石)` : ''}</p></div>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
<div class="bubble-2s">
|
2022-10-20 16:28:50 +08:00
|
|
|
|
<p class="first-line">點擊選取</p>
|
|
|
|
|
<p class="second-line">賺 <span>${item.multiple}</span> 倍獎勵</p>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="select-num">${item.costPieceNum === 0 ? '' : '+ ' + item.costPieceNum}</div>
|
|
|
|
|
</li>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.game-area').find('ul').html(str)
|
|
|
|
|
setTimeout2s()
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 17:15:23 +08:00
|
|
|
|
// 獲取往輪遊戲結果
|
2022-09-08 18:22:18 +08:00
|
|
|
|
const getPreviousResults = (count, roundId) => {
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/listLuckySeaActInfo',
|
2022-10-22 20:08:44 +08:00
|
|
|
|
data: {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
count,
|
|
|
|
|
roundId
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
2023-03-06 17:15:23 +08:00
|
|
|
|
// previousResults = res.data
|
|
|
|
|
renderPreviousResults(res.data)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 渲染往輪遊戲結果
|
2023-03-06 17:15:23 +08:00
|
|
|
|
const renderPreviousResults = (val) => {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let str = ''
|
2023-03-06 17:15:23 +08:00
|
|
|
|
if (val.length < 5) {
|
|
|
|
|
let len = 5 - val.length
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let arr = new Array(len).fill(1)
|
2023-03-06 17:15:23 +08:00
|
|
|
|
val.push(...arr)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (isStatus3) {
|
|
|
|
|
if (img) {
|
2023-03-06 17:15:23 +08:00
|
|
|
|
val.pop()
|
|
|
|
|
val.unshift({
|
2022-09-08 18:22:18 +08:00
|
|
|
|
drawImageUrl: img
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-06 17:15:23 +08:00
|
|
|
|
val.forEach(res => {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
str += `
|
2023-03-06 17:15:23 +08:00
|
|
|
|
<li>
|
|
|
|
|
${res.drawItemList.map(item => {
|
|
|
|
|
if (res.drawItemList.length == 1) {
|
|
|
|
|
return `<p style="width:0.8rem;height:0.8rem"><img src="${item.drawImageUrl}" alt=""></p>`;
|
|
|
|
|
} else if (res.drawItemList.length == 2) {
|
|
|
|
|
return `<p style="width:0.6rem;height:0.6rem"><img src="${item.drawImageUrl}" alt=""></p>`;
|
|
|
|
|
} else if (res.drawItemList.length == 3) {
|
|
|
|
|
return `<p style="width:0.45rem;height:0.45rem"><img src="${item.drawImageUrl}" alt=""></p>`;
|
|
|
|
|
} else {
|
|
|
|
|
return `<p><img style="width:0.3333333333rem;height:0.3333333333rem" src="${item.drawImageUrl}" alt=""></p>`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).join('')
|
|
|
|
|
}
|
|
|
|
|
</li>
|
2022-09-08 18:22:18 +08:00
|
|
|
|
`
|
|
|
|
|
})
|
2023-03-06 17:15:23 +08:00
|
|
|
|
$('.wrap .previous_Round_Result .box ul').html(str)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 發送用戶抽獎數量
|
2022-12-15 16:00:23 +08:00
|
|
|
|
const sendUserDrawInfo = (itemId, num, tais) => {
|
2023-03-06 17:15:23 +08:00
|
|
|
|
// showLoading();
|
2022-09-08 18:22:18 +08:00
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/draw',
|
2022-12-08 18:44:05 +08:00
|
|
|
|
// contentType: 'application/json',
|
2023-03-06 17:15:23 +08:00
|
|
|
|
// data: `[{
|
2022-12-08 17:10:30 +08:00
|
|
|
|
// "itemId":${itemId},
|
|
|
|
|
// "num":${num}
|
|
|
|
|
// }]`,
|
|
|
|
|
data: { itemId, num },
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
2022-12-15 16:00:23 +08:00
|
|
|
|
tais.data('total-num').number = parseInt(tais.data('total-num').number) + fragmentNum
|
|
|
|
|
tais
|
|
|
|
|
.stop(true, true)
|
|
|
|
|
.animate({ scale: 1.1 }, 200)
|
|
|
|
|
.animate({ scale: 1 }, 200, function () {
|
|
|
|
|
if (lock) {
|
|
|
|
|
tais.find('.select-num').html('+' + tais.data('total-num').number).hide().fadeIn(200)
|
|
|
|
|
}
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// getUserInfo()
|
|
|
|
|
getUserPieceNum()
|
|
|
|
|
// getListItem(roundId)
|
|
|
|
|
}, 100)
|
|
|
|
|
})
|
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
} else if (31005) {
|
2023-02-23 11:33:00 +08:00
|
|
|
|
lock = !lock
|
2022-10-22 20:08:44 +08:00
|
|
|
|
toastMsg(res.message)
|
2022-12-15 16:00:23 +08:00
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
else {
|
2023-02-23 11:33:00 +08:00
|
|
|
|
lock = !lock
|
2022-09-08 18:22:18 +08:00
|
|
|
|
toastMsg(res.message)
|
2022-12-15 16:00:23 +08:00
|
|
|
|
hideLoading(layerIndex)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2023-02-23 11:33:00 +08:00
|
|
|
|
lock = !lock
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
2022-12-15 16:00:23 +08:00
|
|
|
|
hideLoading(layerIndex)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
/******************************************** 今日排名相關 ********************************************/
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 榜單類型,1是鉆石榜,2是歐皇榜
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let type = 1
|
|
|
|
|
|
2022-12-12 18:47:29 +08:00
|
|
|
|
let pageSize = 20
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 鉆石榜單
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let pageD = 1
|
|
|
|
|
let myInfoD = []
|
|
|
|
|
let rankListD = []
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 歐皇榜單
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let pageN = 1
|
|
|
|
|
let myInfoN = []
|
|
|
|
|
let rankListN = []
|
2022-10-22 20:08:44 +08:00
|
|
|
|
let clickTabCanNetworkN = true
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
|
|
|
|
let isLockD = true
|
|
|
|
|
let isLockN = true
|
|
|
|
|
let isLock = true
|
|
|
|
|
|
|
|
|
|
let canRequsetNextPageD = true
|
|
|
|
|
let canRequsetNextPageN = true
|
|
|
|
|
|
2022-10-22 20:08:44 +08:00
|
|
|
|
const getListRank = (type, page) => {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/act/luckySea/listRank',
|
2022-10-22 20:08:44 +08:00
|
|
|
|
data: {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
type,
|
|
|
|
|
page,
|
|
|
|
|
pageSize
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
success (res) {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
if (type === 1) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 鉆石榜單
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (res.data.rankList.length === pageSize) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 可以請求下一頁
|
2022-10-12 14:16:57 +08:00
|
|
|
|
canRequsetNextPageD = true
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 不再請求下一頁
|
2022-10-12 14:16:57 +08:00
|
|
|
|
canRequsetNextPageD = false
|
|
|
|
|
}
|
|
|
|
|
rankListD.push(...res.data.rankList)
|
|
|
|
|
myInfoD = res.data.myRankInfo
|
|
|
|
|
renderMyInfo()
|
|
|
|
|
renderRankList()
|
|
|
|
|
isLockD = true
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
if (res.data.rankList.length === pageSize) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 可以請求下一頁
|
2022-10-12 14:16:57 +08:00
|
|
|
|
canRequsetNextPageN = true
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 不再請求下一頁
|
2022-10-12 14:16:57 +08:00
|
|
|
|
canRequsetNextPageN = false
|
|
|
|
|
}
|
|
|
|
|
rankListN.push(...res.data.rankList)
|
|
|
|
|
myInfoN = res.data.myRankInfo
|
|
|
|
|
renderMyInfo()
|
|
|
|
|
renderRankList()
|
|
|
|
|
isLockN = true
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-15 16:00:23 +08:00
|
|
|
|
error (err) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
toastMsg('網絡錯誤')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 渲染底部個人信息
|
2022-10-12 14:16:57 +08:00
|
|
|
|
const renderMyInfo = () => {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (type === 1) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 鉆石榜單
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let erbanNo = myInfoD.erbanNo
|
|
|
|
|
let myIndex = rankListD.findIndex((item, index) => {
|
|
|
|
|
return item.erbanNo === erbanNo
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (myIndex === -1) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.mine-rank').html('未上榜')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.mine-rank').html(myIndex + 1)
|
|
|
|
|
}
|
|
|
|
|
$('.mine-info').find('img').attr('src', myInfoD.avatar)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (myInfoD.nick) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
myInfoD.nick.length > 5 ? myInfoD.nick.slice(0, 5) + '...' : myInfoD.nick
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
myInfoD.nick = '未知'
|
|
|
|
|
}
|
|
|
|
|
$('.mine-info').find('.mine-nick').html(myInfoD.nick)
|
|
|
|
|
let tostr = myInfoD.num.toString()
|
|
|
|
|
let num
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (tostr.length >= 5) {
|
|
|
|
|
num = (myInfoD.num / 10000).toFixed(2) + 'w'
|
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
num = myInfoD.num
|
|
|
|
|
}
|
2022-12-12 18:14:56 +08:00
|
|
|
|
// $('.mine-diamond-num').html('今日獎勵' + num)
|
|
|
|
|
$('.mine-diamond-num').html(num)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let erbanNo = myInfoN.erbanNo
|
|
|
|
|
let myIndex = rankListN.findIndex((item, index) => {
|
|
|
|
|
return item.erbanNo === erbanNo
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (myIndex === -1) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.mine-rank').html('未上榜')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.mine-rank').html(myIndex + 1)
|
|
|
|
|
}
|
|
|
|
|
$('.mine-info').find('img').attr('src', myInfoN.avatar)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (myInfoN.nick) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
myInfoN.nick.length > 5 ? myInfoN.nick.slice(0, 5) + '...' : myInfoN.nick
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
myInfoN.nick = '未知'
|
|
|
|
|
}
|
|
|
|
|
$('.mine-info').find('.mine-nick').html(myInfoN.nick)
|
2023-03-06 17:15:23 +08:00
|
|
|
|
$('.mine-diamond-num').html('猜中<b> ' + myInfoN.num + ' </b>次')
|
2022-10-12 14:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 渲染榜單信息
|
2022-10-12 14:16:57 +08:00
|
|
|
|
const renderRankList = () => {
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (type === 1) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 鉆石榜單
|
2022-10-12 14:16:57 +08:00
|
|
|
|
// 渲染前3
|
|
|
|
|
let topThreeArr = rankListD.slice(0, 1)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (rankListD.length === 0) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let len = 1 - rankListD.length
|
|
|
|
|
let arr = new Array(len).fill({
|
|
|
|
|
nick: '虛位以待',
|
|
|
|
|
avatar: './images/default.png',
|
|
|
|
|
num: ''
|
|
|
|
|
})
|
|
|
|
|
topThreeArr.push(...arr)
|
|
|
|
|
}
|
|
|
|
|
let topThreeStr = ''
|
|
|
|
|
topThreeArr.map((item) => {
|
|
|
|
|
let tostr = item.num.toString()
|
|
|
|
|
let num
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (tostr.length >= 5) {
|
|
|
|
|
num = (item.num / 10000).toFixed(2) + 'w'
|
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
num = item.num
|
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
2022-10-12 14:16:57 +08:00
|
|
|
|
topThreeStr = `
|
2022-12-12 17:55:15 +08:00
|
|
|
|
<div class="info-wrap" uid="${item.uid}">
|
2022-10-12 14:16:57 +08:00
|
|
|
|
<div class="avatar">
|
|
|
|
|
<p></p>
|
|
|
|
|
<img src="${item.avatar}" alt="">
|
|
|
|
|
</div>
|
|
|
|
|
<p class="diamond-num">${num}</p>
|
2022-10-22 20:08:44 +08:00
|
|
|
|
<p class="nick">${item.nick.length > 5 ? item.nick.slice(0, 5) + '...' : item.nick}</p>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
$('.topthree-wrap').html(topThreeStr)
|
2022-12-12 17:55:15 +08:00
|
|
|
|
$('.topthree-wrap .info-wrap').click(function () {
|
|
|
|
|
let uid = $(this).attr('uid')
|
|
|
|
|
openPerson(uid)
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
|
|
|
|
// 渲染非前3
|
|
|
|
|
let othersArr = rankListD.slice(1)
|
|
|
|
|
let others = ''
|
|
|
|
|
othersArr.map((item, index) => {
|
|
|
|
|
let tostr = item.num.toString()
|
|
|
|
|
let num
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (tostr.length >= 5) {
|
|
|
|
|
num = (item.num / 10000).toFixed(2) + 'w'
|
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
num = item.num
|
|
|
|
|
}
|
|
|
|
|
others += `
|
2022-12-12 17:55:15 +08:00
|
|
|
|
<li uid="${item.uid}">
|
2022-10-22 20:08:44 +08:00
|
|
|
|
<span class="index">${index + 2}</span>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
<div class="others-info">
|
|
|
|
|
<img src="${item.avatar}" alt="">
|
2022-10-22 20:08:44 +08:00
|
|
|
|
<span class="others-nick">${item.nick.length > 5 ? item.nick.slice(0, 5) + '...' : item.nick}</span>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
</div>
|
2022-12-12 18:14:56 +08:00
|
|
|
|
<span class="others-diamond-num">${num}</span>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
</li>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
$('.other-rank').html(others)
|
2022-12-15 16:00:23 +08:00
|
|
|
|
$('.other-rank li').click(function () {
|
2022-12-12 17:55:15 +08:00
|
|
|
|
let uid = $(this).attr('uid')
|
|
|
|
|
openPerson(uid)
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 歐皇榜單
|
2022-10-12 14:16:57 +08:00
|
|
|
|
// 渲染前3
|
|
|
|
|
let topThreeArr = rankListN.slice(0, 1)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (rankListN.length === 0) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
let len = 1 - rankListN.length
|
|
|
|
|
let arr = new Array(len).fill({
|
|
|
|
|
nick: '虛位以待',
|
|
|
|
|
avatar: './images/default.png'
|
|
|
|
|
})
|
|
|
|
|
topThreeArr.push(...arr)
|
|
|
|
|
}
|
|
|
|
|
let topThreeStr = ''
|
|
|
|
|
topThreeArr.map((item) => {
|
|
|
|
|
let num = ''
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (item.erbanNo) {
|
|
|
|
|
num = '猜中' + item.num + '次'
|
2022-10-12 14:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
topThreeStr = `
|
2022-12-12 17:55:15 +08:00
|
|
|
|
<div class="info-wrap" uid="${item.uid}">
|
2022-10-12 14:16:57 +08:00
|
|
|
|
<div class="avatar">
|
|
|
|
|
<p></p>
|
|
|
|
|
<img src="${item.avatar}" alt="">
|
|
|
|
|
</div>
|
|
|
|
|
<p class="diamond-num" style="display:block">${num}</p>
|
2022-10-22 20:08:44 +08:00
|
|
|
|
<p class="nick">${item.nick.length > 5 ? item.nick.slice(0, 5) + '...' : item.nick}</p>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
$('.topthree-wrap').html(topThreeStr)
|
2022-12-12 17:55:15 +08:00
|
|
|
|
$('.topthree-wrap .info-wrap').click(function () {
|
|
|
|
|
let uid = $(this).attr('uid')
|
|
|
|
|
openPerson(uid)
|
|
|
|
|
})
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
|
|
|
|
// 渲染非前3
|
|
|
|
|
let othersArr = rankListN.slice(1)
|
|
|
|
|
console.log(othersArr);
|
|
|
|
|
let others = ''
|
|
|
|
|
othersArr.map((item, index) => {
|
|
|
|
|
let num
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (item.erbanNo) {
|
2023-03-06 17:15:23 +08:00
|
|
|
|
num = '猜中<b> ' + item.num + ' </b>次'
|
2022-10-12 14:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
others += `
|
2022-12-12 17:55:15 +08:00
|
|
|
|
<li uid="${item.uid}">
|
2022-10-22 20:08:44 +08:00
|
|
|
|
<span class="index">${index + 2}</span>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
<div class="others-info">
|
|
|
|
|
<img src="${item.avatar}" alt="">
|
2022-10-22 20:08:44 +08:00
|
|
|
|
<span class="others-nick">${item.nick.length > 5 ? item.nick.slice(0, 5) + '...' : item.nick}</span>
|
2022-10-12 14:16:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
<span class="others-diamond-num">${num}</span>
|
|
|
|
|
</li>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
$('.other-rank').html(others)
|
2022-12-15 16:00:23 +08:00
|
|
|
|
$('.other-rank li').click(function () {
|
2022-12-12 17:55:15 +08:00
|
|
|
|
let uid = $(this).attr('uid')
|
|
|
|
|
openPerson(uid)
|
|
|
|
|
})
|
2022-10-12 14:16:57 +08:00
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
2022-10-12 14:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-12 17:55:15 +08:00
|
|
|
|
//跳转个人主页
|
2022-12-15 16:00:23 +08:00
|
|
|
|
function openPerson (uid) {
|
2022-12-12 17:55:15 +08:00
|
|
|
|
console.log('跳转个人主页方法');
|
|
|
|
|
if (!browser.app) return
|
|
|
|
|
if (browser.ios) {
|
|
|
|
|
window.webkit.messageHandlers.openPersonPage.postMessage(uid);
|
|
|
|
|
} else if (browser.android) {
|
|
|
|
|
if (androidJsObj && typeof androidJsObj === 'object') {
|
|
|
|
|
window.androidJsObj.openPersonPage(uid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$(function () {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
getInfoFromClient()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
setTimeout(function () {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
// getUserInfo()
|
2022-10-12 14:16:57 +08:00
|
|
|
|
getGameMode()
|
|
|
|
|
// getNewestAct()
|
2022-09-08 18:22:18 +08:00
|
|
|
|
// getListItem()
|
2022-10-28 11:29:03 +08:00
|
|
|
|
$('.recharge').click(function () {
|
|
|
|
|
// if (browser.app) {
|
|
|
|
|
// if (browser.ios) {
|
|
|
|
|
// window.location.href = 'https://api.pekolive.com/peko/modules/pay/index.html?channelType=4';
|
|
|
|
|
// } else {
|
|
|
|
|
// if (browser.android) {
|
|
|
|
|
// let channel = pubInfo.deviceInfo.channel
|
|
|
|
|
// console.log(channel);
|
|
|
|
|
// if (channel.search('official') != -1) {
|
|
|
|
|
// window.androidJsObj.openChargePage();
|
|
|
|
|
// } else if (channel.search('official') != -1) {
|
|
|
|
|
// window.androidJsObj.openChargePage();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (browser.app) {
|
|
|
|
|
if (browser.android) {
|
2022-12-09 19:35:35 +08:00
|
|
|
|
window.androidJsObj.openChargePage(6);
|
2022-10-28 11:29:03 +08:00
|
|
|
|
} else if (browser.ios) {
|
2022-12-09 19:35:35 +08:00
|
|
|
|
window.webkit.messageHandlers.chargePayClickPage.postMessage(6);
|
2022-10-28 11:29:03 +08:00
|
|
|
|
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-03-06 17:15:23 +08:00
|
|
|
|
// getPreviousResults(20, roundId)
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}, 50)
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 監聽按鈕點擊事件
|
2022-09-08 18:22:18 +08:00
|
|
|
|
// let fragmentNum
|
|
|
|
|
// let isSelectTab = false
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.btn-wrap').on('click', 'div', function () {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$(this).addClass('active').siblings().removeClass('active')
|
2022-10-12 14:16:57 +08:00
|
|
|
|
fragmentNum = parseInt($(this).html())
|
2022-09-08 18:22:18 +08:00
|
|
|
|
isSelectTab = true
|
|
|
|
|
sessionStorage.setItem("mySelect", $(this).index())
|
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 監聽規則按鈕點擊事件
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.rule').on('click', function () {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.shade-mask').show()
|
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 關閉規則彈窗
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.shade-mask').on('click', function () {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$(this).hide()
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.shade-content').on('click', function (e) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
e.stopPropagation()
|
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 跳轉特權商城
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.mall').on('click', function () {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
window.location.href = './mall.html'
|
|
|
|
|
})
|
2022-12-10 18:25:58 +08:00
|
|
|
|
// +按钮跳转充值
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.add').on('click', function () {
|
2022-12-10 18:25:58 +08:00
|
|
|
|
if (browser.app) {
|
|
|
|
|
if (browser.android) {
|
|
|
|
|
let channel = pubInfo.deviceInfo.channel;
|
|
|
|
|
console.log(pubInfo.deviceInfo);
|
|
|
|
|
if (channel == "google") {
|
|
|
|
|
window.androidJsObj.openChargePage(6);
|
|
|
|
|
} else {
|
|
|
|
|
window.androidJsObj.openChargePage(6);
|
|
|
|
|
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
|
|
|
|
}
|
|
|
|
|
} else if (browser.ios) {
|
|
|
|
|
window.webkit.messageHandlers.chargePayClickPage.postMessage(6);
|
|
|
|
|
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
toastMsg('請在app內打開')
|
|
|
|
|
}
|
2022-10-12 14:16:57 +08:00
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 監聽遊戲記錄按鈕點擊事件
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.record').on('click', function () {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
window.location.href = './record.html'
|
|
|
|
|
})
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-12-08 17:10:30 +08:00
|
|
|
|
// 监听历史开奖记录按钮点击事件
|
|
|
|
|
$('.more-result').on('click', function () {
|
|
|
|
|
window.location.href = './result.html?roundId=' + roundId
|
|
|
|
|
})
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 監聽今日排名按鈕點擊事件
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.rank').on('click', function () {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
getListRank(type, pageD)
|
|
|
|
|
$('.shade-mask-rank').show()
|
2022-09-08 18:22:18 +08:00
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 監聽今日排名tab
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.tab-wrap').on('click', 'span', function () {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$(this).addClass('active').siblings().removeClass('active')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (type === $(this).index() + 1) return
|
2022-10-12 14:16:57 +08:00
|
|
|
|
type = $(this).index() + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.other-rank').scrollTop(0)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (type === 1) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
renderRankList()
|
|
|
|
|
renderMyInfo()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
if (clickTabCanNetworkN) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
getListRank(type, pageN)
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
renderRankList()
|
|
|
|
|
renderMyInfo()
|
|
|
|
|
}
|
|
|
|
|
clickTabCanNetworkN = false
|
|
|
|
|
}
|
2022-09-08 18:22:18 +08:00
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 關閉排名彈窗
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.shade-mask-rank').on('click', function () {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$(this).hide()
|
|
|
|
|
type = 1
|
|
|
|
|
pageD = 1
|
|
|
|
|
pageN = 1
|
|
|
|
|
myInfoD = []
|
|
|
|
|
myInfoN = []
|
|
|
|
|
rankListD = []
|
|
|
|
|
rankListN = []
|
|
|
|
|
clickTabCanNetworkN = true
|
|
|
|
|
$('.diamond-rank').addClass('active').siblings('.num-rank').removeClass('active')
|
|
|
|
|
$('.other-rank').html('')
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.shade-content-rank').on('click', function (e) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
e.stopPropagation()
|
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 監聽滾動
|
2022-12-12 18:47:29 +08:00
|
|
|
|
// $('.other-rank').on('scroll', function () {
|
|
|
|
|
// let scrollTop = $(this).scrollTop();//這是已經卷進去滾動條的的高度
|
|
|
|
|
// let scrollHeight = $('.other-rank')[0].scrollHeight;//這個是other-rank包含滾動條的總高度
|
|
|
|
|
// let ulHeight = $(this).innerHeight();//這個是other-rank的高度
|
|
|
|
|
|
|
|
|
|
// //這樣距離到底還有一段距離就請求,但是會導致重復請求,所以要加鎖限製
|
|
|
|
|
// if (scrollTop + ulHeight + 100 >= scrollHeight) {
|
|
|
|
|
// if (type === 1) {
|
|
|
|
|
// if (isLockD) {
|
|
|
|
|
// isLockD = false
|
|
|
|
|
// pageD++
|
|
|
|
|
// if (pageSize * pageD > 30) {
|
|
|
|
|
// toastMsg('沒有更多數據啦~')
|
|
|
|
|
// } else {
|
|
|
|
|
// if (canRequsetNextPageD) {
|
|
|
|
|
// getListRank(type, pageD);
|
|
|
|
|
// } else {
|
|
|
|
|
// toastMsg('沒有更多數據啦~')
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// if (scrollTop + ulHeight >= scrollHeight) {
|
|
|
|
|
// if (pageSize * pageD > 30) {
|
|
|
|
|
// toastMsg('沒有更多數據啦~')
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
// if (isLockN) {
|
|
|
|
|
// isLockN = false
|
|
|
|
|
// pageN++
|
|
|
|
|
// if (pageSize * pageN > 30) {
|
|
|
|
|
// toastMsg('沒有更多數據啦~')
|
|
|
|
|
// } else {
|
|
|
|
|
// if (canRequsetNextPageN) {
|
|
|
|
|
// getListRank(type, pageN);
|
|
|
|
|
// } else {
|
|
|
|
|
// toastMsg('沒有更多數據啦')
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// if (scrollTop + ulHeight >= scrollHeight) {
|
|
|
|
|
// if (pageSize * pageN > 30) {
|
|
|
|
|
// toastMsg('沒有更多數據啦~')
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 播放3s動畫
|
2022-12-09 19:35:35 +08:00
|
|
|
|
// let player1 = new SVGA.Player('.draw-time');
|
|
|
|
|
// let parser1 = new SVGA.Parser('.draw-time');
|
|
|
|
|
// parser1.load('./images/draw.svga', function (videoItem) {
|
|
|
|
|
// // player.loops = 2;
|
|
|
|
|
// player1.clearsAfterStop = false;
|
|
|
|
|
// player1.setVideoItem(videoItem);
|
|
|
|
|
// player1.startAnimation();
|
|
|
|
|
// })
|
2022-12-10 10:46:06 +08:00
|
|
|
|
// 点击跳转个人主页
|
|
|
|
|
// $('.draw-time .top-three .top-three-list .no').off()
|
|
|
|
|
$('.draw-time .top-three .top-three-list .no').click(function () {
|
|
|
|
|
let uid = $(this).find('.tx').attr('uid');
|
|
|
|
|
console.log('uid', uid);
|
|
|
|
|
openPerson(uid)
|
|
|
|
|
})
|
2022-10-12 14:16:57 +08:00
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 關閉碎片不足提示彈窗
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.cancel-btn').on('click', function () {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.shade-mask-fragmentNum').hide()
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.shade-mask-fragmentNum').on('click', function () {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$(this).hide()
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.shade-content-fragmentNum').on('click', function (e) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
e.stopPropagation()
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.confirm-btn').on('click', function () {
|
|
|
|
|
// window.location.href = './mall.html'
|
|
|
|
|
if (browser.app) {
|
|
|
|
|
if (browser.android) {
|
2022-10-22 20:16:36 +08:00
|
|
|
|
let channel = pubInfo.deviceInfo.channel;
|
2022-10-22 20:08:44 +08:00
|
|
|
|
console.log(pubInfo.deviceInfo);
|
|
|
|
|
if (channel == "google") {
|
2022-12-10 18:25:58 +08:00
|
|
|
|
window.androidJsObj.openChargePage(6);
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else {
|
2022-12-10 18:25:58 +08:00
|
|
|
|
window.androidJsObj.openChargePage(6);
|
2022-10-22 20:16:36 +08:00
|
|
|
|
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
2022-10-22 20:08:44 +08:00
|
|
|
|
}
|
|
|
|
|
} else if (browser.ios) {
|
2022-12-10 18:25:58 +08:00
|
|
|
|
window.webkit.messageHandlers.chargePayClickPage.postMessage(6);
|
2022-10-22 20:08:44 +08:00
|
|
|
|
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-10-22 20:25:30 +08:00
|
|
|
|
toastMsg('請在app內打開')
|
2022-10-22 20:08:44 +08:00
|
|
|
|
}
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.shade-mask-fragmentNum').hide()
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// 點擊海鮮動物的動畫以及發送請求
|
2022-10-22 20:08:44 +08:00
|
|
|
|
$('.select-time ul').on('click', 'li', function () {
|
|
|
|
|
if (!isSelectTab) {
|
2022-10-20 16:28:50 +08:00
|
|
|
|
return toastMsg('請先選擇碎片數量')
|
2022-10-12 14:16:57 +08:00
|
|
|
|
}
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (myFragment < fragmentNum) {
|
2022-10-12 14:16:57 +08:00
|
|
|
|
$('.shade-mask-fragmentNum').show()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
// toastMsg('鉆石余額不足');
|
2022-10-12 14:16:57 +08:00
|
|
|
|
return
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
2022-10-20 16:28:50 +08:00
|
|
|
|
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (!lock) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
lock = !lock
|
2022-12-15 16:00:23 +08:00
|
|
|
|
// console.log($(this).data('total-num'));
|
|
|
|
|
// console.log($(this).data('total-num').number);
|
|
|
|
|
// console.log(fragmentNum);
|
|
|
|
|
// $(this).data('total-num').number = parseInt($(this).data('total-num').number) + fragmentNum
|
|
|
|
|
// $(this)
|
|
|
|
|
// .stop(true, true)
|
|
|
|
|
// .animate({ scale: 1.1 }, 200)
|
|
|
|
|
// .animate({ scale: 1 }, 200, function () {
|
|
|
|
|
// if (lock) {
|
|
|
|
|
// $(this).find('.select-num').html('+' + $(this).data('total-num').number).hide().fadeIn(200)
|
|
|
|
|
// }
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// // getUserInfo()
|
|
|
|
|
// getUserPieceNum()
|
|
|
|
|
// // getListItem(roundId)
|
|
|
|
|
// }, 100)
|
|
|
|
|
// })
|
|
|
|
|
sendUserDrawInfo($(this).data('total-num').id, fragmentNum, $(this))
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
2022-10-22 20:08:44 +08:00
|
|
|
|
|
2022-10-20 16:28:50 +08:00
|
|
|
|
// ios去到後臺或者鎖屏後再回來倒計時不準確
|
2022-09-08 18:22:18 +08:00
|
|
|
|
let leftTime, deltaTime, startTime, endTime
|
2022-10-22 20:08:44 +08:00
|
|
|
|
document.addEventListener('visibilitychange', function () {
|
|
|
|
|
if (document.visibilityState == 'hidden') {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
leftTime = countDownTime
|
|
|
|
|
startTime = new Date().getTime()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
} else if (document.visibilityState == 'visible') {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
endTime = new Date().getTime()
|
2022-10-22 20:08:44 +08:00
|
|
|
|
deltaTime = Math.floor((endTime - startTime) / 1000) //出去了多久
|
|
|
|
|
if (deltaTime > 300) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
window.location.reload()
|
|
|
|
|
}
|
|
|
|
|
countDownTime = leftTime - deltaTime
|
2022-10-22 20:08:44 +08:00
|
|
|
|
if (countDownTime < 0) {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
countDownTime = 0
|
|
|
|
|
}
|
|
|
|
|
$countDown.html(countDownTime)
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-10-20 16:28:50 +08:00
|
|
|
|
})
|