244 lines
8.6 KiB
JavaScript
244 lines
8.6 KiB
JavaScript
let urlPrefix = getUrlPrefix()
|
|
let browser = checkVersion()
|
|
let env = EnvCheck();
|
|
if (env == 'test') {
|
|
new VConsole();
|
|
}
|
|
// 封裝layer消息提醒框
|
|
let layerIndex
|
|
var langReplace;
|
|
var localLang;
|
|
const showLoading = (content = langReplace(localLang.demoModule.layerIndex1)) => {
|
|
layer.open({
|
|
type: 2,
|
|
shadeClose: false,
|
|
content,
|
|
success(e) {
|
|
layerIndex = $(e).attr('index')
|
|
}
|
|
})
|
|
}
|
|
const hideLoading = (index) => {
|
|
layer.close(index)
|
|
}
|
|
const toastMsg = (content = langReplace(localLang.demoModule.layerIndex2), time = 2) => {
|
|
layer.open({
|
|
content,
|
|
time,
|
|
skin: 'msg'
|
|
})
|
|
}
|
|
// 初始化函數
|
|
$(function () {
|
|
getInfoFromClient();
|
|
fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言
|
|
setTimeout(function () {
|
|
// 頁面全屏
|
|
if (browser.app) {
|
|
if (browser.android) {
|
|
window.androidJsObj.initShowNav(false)
|
|
} else {
|
|
window.webkit.messageHandlers.initShowNav.postMessage(0)
|
|
}
|
|
};
|
|
// 頂部返回事件
|
|
$('.back .backs').click(() => {
|
|
window.history.back();
|
|
})
|
|
fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言
|
|
langReplace = window.lang.replace;
|
|
localLang = window.lang;
|
|
translateFun();
|
|
getTimeBoxData();
|
|
getGuildGame();
|
|
}, 100)
|
|
})
|
|
function translateFun() {
|
|
var langReplace = window.lang.replace;
|
|
var localLang = window.lang;
|
|
$('.Game_salary').text(langReplace(localLang.GameSalary.Game_salary));
|
|
$('.Enter_account').text(langReplace(localLang.GameSalary.Enter_account));
|
|
$('.Received_salary').text(langReplace(localLang.GameSalary.Received_salary));
|
|
$('.Game_Times').text(langReplace(localLang.GameSalary.Game_Times));
|
|
$('.Daily_data').text(langReplace(localLang.GameSalary.Daily_data));
|
|
$('.Salary').text(langReplace(localLang.GameSalary.Salary));
|
|
$('.Receive').text(langReplace(localLang.GameSalary.Receive));
|
|
$('.Received').text(langReplace(localLang.GameSalary.Received));
|
|
$('.Expired').text(langReplace(localLang.GameSalary.Expired));
|
|
$('.Confirm').text(langReplace(localLang.GameSalary.Confirm));
|
|
$('.Received_successfully').text(langReplace(localLang.GameSalary.Received_successfully));
|
|
|
|
}
|
|
function getGuildGame() {
|
|
showLoading()
|
|
networkRequest({
|
|
type: 'get',
|
|
url: urlPrefix + '/guildGameUsd/info',
|
|
data: {
|
|
monthDate: timeDate
|
|
},
|
|
success(res) {
|
|
if (res.code === 200) {
|
|
let Resultados = res.data;
|
|
$('.user_info .avatar img').attr('src', Resultados.avatar)
|
|
$('.user_info .info .nick').text(Resultados.nick)
|
|
$('.user_info .info .erbanNo').text(`ID: ${Resultados.erbanNo}`)
|
|
$('.salary_num .num').text(Resultados.gameSalary+ ' ÜS')
|
|
$('.info_salary .receivedSalary').text(Resultados.gameDayVo.receivedSalary+ ' ÜS')
|
|
$('.info_salary .totalPlayGameNum').text(Resultados.gameDayVo.totalPlayGameNum)
|
|
// 每日数据
|
|
$('.Daily_dataBox .content_list .content_box').remove();
|
|
let str = ''
|
|
// <div class="Go_game" style='display:${item.receiveStatus == 4 ? '' : 'none'}'></div>
|
|
Resultados.gameDayVo.dayDetailList.forEach((item, index) => {
|
|
str += `
|
|
<div class="content_box">
|
|
<div class="felx_box">
|
|
<span class="creat_time">${item.statDate}</span>
|
|
<div class="${item.receiveStatus == 0 ? 'Receive' : item.receiveStatus == 1 ? 'Received' : item.receiveStatus == 2?'Expired':'Claim'} Expired_btn" style='display:${item.receiveStatus != 3 ? '' : 'none'}' daySalary='${item.daySalary}' statDate='${item.statDate}' guildMemberId='${Resultados.guildMemberId}'></div>
|
|
</div>
|
|
<div class="felx_box">
|
|
<span class="Salary"></span>
|
|
<span class="num">${item.daySalary + ' ÜS'}</span>
|
|
</div>
|
|
<div class="felx_box">
|
|
<span class="Game_name"></span>
|
|
<span class="num">Ludo</span>
|
|
</div>
|
|
<div class="felx_box">
|
|
<span class="Game_Times"></span>
|
|
<span class="num">${item.playGameNum}</span>
|
|
</div>
|
|
</div>
|
|
`
|
|
})
|
|
$('.Daily_dataBox .content_list').append(str);
|
|
$('.Game_Times').text(langReplace(localLang.GameSalary.Game_Times));
|
|
$('.Game_name').text(langReplace(localLang.GameSalary.Game_name));
|
|
$('.Salary').text(langReplace(localLang.GameSalary.Salary));
|
|
$('.Go_game').text(langReplace(localLang.GameSalary.Go_game));
|
|
$('.Receive').text(langReplace(localLang.GameSalary.Receive));
|
|
$('.Received').text(langReplace(localLang.GameSalary.Received));
|
|
$('.Expired').text(langReplace(localLang.GameSalary.Expired));
|
|
$('.Claim').text(langReplace(localLang.GameSalary.Receive));
|
|
|
|
|
|
} else {
|
|
toastMsg(res.message)
|
|
}
|
|
hideLoading(layerIndex)
|
|
},
|
|
error(err) {
|
|
hideLoading(layerIndex)
|
|
toastMsg(langReplace(localLang.demoModule.layerIndex3))
|
|
}
|
|
})
|
|
}
|
|
// 领取薪资
|
|
$('.Daily_dataBox .content_list').on('click', '.content_box .Receive', function () {
|
|
let daySalary = $(this).attr('daysalary')
|
|
let statDate = $(this).attr('statDate')
|
|
let guildMemberId = $(this).attr('guildMemberId')
|
|
showLoading()
|
|
networkRequest({
|
|
type: 'post',
|
|
url: urlPrefix + '/guildGameUsd/receive',
|
|
data: {
|
|
usd :daySalary,
|
|
statDate,
|
|
guildMemberId
|
|
},
|
|
success(res) {
|
|
if (res.code === 200) {
|
|
$('.popup_tip .popup_content .content').html(langReplace(localLang.GameSalary.You_count(daySalary)))
|
|
bodyScroolFun(true);
|
|
$('.popup_tip').show();
|
|
getGuildGame();
|
|
} else {
|
|
toastMsg(res.message)
|
|
}
|
|
hideLoading(layerIndex)
|
|
},
|
|
error(err) {
|
|
hideLoading(layerIndex)
|
|
toastMsg(langReplace(localLang.demoModule.layerIndex3))
|
|
}
|
|
})
|
|
})
|
|
// 前往游戏
|
|
$('.Daily_dataBox .content_list').on('click', '.content_box .Go_game', function () {
|
|
if (browser.android) {
|
|
if (androidJsObj && typeof androidJsObj === 'object') {
|
|
window.androidJsObj.showHomeGameDialog();
|
|
}
|
|
}
|
|
})
|
|
|
|
// 关闭弹窗
|
|
$('.popup_tip .popup_content .tip_btn').click(function () {
|
|
bodyScroolFun(false);
|
|
$('.popup_tip').hide();
|
|
});
|
|
|
|
// 选择开始时间
|
|
$('.info_salary .time_box').click(function () {
|
|
bodyScroolFun(true);
|
|
$('.timeBox').show();
|
|
})
|
|
$('.timeBox').click(function () {
|
|
bodyScroolFun(false);
|
|
$('.timeBox').toggle();
|
|
})
|
|
var timeDate;
|
|
// 选择时间
|
|
$('.timeBox .timeBox_in ul').on('click', 'li', function (event) {
|
|
event.stopPropagation();
|
|
var time = $(this).text();
|
|
$(this).addClass('act').siblings().removeClass('act');
|
|
timeDate = time;
|
|
})
|
|
// 确认时间按钮
|
|
$('.timeBox .timeBox_in .but').click(function (event) {
|
|
event.stopPropagation();
|
|
$('.info_salary .time_box .time').text(timeDate);
|
|
bodyScroolFun(false);
|
|
$('.timeBox').hide();
|
|
getGuildGame();
|
|
// pageNo = 1;
|
|
// AgencyList = [];
|
|
// getData();
|
|
})
|
|
// 薪资账户
|
|
$('.Enter_account').click(function (params) {
|
|
window.location.href = `./salary_game_account.html`
|
|
return
|
|
})
|
|
function getTimeBoxData() {
|
|
// 使用示例
|
|
const lastThreeMonths = getLastThreeMonths();
|
|
var str = '';
|
|
lastThreeMonths.forEach(res => {
|
|
str += `
|
|
<li>${res}</li>
|
|
`
|
|
})
|
|
$('.timeBox .timeBox_in ul').append(str);
|
|
$('.info_salary .time_box .time').text(lastThreeMonths[lastThreeMonths.length - 1]);
|
|
timeDate = lastThreeMonths[lastThreeMonths.length - 1];
|
|
}
|
|
// 获取当前月份及前两个月的 yyyy-MM 格式
|
|
function getLastThreeMonths() {
|
|
const months = [];
|
|
const now = new Date();
|
|
|
|
// 获取当前月份
|
|
for (let i = 2; i >= 0; i--) {
|
|
const date = new Date(now.getFullYear(), now.getMonth() - i, 1);
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
months.push(`${year}-${month}`);
|
|
}
|
|
|
|
return months;
|
|
}
|