Files
peko-h5/view/peko/activity/act-2022-qx/js/index.js
2022-09-08 18:22:18 +08:00

856 lines
31 KiB
JavaScript

let urlPrefix = getUrlPrefix()
let browser = checkVersion()
let env = EnvCheck();
if (env == 'test') {
new VConsole();
}
// 封装layer消息提醒框
let layerIndex
const showLoading = (content = '加载中...') => {
layer.open({
type: 2,
shadeClose: false,
content,
success (e) {
layerIndex = $(e).attr('index')
}
})
}
const hideLoading = (index) => {
layer.close(index)
}
const toastMsg = (content = '操作完成', time = 2) => {
layer.open({
content,
time,
skin: 'msg'
})
}
var myRankings;
let damuPool = []
let danmu = []
let timer2
// 初始化
let danmaku
const initDanmu = () => {
danmaku = new Danmaku({
container: document.getElementById('my_container'),
speed: 50,
})
}
const setDanmuData = () => {
// damuPool = [
// { sendAvatar: './images/logo.png', sendNick: `1asdasdasdasdasdasdasdasdasd`, text: '我把思念写着天空asdasdasdasdasdasdasdasdasdasd', },
// { sendAvatar: './images/logo.png', sendNick: `2`, text: '我想永远陪着你', },
// { sendAvatar: './images/logo.png', sendNick: `3`, text: '我爱你我爱你甜蜜蜜', },
// { sendAvatar: './images/logo.png', sendNick: `4`, text: 'asdawdasdasdas', },
// ]
if (!timer2) {
if (damuPool.length < 5) {
timer2 = setInterval(() => {
if (!danmu.length) {
danmu = [...damuPool]
}
let danmushoot = danmu.shift();
if (danmushoot) {
renderDM(danmushoot);
}
}, 2000);
} else {
timer2 = setInterval(() => {
if (!danmu.length) {
danmu = [...damuPool]
}
let danmushoot = danmu.shift();
if (danmushoot) {
renderDM(danmushoot);
}
}, 1000);
}
}
}
const renderDM = (item) => {
danmaku.emit({
// text: item.text,
render: function () {
var $div = document.createElement('div');
var $img = document.createElement('img');
var $span = document.createElement('span');
var $b = document.createElement('b');
$span.innerHTML = item.text;
$b.innerHTML = item.sendNick + ' :';
$img.src = item.sendAvatar;
$b.style = `color:#C09FF5;margin-right: 0.12rem;`;
$img.style = 'width: 0.4266666667rem;height: 0.3733333333rem;margin-right: 0.12rem;display: inline-block;vertical-align: middle;border: 1px solid #FFF;'
$div.style = `padding:0.1rem 0.2rem;height:auto;box-sizing: border-box;border-radius:1rem;font-size:0.24rem;color:#fff;background:#1A0042;border: 0.5px solid #fffaca;`;
$div.appendChild($img);
$div.appendChild($b);
$div.appendChild($span);
$('.barrage_text div').eq(0).css({ height: '4.5rem', width: "8.3rem", "margin": '0rem auto 0', "top": "0.2rem" })
return $div;
},
})
}
var roomUid;
var arrInfoGiftIndex = 0;
var datas;
var contentType;
var listMyRankFuns = 1;
var myAvatar;
var myNick;
var arrInfoGift = [
{ name: '同心锁', charging: 1000, img: './images/z1.png' },
{ name: '香囊', charging: 1200, img: './images/z2.png' },
{ name: '玉佩', charging: 1500, img: './images/z3.png' },
{ name: '绣球', charging: 1800, img: './images/z4.png' },
]
var rewardGit = [
{ name: '', type: 1, day: "1天", img: '' },//type 1:头饰,2:礼物
{ name: '', type: 1, day: "3天", img: '' },
{ name: '星星瓶', type: 2, day: "99钻石", img: './images/g3.png' },
{ name: '告白情书', type: 2, day: "666钻石", img: './images/g4.png' },
]
$(function () {
setTimeout(function () {
getInfoFromClient()
setTimeout(function () {
// 页面全屏
if (browser.app) {
if (browser.android) {
window.androidJsObj.initShowNav(false)
} else {
window.webkit.messageHandlers.initShowNav.postMessage(0)
}
};
// 顶部返回事件
$('.back').click(() => {
if (browser.android) {
window.androidJsObj.closeWebView()
} else {
window.webkit.messageHandlers.closeWebView.postMessage(null)
}
})
getRecommendRoom();
getPageInfo();
getMyBulletChat();
}, 100)
})
})
// 播放svg
function svgaFun () {
player1 = new SVGA.Player('.svgas');
parser1 = new SVGA.Parser('.svgas');
parser1.load('./images/svga.svga', function (videoItem) {
// player1.loops= 1
// player1.clearsAfterStop = false;
// player1.setVideoItem(videoItem);
// player1.startAnimation();
player1.loops = 1;
player1.clearsAfterStop = false;
player1.setVideoItem(videoItem);
player1.startAnimation();
player1.setContentMode('AspectFill')
player1.onFinished(() => {
$('.svga').hide()
})
})
}
// 处理充能礼物列表
function arrInfoGiftFun (arrInfoGiftIndex, res) {
// 处理信物数据
console.log("arrInfoGiftIndex:" + arrInfoGiftIndex);
console.log("currLevelNo:", res.data.currLevelNo - 1);
console.log(res.data);
$('.txs .logosssss').attr('src', arrInfoGift[arrInfoGiftIndex].img);
$('.txs .giftName').text(arrInfoGift[arrInfoGiftIndex].name);
$('.txs .line p b').text(arrInfoGift[arrInfoGiftIndex].charging);
$('.txs .line span b').text(res.data.batteryNum);
if (res.data.allUnlock == true) {
if (arrInfoGiftIndex == arrInfoGift.length - 1) {
$('.txs .rightBut_tab1').hide();
}
$('.getGifts').show();
$('.txs .line div').css('width', "100%");
$('.txs .line p').html(`${arrInfoGift[arrInfoGiftIndex].charging}/<b>${arrInfoGift[arrInfoGiftIndex].charging}</b>`);
} else {
if (arrInfoGiftIndex == res.data.currLevelNo - 1) {
$('.txs .line div').css('width', (res.data.currLevelScore / (arrInfoGift[res.data.currLevelNo - 1].charging)) * 100 + "%");
$('.txs .line p').html(`${res.data.currLevelScore}/<b>${arrInfoGift[res.data.currLevelNo - 1].charging}</b>`);
$('.getGifts').hide();
$('.notGetGifts').show();
} else {
if (arrInfoGiftIndex < res.data.currLevelNo - 1) {
$('.getGifts').show();
$('.notGetGifts').hide();
$('.txs .line div').css('width', "100%");
$('.txs .line p').html(`${arrInfoGift[arrInfoGiftIndex].charging}/<b>${arrInfoGift[arrInfoGiftIndex].charging}</b>`);
} else if (arrInfoGiftIndex > res.data.currLevelNo - 1) {
$('.txs .line div').css('width', "0%");
$('.txs .line p').html(`${0}/<b>${arrInfoGift[res.data.currLevelNo - 1].charging}</b>`);
$('.getGifts').hide();
$('.notGetGifts').show();
}
}
}
// 处理查看奖励弹窗
$('.notPubBG .pubBG_in .giftImg').attr('src', rewardGit[arrInfoGiftIndex].img);
$('.notPubBG .pubBG_in .giftName').text(`点亮${$('.txs .giftName').text()}可获得`);
$('.notPubBG .pubBG_in .nick2').text(rewardGit[arrInfoGiftIndex].name);
$('.notPubBG .pubBG_in .num').text(rewardGit[arrInfoGiftIndex].day);
// 处理按钮状态
if (res.data.allUnlock == true) {
$('.txs .but11').hide();
$('.tab1 .txs .butsss').show();
// $('.tab1 .txs').addClass('txs_active');
console.log('全部解锁');
} else {
if (arrInfoGiftIndex == res.data.currLevelNo - 1) {
$('.txs .but11').show();
$('.tab1 .txs .butsss').hide();
// $('.tab1 .txs').removeClass('txs_active');
console.log('两个按钮');
} else if (arrInfoGiftIndex < res.data.currLevelNo - 1) {
$('.txs .but11').hide();
$('.tab1 .txs .butsss').show();
// $('.tab1 .txs').addClass('txs_active');
console.log('已解锁按钮');
} else if (arrInfoGiftIndex > res.data.currLevelNo - 1) {
$('.txs .but11').hide();
$('.tab1 .txs .butsss').hide();
// $('.tab1 .txs').removeClass('txs_active');
console.log(('啥都不显示'));
}
}
}
// 查看奖励按钮
$('.txs .logosssss').click(function () {
$('.notPubBG').show();
bodyScroolFun(true);
})
$('.tab1 .txs .butsss img').click(function () {
$('.notPubBG').show();
bodyScroolFun(true);
})
// 充能左切换按钮
$('.txs .leftBut_tab1').click(function () {
arrInfoGiftIndex = arrInfoGiftIndex - 1;
if (arrInfoGiftIndex <= 0) {
arrInfoGiftIndex = 0;
arrInfoGiftFun(arrInfoGiftIndex, datas);
$(this).hide();
} else {
$('.txs .rightBut_tab1').show();
arrInfoGiftFun(arrInfoGiftIndex, datas);
}
})
// 充能右切换按钮
$('.txs .rightBut_tab1').click(function () {
arrInfoGiftIndex = arrInfoGiftIndex + 1;
if (arrInfoGiftIndex == arrInfoGift.length - 1) {
arrInfoGiftIndex = arrInfoGift.length - 1;
arrInfoGiftFun(arrInfoGiftIndex, datas);
$(this).hide();
} else {
$('.txs .leftBut_tab1').show();
arrInfoGiftFun(arrInfoGiftIndex, datas);
}
})
// 获取榜单接口
function listRank (rankType) {
showLoading()
networkRequest({
type: 'GEt',
url: urlPrefix + '/act/cp/2022/listRank',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid, rankType },
success (res) {
if (res.code === 200) {
$('.listBox ul li').remove();
$('.myList ul li').remove();
// 前三
var top3 = res.data.rank.slice(0, 3);
var notTop3 = res.data.rank.slice(3);
if (top3.length < 3) {
let arr = new Array(3 - top3.length).fill({
lavatar: './images/logo.png',
ravatar: './images/logo.png',
lnick: '虚位以待',
rnick: '虚位以待',
score: ""
})
top3.push(...arr)
}
top3.forEach((res, index) => {
$(`.listBox .div${index + 1} .imgl`).attr('src', res.lavatar);
$(`.listBox .div${index + 1} .imgr`).attr('src', res.ravatar);
$(`.listBox .div${index + 1} p`).html(`${res.lnick.length > 4 ? res.lnick.slice(0, 4) + '...' : res.lnick}&nbsp;<b>&amp;</b>&nbsp;${res.rnick.length > 4 ? res.rnick.slice(0, 4) + '...' : res.rnick}`);
$(`.listBox .div${index + 1} .b`).html(`${res.score > 10000 ? (Math.floor(res.score / 1000) / 10).toFixed(1) + 'w' : res.score} 亲密值`);
});
// 非前三
var str = '';
notTop3.forEach((res, index) => {
str += `
<li>
<div class="num">${index + 4}</div>
<img src="${res.lavatar}" alt="" class="imgl">
<img src="${res.ravatar}" alt="" class="imgr">
<p class="name">${res.lnick.length > 4 ? res.lnick.slice(0, 4) + '...' : res.lnick}&nbsp;<b>&amp;</b>&nbsp;${res.rnick.length > 4 ? res.rnick.slice(0, 4) + '...' : res.rnick}</p>
<b class="right">${res.score > 10000 ? (Math.floor(res.score / 1000) / 10).toFixed(1) + 'w' : res.score} 亲密值</b>
</li>
`
})
$('.listBox ul').append(str);
// 处理自己排名
if (res.data.myRank == undefined) {
$('.myList .more').hide();
$('.myList ul').append('<li class="active">当前暂未有组合哦~ 快去找你的组合吧!</li>')
} else {
$('.myList ul').append(`
<li>
<img src="${res.data.myRank.lavatar}" alt="" class="left">
<img src="${res.data.myRank.ravatar}" alt="" class="right">
<img src="./images/love.png" alt="" class="love">
<p class="name">${res.data.myRank.lnick.length > 4 ? res.data.myRank.lnick.slice(0, 4) + '...' : res.data.myRank.lnick}&nbsp;<b>&amp;</b>&nbsp;${res.data.myRank.rnick.length > 4 ? res.data.myRank.rnick.slice(0, 4) + '...' : res.data.myRank.rnick}</p>
<div class="rightBox">
<p>${res.data.myRank.score > 10000 ? (Math.floor(res.data.myRank.score / 1000) / 10).toFixed(1) + 'w' : res.data.myRank.score} 亲密值</p>
<span>当前排名${res.data.myRanking}名</span>
</div>
</li>
`)
myRankings = res.data.myRanking;
$('.myList .more').show();
}
hideLoading(layerIndex)
} else {
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
}
var myListBut = false;
// 上拉加载更多
$('.myList .more').click(function () {
myListBut = !myListBut;
if (myListBut) {
listMyRankFun(listMyRankFuns);
$('.myList').addClass('myList_active');
$(this).addClass('more_active');
$('.myList ul').css('overflow-y', 'scroll');
$('.myList ul').css('height', '7rem');
bodyScroolFun(true);
} else {
$('.myList').removeClass('myList_active');
$(this).removeClass('more_active');
$('.myList ul').css('overflow-y', 'hidden');
$('.myList ul').css('height', 'auto');
bodyScroolFun(false);
}
})
// 控制body是否可以滑动
function bodyScroolFun (bool) {
if (bool) {
$('body').css('overflow', 'hidden');
} else {
$('body').css('overflow', 'auto');
}
}
// 获取当前用户的组合列表
function listMyRankFun (rankType) {
showLoading();
networkRequest({
type: 'GEt',
url: urlPrefix + '/act/cp/2022/listMyRank',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid, rankType },
success (res) {
if (res.code === 200) {
$('.myList ul li').remove();
var str = ''
res.data.forEach((res, index) => {
str += `
<li>
<img src="${res.lavatar}" alt="" class="left">
<img src="${res.ravatar}" alt="" class="right">
<img src="./images/love.png" alt="" class="love">
<p class="name">${res.lnick.length > 4 ? res.lnick.slice(0, 4) + '...' : res.lnick}&nbsp;<b>&amp;</b>&nbsp;${res.rnick.length > 4 ? res.rnick.slice(0, 4) + '...' : res.rnick}</p>
<div class="rightBox">
<p>${res.score > 10000 ? (Math.floor(res.score / 1000) / 10).toFixed(1) + 'w' : res.score} 亲密值</p>
<span>${index == 0 ? "当前排名" + myRankings + '名' : ''}</span>
</div>
</li>
`
})
$('.myList ul').append(str);
hideLoading(layerIndex)
} else {
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
}
// 切换总榜日榜
$('.listBox .tab div').click(function () {
var i = $(this).index();
if (i == 0) {
listMyRankFuns = 1
listRank(1);
$(this).addClass('active')
$(this).siblings().removeClass('active2')
} else {
listMyRankFuns = 3
listRank(3)
$(this).addClass('active2')
$(this).siblings().removeClass('active')
}
})
// 获取房间接口
function getRecommendRoom () {
showLoading()
networkRequest({
type: 'GEt',
url: urlPrefix + '/act/cp/2022/getRecommendRoom',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid },
success (res) {
if (res.code === 200) {
roomUid = res.data;
// 获取我的弹幕列表
networkRequest({
type: 'GEt',
url: urlPrefix + '/act/cp/2022/getMyBulletChat',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid },
success (res) {
if (res.code === 200) {
if (res.data != undefined) {
contentType = true;
damuPool.push({
sendAvatar: myAvatar,
text: res.data.text,
sendNick: myNick,
})
console.log(damuPool);
$('.qx_put_out .qx_put_outin .p1').text('您在' + dateFormat(res.data.createTime, "MM月dd日") + '已发送了情书');
$('.qx_put_out .qx_put_outin .p2').text(res.data.text);
}
hideLoading(layerIndex)
} else {
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
hideLoading(layerIndex)
} else {
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
}
// 发送弹幕确定按钮
$('.qx_put .qx_put_in .ok').click(function () {
var val = $('.qx_put .qx_put_in input').val();
if (val == '') {
toastMsg('告白语不能为空')
} else {
sendBulletChatFun(val);
bodyScroolFun(false);
}
})
// 发送弹幕接口
function sendBulletChatFun (content) {
showLoading()
networkRequest({
type: 'POST',
url: urlPrefix + '/act/cp/2022/sendBulletChat',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid, content },
success (res) {
if (res.code === 200) {
$('.qx_put').hide();
// 获取我的弹幕列表
networkRequest({
type: 'GEt',
url: urlPrefix + '/act/cp/2022/getMyBulletChat',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid },
success (res) {
if (res.code === 200) {
if (res.data != undefined) {
contentType = true;
damuPool.push({
sendAvatar: myAvatar,
text: res.data.text,
sendNick: myNick,
})
console.log(damuPool);
setDanmuData();
$('.qx_put_out .qx_put_outin .p1').text('您在' + dateFormat(res.data.createTime, "MM月dd日") + '已发送了情书');
$('.qx_put_out .qx_put_outin .p2').text(res.data.text);
}
hideLoading(layerIndex)
} else {
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
} else {
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
}
// 获取弹幕列表
function getMyBulletChat () {
showLoading();
networkRequest({
type: 'GEt',
url: urlPrefix + '/act/cp/2022/listBulletChat',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid },
success (res) {
if (res.code === 200) {
res.data.forEach(res => {
damuPool.push(res);
})
initDanmu();
setDanmuData();
setTimeout(function () {
$('.tab2').hide();
}, 10)
hideLoading(layerIndex)
} else {
hideLoading(layerIndex)
// toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
}
$('.queqiao .myqs').click(function () {
bodyScroolFun(true);
if (contentType) {//
$('.qx_put_out').show();
} else {
textFun();
$('.qx_put').show();
}
})
// 获取用户为爱发电活动页面信息
function getPageInfo () {
showLoading()
networkRequest({
type: 'GEt',
url: urlPrefix + '/act/cp/2022/getPageInfo',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid },
success (res) {
if (res.code === 200) {
datas = res;
if (res.data.allUnlock == true) {
res.data.currLevelNo = 4;
arrInfoGiftIndex = res.data.currLevelNo - 1;
} else {
arrInfoGiftIndex = res.data.currLevelNo - 1;
}
if (arrInfoGiftIndex != 0) {
$('.txs .leftBut_tab1').show();
} else if (arrInfoGiftIndex == arrInfoGift.length - 1) {
$('.txs .rightBut_tab1').hide();
}
$('.txs .line p').html(`${res.data.currLevelScore}/<b>${arrInfoGift[res.data.currLevelNo - 1].charging}</b>`);
networkRequest({
type: 'GET',
url: urlPrefix + `/user/get?uid=${pubInfo.uid}`,
success (ress) {
if (ress.code === 200) {
// $('.avatar').find('img').attr('src', res.data.avatar)
var gender = ress.data.gender;
rewardGit[0].img = gender == 1 ? './images/g1.png' : './images/g2.png';
rewardGit[1].img = gender == 1 ? './images/g1.png' : './images/g2.png';
rewardGit[0].name = gender == 1 ? '牛郎' : '织女';
rewardGit[1].name = gender == 1 ? '牛郎' : '织女';
myAvatar = ress.data.avatar;
myNick = ress.data.nick;
arrInfoGiftFun(arrInfoGiftIndex, res);
} else {
toastMsg(ress.message)
}
},
error () {
toastMsg('网络错误')
}
})
res.data.tasks.forEach((res, index) => {
if (res.taskStatus == 2) {
$(`.toak .div${index + 1} .but`).addClass('but_active');
$(`.toak .div${index + 1} .but`).attr('isbut', '1');
}
$(`.toak .div${index + 1} .but`).attr('taskno', res.taskNo);
$(`.toak .div${index + 1} span p b`).text(res.taskProgress == undefined ? "3/3" : res.taskProgress + "/3")
});
$('.toak div .but').click(function () {
var type = $(this).attr('isbut');
if (type != 1) {
if (browser.ios) {
// window.webkit.messageHandlers.openRoom.postMessage(roomUid);
} else if (browser.android) {
if (androidJsObj && typeof androidJsObj === 'object') {
window.androidJsObj.openRoom(roomUid);
}
}
} else {
console.log('已完成');
}
})
// 处理鹊桥情书
if (res.data.allUnlock == true) {
$('.queqiao .myqs').show();
} else {
$('.queqiao .myqs').hide();
}
for (let index = 1; index <= arrInfoGift.length; index++) {
if (res.data.allUnlock == true) {
$(`.xw .d${index}`).hide();
} else {
if (Number($(`.xw .d${index}`).attr('id')) < res.data.currLevelNo) {
$(`.xw .d${index}`).hide();
}
}
}
hideLoading(layerIndex)
} else {
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
}
// 使用电池充电接口
function chargeFun (batteryNum) {
showLoading()
networkRequest({
type: 'POST',
url: urlPrefix + '/act/cp/2022/charge',
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid, batteryNum: batteryNum },
success (res) {
if (res.code === 200) {
if (JSON.stringify(res.data) != "{}") {
$('.pubBG .pubBG_in .giftImg').attr('src', res.data.prizePic);
$('.pubBG .pubBG_in .nick2').text(res.data.prizeName);
$('.pubBG .pubBG_in .num').text(res.data.awardDayDesc);
$('.pubBG').show();
}
getPageInfo();
chargeFunType = !chargeFunType;
// hideLoading(layerIndex)
} else {
chargeFunType = !chargeFunType;
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
chargeFunType = !chargeFunType;
}
})
}
// 充电一次按钮
$('.txs .butLeft').click(function () {
if (chargeFunType) {
chargeFunType = !chargeFunType;
if (Number($('.txs .line span b').text()) <= 0) {
toastMsg('电池不足,快去完成任务获取吧~');
chargeFunType = !chargeFunType;
} else {
$('.svga').show();
svgaFun();
setTimeout(function () {
chargeFun(1);
}, 2000)
}
}
})
// 充电五次按钮
var chargeFunType = true;
$('.txs .butRight').click(function () {
if (chargeFunType) {
chargeFunType = !chargeFunType;
if (Number($('.txs .line span b').text()) <= 0) {
toastMsg('电池不足,快去完成任务获取吧~');
chargeFunType = !chargeFunType;
} else {
$('.svga').show();
svgaFun();
setTimeout(function () {
chargeFun(5);
}, 2000)
}
}
})
// tab切换
$('.tabBox div').click(function () {
var i = $(this).index();
$(this).addClass('active').siblings().removeClass('active');
if (i == 0) {
$(".tab1").show();
$(".tab2").hide();
$(".tab3").hide();
} else if (i == 1) {
$(".tab1").hide();
$(".tab2").show();
$(".tab3").hide();
} else {
$(".tab1").hide();
$(".tab2").hide();
$(".tab3").show();
listRank(1);
}
})
// 打开规则
$('.header .rule_icon').click(function () {
bodyScroolFun(true);
$('.rule').show();
})
// 关闭规则
$('.rule img').click(function () {
bodyScroolFun(false);
$('.rule').hide();
})
// 打开告白输入框弹窗
var textArr = [
'不太相信星座,除了喜欢你的时候',
'我喜欢你,从一而终,认真且怂',
'你的身旁,是我最想驻足的地方',
'你所过之处,便是我的江湖',
'自从遇见了你,一切繁华都成背景',
'我想换个身份,重新认识你一遍',
'不盼星辰盼你,不追星月追你',
'见过那么多猪,就你最可爱',
'我明明跟你在一起,却还是好想你',
'见什么世面,见见你就好啦',
'看尽世间繁华,唯愿将你放在心上',
'心动是我送你的,第一份礼物',
'众生皆苦,只有你是草莓味',
'想和你看星空,谈夜色微风',
'你去哪里,我都尾随其后',
'如果没有你,我想我会断电',
'和你在一起,总会令我忘记时间存在',
'有你的日子,咖啡也是甜的'
]
var textI = 0;
// 换一批按钮
$('.qx_put .qx_put_in .update').click(function () {
textFun();
})
// 自动输入按钮
$('.qx_put .li').click(function () {
$(".qx_put .qx_put_in input").val($(this).text())
var val = $(".qx_put .qx_put_in input").val();
$('.qx_put .qx_put_in .num b').text(val.length)
})
// 替换告白语
function textFun () {
if (textI >= 18) {
textI = 3;
} else {
textI = textI + 3;
}
$('.li1').text(textArr[textI - 3]);
$('.li2').text(textArr[textI - 2]);
$('.li3').text(textArr[textI - 1]);
}
// 监听告白输入框
$(".qx_put .qx_put_in").bind("input propertychange", function (event) {
var val = $(".qx_put .qx_put_in input").val();
$('.qx_put .qx_put_in .num b').text(val.length)
});
// 取消告白输入框弹窗
$('.qx_put .qx_put_in .clos').click(function () {
$('.qx_put').hide();
bodyScroolFun(false);
})
// 关闭已发送弹窗
$('.qx_put_out .qx_put_outin img').click(function () {
$('.qx_put_out').hide();
bodyScroolFun(false);
})
// 关闭奖励弹窗
$('.pubBG .pubBG_in .close').click(function () {
$('.pubBG').hide();
bodyScroolFun(false);
})
// 关闭查看奖励弹窗
$('.notPubBG .pubBG_in .close').click(function () {
$('.notPubBG').hide();
bodyScroolFun(false);
})
// 打开榜单规则
$('.listBox .listRule_icon').click(function () {
bodyScroolFun(true);
$('.listRule').show();
})
// 关闭榜单规则
$('.listRule .listRule_in .close').click(function () {
bodyScroolFun(false);
$('.listRule').hide();
})
//返回页面 重新请求接口
var hiddenProperty = 'hidden' in document ? 'hidden' :
'webkitHidden' in document ? 'webkitHidden' :
'mozHidden' in document ? 'mozHidden' : null;
var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange');
var onVisibilityChange = function () {
if (!document[hiddenProperty]) {
location.reload()
}
}
document.addEventListener(visibilityChangeEvent, onVisibilityChange);