Files
eparty-h5/view/eparty/modules/newRank/js/monthlyRewards.js
2025-07-01 14:08:09 +08:00

256 lines
9.1 KiB
JavaScript

let urlPrefix = getUrlPrefix()
let browser = checkVersion()
let env = EnvCheck();
if (env == 'test') {
new VConsole();
}
// 封裝layer消息提醒框
let layerIndex
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'
})
}
var listType = 2;//2爱意榜 1魅力榜 3房间榜
var timeType = 1;//1日 2周
// 初始化函數
$(function () {
getInfoFromClient();
fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言
setTimeout(function () {
// 頁面全屏
if (browser.app) {
if (browser.android) {
window.androidJsObj.initShowNav(false)
} else {
window.webkit.messageHandlers.initShowNav.postMessage(0)
}
};
// 頂部返回事件
$('.back img').click(() => {
window.history.back();
})
langReplace = window.lang.replace;
localLang = window.lang;
translateFun();
showLoading()
geth5()
}, 100)
})
function translateFun() {
var langReplace = window.lang.replace;
var localLang = window.lang;
$('.text1').html(langReplace(localLang.demoModule.text1));
$('.text2').html(langReplace(localLang.demoModule.text2));
$('.text3').html(langReplace(localLang.demoModule.text3));
$('.text4').html(langReplace(localLang.demoModule.text4));
$('.text5').html(langReplace(localLang.demoModule.text5));
$('.text6').html(langReplace(localLang.demoModule.text6));
$('.newText1').html(langReplace(localLang.demoModule.newText1));
$('.newText2').html(langReplace(localLang.demoModule.newText2));
$('.newText22').html(langReplace(localLang.demoModule.newText22));
$('.newText3').html(langReplace(localLang.demoModule.newText3));
$('.newText4').html(langReplace(localLang.demoModule.newText4));
$('.newText5').html(langReplace(localLang.demoModule.newText5));
$('.newText6').html(langReplace(localLang.demoModule.newText6));
$('.newText7').html(langReplace(localLang.demoModule.newText7));
}
var partitionId;
// 榜单接口
function geth5() {
$('ul li').remove();
$('.header .sTab').show();
$('.my').show()
$('.header .top .top2 .score,.header .top .top3 .score').show();
// $('.header .top .top1 .fist').show();
$('.header .top .top1 .fist').hide();
$('ul li .score').show();
// showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '/allrank/geth5',
data: {
type: listType,
datetype: 5,
periodType: 2,
uid: pubInfo.uid
},
success(res) {
if (res.code === 200) {
var my = res.data.me;
var listTo3 = res.data.rankVoList.slice(0, 3);
var notListTo3 = res.data.rankVoList.slice(3);
partitionId = res.data.partitionId;
var currentTabIndex = $('.header .tabBox div.act').index() + 1;
// if (partitionId == 16 && currentTabIndex == 1) {
// $('.rewards').removeClass('reward1');
// $('.rewards').addClass('newreward1');
// }
// 处理前三
if (listTo3.length < 3) {
let arr = new Array(3 - listTo3.length).fill({
avatar: './images/logo.png',
nick: langReplace(localLang.demoModule.newText7),
diffNum: "",
uid: "0",
})
listTo3.push(...arr)
}
listTo3.forEach((res, i) => {
$(`.header .top .top${i + 1} .ts`).attr('uid', res.uid);
$(`.header .top .top${i + 1} .tx`).attr('src', res.avatar);
$(`.header .top .top${i + 1} .nick`).text(res.nick);
// if (i > 0) {
$(`.header .top .top${i + 1} .score span`).text(unitProcessingAr(res.diffNum, 1));
// }
});
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error(err) {
hideLoading(layerIndex)
toastMsg(langReplace(localLang.demoModule.layerIndex3))
}
})
}
// 公会接口
function listRank(type) {
$('ul li').remove();
$('.header .sTab').hide();
$('.my').hide()
// $('.header .top .top2 .score,.header .top .top3 .score').hide();
$('.header .top .top1 .fist').hide();
$('ul li .score').hide();
// showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '/clan/listRank',
data: {
periodType: 2,
},
success(res) {
if (res.code === 200) {
var my = res.data.me;
// if(partitionId == 16) return
var listTo3 = res.data.slice(0, 3);
var notListTo3 = res.data.slice(3);
notListTo3 = notListTo3.slice(0, 27)
// 处理前三
if (listTo3.length < 3) {
let arr = new Array(3 - listTo3.length).fill({
avatar: './images/logo.png',
name: langReplace(localLang.demoModule.newText7),
diffNum: "",
uid: "0",
})
listTo3.push(...arr)
}
listTo3.forEach((res, i) => {
$(`.header .top .top${i + 1} .ts`).attr('uid', res.clanElderUid);
$(`.header .top .top${i + 1} .tx`).attr('src', res.avatar);
$(`.header .top .top${i + 1} .nick`).text(res.name);
// if (i > 0) {
$(`.header .top .top${i + 1} .score span`).text(unitProcessingAr(res.diffNum, 1));
// }
});
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error(err) {
hideLoading(layerIndex)
toastMsg(langReplace(localLang.demoModule.layerIndex3))
}
})
}
// 榜单切换tab
$('.header .tabBox div').click(function () {
var i = $(this).index() + 1;
$(this).addClass('act').siblings().removeClass('act');
$('ul').removeClass('ul1').removeClass('ul2').removeClass('ul3').removeClass('ul4');
$(`ul`).addClass(`ul${i}`);
$('.header').removeClass('header1').removeClass('header2').removeClass('header3').removeClass('header4');
$(`.header`).addClass(`header${i}`);
$('.top').removeClass('tops1').removeClass('tops2').removeClass('tops3').removeClass('tops4');
$(`.top`).addClass(`tops${i}`);
$('.header .monthlyRewards').hide();
$(`.header .top .top1 .ts`).attr('src', './images/no1.png')
$(`.header .top .top2 .ts`).attr('src', './images/no2.png')
$(`.header .top .top3 .ts`).attr('src', './images/no3.png')
timeType = 1;
$('.header .sTab div').removeClass('act');
$('.header .sTab div').eq(0).addClass('act');
$('.header .top .score img').attr('src', `./images/${i}.png`);
$('.rewards').removeClass('reward1').removeClass('reward2').removeClass('reward3').removeClass('newreward1').removeClass('newreward3');
$('.rewards').addClass(`reward${i}`);
// if (partitionId != 16) {
// $('.rewards').addClass(`reward${i}`);
// } else {
// if (i === 2) {
// $('.rewards').addClass(`reward${i}`);
// } else {
// $('.rewards').addClass(`newreward${i}`);
// }
// }
if (i == 1) {
listType = 2;
geth5();
} else if (i == 2) {
listType = 1;
geth5();
} else if (i == 3) {
listType = 3;
listRank();
$('.header .top .score img').attr('src', `./images/${4}.png`);
$(`.header .top .top1 .ts`).attr('src', './images/no11.png')
$(`.header .top .top2 .ts`).attr('src', './images/no22.png')
$(`.header .top .top3 .ts`).attr('src', './images/no33.png')
} else if (i == 4) {
// listRank();
}
})
// 前三跳转个人页
$('.header .top .ts').click(function () {
var uid = $(this).attr('uid');
if (browser.ios) {
window.webkit.messageHandlers.openPersonPage.postMessage(uid);
} else if (browser.android) {
if (androidJsObj && typeof androidJsObj === "object") {
window.androidJsObj.openPersonPage(uid);
}
}
})
window.addEventListener('scroll', function () {
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
console.log('页面下滑距顶部的距离:', scrollTop);
if (scrollTop >= 30) {
$('.newText22').hide();
$('.newText2').css('height', '2rem')
} else if (scrollTop < 30) {
$('.newText2').css('height', '0rem')
$('.newText22').show();
}
});