Files
peko-h5/view/peko/activity/2023-Valentines-Day/js/index.js

876 lines
31 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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',
offset: 'b'
})
}
if (false) {//!browser.app
toastMsg('請在app內打開');
} else {
$('.wrap').removeClass('no-in-app')
}
var nowTime = new Date().getTime()
var startTime
var endTime
var canGet = true
$(function () {
getInfoFromClient()
setTimeout(function () {
getLetterInit()
getPetitionInit()
cpOffset()
getRank()
swiperFun()
}, 100)
})
// 礼物轮播
function swiperFun() {
var swiper = new Swiper('.swiper', {
autoplay: {
delay: 2000,//2秒切换一次
},
// loop: true, // 循环模式选项
direction: 'horizontal',
});
}
// 获取信物配置
function getLetterInit() {
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/getKeepsakeConfig',
success(res) {
if (res.code === 200) {
startTime = res.data.startTime;
endTime = res.data.endTime;
$('.letter-wrap .letter .imgbox img').attr('src', res.data.keepsake.icon)
$('.letter-wrap .letter p e').text(res.data.keepsakeNum)
$('.letter-wrap .get_letter').attr('id', res.data.keepsake.id)
$('.letter-wrap .get_letter').attr('type', res.data.keepsake.type)
if (nowTime >= res.data.endTime) {
$('.letter-wrap .get_letter').css('filter', 'grayscale(0.7)')
}
hideLoading(layerIndex)
} else {
toastMsg(res.message)
hideLoading(layerIndex)
}
},
error(err) {
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 获取兑换/抽奖配置
function getPetitionInit() {
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/getPropItemConfig',
success(res) {
if (res.code === 200) {
$('.petition-wrap .myticket span e').html(res.data.cpCurrency)
let numberList = res.data.propTabs.find(item => {
return item.type == 2
})
let chargeList = res.data.propTabs.find(item => {
return item.type == 1
})
chargeList.props.forEach((res, i) => {
$(`.petition-wrap .gift-wrap .li${i + 1} .giftbg img`).attr('src', res.icon)
$(`.petition-wrap .gift-wrap .li${i + 1} span`).html(res.name)
$(`.petition-wrap .gift-wrap .li${i + 1} .btn`).attr('id', res.id)
$(`.petition-wrap .gift-wrap .li${i + 1} .btn`).attr('type', res.type)
$(`.petition-wrap .gift-wrap .li${i + 1} .btn`).html(res.type == 2 ? '兌換銘牌' : res.type == 3 ? '兌換資料卡' : res.type == 4 ? '兌換頭飾' : '兌換座駕')
$(`.petition-wrap .gift-wrap .li${i + 1} p e`).html(res.price)
})
numberList.props.forEach(res => {
$('.petition-wrap .number-wrap .giftbg img').attr('src', res.icon)
$('.petition-wrap .number-wrap span').html(res.name)
$('.petition-wrap .number-wrap .btn').attr('id', res.id)
$('.petition-wrap .number-wrap .btn').attr('type', res.type)
$('.petition-wrap .number-wrap p e').html(res.price)
})
hideLoading(layerIndex)
} else {
toastMsg(res.message)
hideLoading(layerIndex)
}
},
error(err) {
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 我的cp未读数
function cpOffset() {
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/cpOffset',
success(res) {
if (res.code === 200) {
if (res.data > 9) {
$('.wrap .unread').html('9+')
} else if (res.data == 0) {
$('.wrap .unread').hide()
} else {
$('.wrap .unread').html(res.data)
}
} else {
toastMsg(res.message)
}
},
error(err) {
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 我的cp列表
function myCpList() {
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/cpList',
success(res) {
if (res.code === 200) {
let cpList = ''
if (res.data == 0 || !res.data) {
$('.mycpBox .mycp_in .tips').show()
} else {
res.data.forEach(res => {
cpList += `
<li>
<b>${res.nick.length > 5 ? res.nick.slice(0, 5) + '...' : res.nick}</b>
<b class="cpValue">${res.cpValue}</b>
<span inviterUid="${res.uid}" class='${res.status == 0 ? "canpass" : res.status == 1 ? "waitpass" : "pass"}'>${res.status == 0 ? "待通過" : res.status == 1 ? "可通過" : "已締結"}</span>
</li>
`
})
$('.mycpBox .mycp_in ul').append(cpList)
}
$('.mycpBox').show();
$('.mycpBox .mycp_in .box li').off()
$('.mycpBox .mycp_in .box li').on("click", '.waitpass', function () {
let index = $(this).parents().index()
let inviterUid = $(this).attr('inviterUid')
confirmCp(inviterUid, index)
})
hideLoading(layerIndex)
} else {
toastMsg(res.message)
hideLoading(layerIndex)
}
},
error(err) {
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 通过cp缔结
function confirmCp(inviterUid, index) {
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/confirmCp',
data: { inviterUid },
success(res) {
if (res.code === 200) {
$('.mycpBox .mycp_in .box li').eq(index).find('span').addClass('pass')
$('.mycpBox .mycp_in .box li').eq(index).find('span').removeClass('waitpass')
$('.mycpBox .mycp_in .box li').eq(index).find('span').html('已締結')
toastMsg('締結成功快去增加和TA的情緣值吧~')
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error(err) {
toastMsg('網絡錯誤,請退出重進')
hideLoading(layerIndex)
}
})
}
// cp奖励记录
var cpRecordPage = 1
var cpRecordScroll = true
function cpRewardRecord(cpRecordPage) {
cpRecordScroll = false;
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/pageCpRewardRecord',
data: { page: cpRecordPage, pageSize: 10 },
success(res) {
if (res.code === 200) {
if (res.data.records.length > 0) {
let str = ``;
res.data.records.forEach((res, i) => {
str += `
<li>
<b>${res.dateTime}</b>
<b>${res.nick.length > 5 ? res.nick.slice(0, 5) + '...' : res.nick}</b>
<b>${res.levelDesc}</b>
<b class="jiangli">${res.rewardDesc}</b>
</li>
`
});
$('.cpRecordBox .cpRecord_in .box').append(str);
cpRecordScroll = true;
} else {
cpRecordScroll = false;
$('.cpRecordBox .cpRecord_in .tips').show();
}
$('.cpRecordBox').show();
hideLoading(layerIndex)
} else {
cpRecordScroll = true;
bodyScroolFun(false)
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error(err) {
cpRecordScroll = true;
bodyScroolFun(false)
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 获取兑换/抽奖记录
var drawPage = 1
var drawScroll = true
function getDrawRecord(drawPage, tab) {
drawScroll = false;
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/pageRecord',
data: { page: drawPage, pageSize: 10, tab },
success(res) {
if (res.code === 200) {
if (res.data.records.length > 0) {
let str = ``;
if (tab == 1) {
res.data.records.forEach((res, i) => {
str += `
<li>
<b>${res.dateTime}</b>
<b>${res.cost}</b>
<b>${res.rewardDesc}</b>
<b>${res.rewardDays}天</b>
</li>
`
});
$('.exchangeBox .exchange_in .box').append(str);
$('.exchangeBox').show();
} else {
res.data.records.forEach((res, i) => {
str += `
<li>
<b>${res.dateTime}</b>
<b>${res.cost}</b>
<b>${res.rewardDesc}</b>
</li>
`
});
$('.drawBox .draw_in .box').append(str);
$('.drawBox').show();
}
drawScroll = true;
} else {
drawScroll = false;
if (tab == 1) {
$('.exchangeBox .exchange_in .tips').show();
$('.exchangeBox').show();
} else {
$('.drawBox .draw_in .tips').show();
$('.drawBox').show();
}
}
hideLoading(layerIndex)
} else {
drawScroll = true;
bodyScroolFun(false)
hideLoading(layerIndex)
toastMsg(res.message)
}
},
error(err) {
drawScroll = true;
bodyScroolFun(false)
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 购买信物、兑换、抽奖 (道具id,数量)
function buy(id, num, type) {
showLoading()
networkRequest({
type: 'POST',
url: urlPrefix + '/act/valentineCp/buy',
data: { id, num },
success(res) {
if (res.code === 200) {
if (res.data.prop) {
if (res.data.prop.type == 1) {
$('.letter-wrap .letter p e').html(res.data.remain)
toastMsg('購買成功信物已放進背包快送給你心儀的TA吧~')
canGet = true
} else if (res.data.prop.type == 6) {
$('.petition-wrap .myticket span e').html(res.data.remain)
$('.gx .gx_in .box li img').attr('src', res.data.prop.icon)
$('.gx .gx_in .box li span').html( res.data.prop.name)
$('.gx .gx_in .tips').html(`*情人節限定5位靚號:52XXXXXX為隨機數字一組為2個靚號<br>聯系客服領取LINE: pekoyuyin)`)
$('.gx').show()
} else {
// if (res.data.prop.type == 2){
// $('.gx .gx_in .box li img').addClass('mingpai')
// }else {
// $('.gx .gx_in .box li img').removeClass('mingpai')
// }
$('.petition-wrap .myticket span e').html(res.data.remain)
$('.gx .gx_in .box li img').attr('src', res.data.prop.icon)
$('.gx .gx_in .box li span').html(res.data.prop.name)
$('.gx .gx_in .tips').html(`獎勵將自動發放到裝扮中心,快去展示自己吧~`)
$('.gx').show()
}
} else {
if (type == 6) {
toastMsg('很遺憾沒有抽到,距離靚號就差一點啦~')
$('.petition-wrap .myticket span e').html(res.data.remain)
} else if(type == 1,type == 3,type == 4,type == 5){
$('.petition-wrap .myticket span e').html(res.data.remain)
}else{
$('.letter-wrap .letter p e').html(res.data.remain)
toastMsg(res.message)
}
canGet = true
}
hideLoading(layerIndex)
} else if (res.code == 31005) {
$('.tishiBox').show()
canGet = true
hideLoading(layerIndex)
} else {
toastMsg(res.message)
canGet = true
hideLoading(layerIndex)
}
},
error(err) {
canGet = true
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 榜单接口
function getRank() {
$('.rank-wrap .list ul li').remove();
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/valentineCp/getRank',
success(res) {
if (res.code === 200) {
// 前一
var top1 = res.data.rankList.slice(0, 1);
var notTop1 = res.data.rankList.slice(1);
if (top1.length < 1) {
let arr = new Array(1 - top1.length).fill({
inviterAvatar: './images/logo.png',
inviterNick: '虛位以待',
cpValue: 0,
inviteeAvatar: './images/logo.png',
inviteeNick: '虛位以待',
})
top1.push(...arr)
}
top1.forEach((res, index) => {
$(`.rank-wrap .list .no${index + 1} .txbox1 img`).attr('src', res.inviterAvatar);
$(`.rank-wrap .list .no${index + 1} .txbox1`).attr('uid', res.inviterUid);
$(`.rank-wrap .list .no${index + 1} .nick1`).html(res.inviterNick.length > 5 ? res.inviterNick.slice(0, 5) + '...' : res.inviterNick);
$(`.rank-wrap .list .no${index + 1} .txbox2 img`).attr('src', res.inviteeAvatar);
$(`.rank-wrap .list .no${index + 1} .txbox2`).attr('uid', res.inviteeUid);
$(`.rank-wrap .list .no${index + 1} .nick2`).html(res.inviteeNick.length > 5 ? res.inviteeNick.slice(0, 5) + '...' : res.inviteeNick);
$(`.rank-wrap .list .no${index + 1} .score b`).html(`${res.cpValue > 10000 ? (Math.floor(res.cpValue / 1000) / 10).toFixed(1) + 'w' : res.cpValue}`);
});
// 非前
let str = ``;
notTop1.forEach((res, i) => {
str += `
<li>
<div class="num">${res.ranking}</div>
<div class="txbox1" uid="${res.inviterUid}">
<img src="${res.inviterAvatar}" uid="${res.inviterUid}" class="tx" alt="">
</div>
<div class="txbox2" uid="${res.inviteeUid}">
<img src="${res.inviteeAvatar}" uid="${res.inviteeUid}" class="tx" alt="">
</div>
<div class="nick1">${res.inviterNick.length > 5 ? res.inviterNick.slice(0, 5) + '...' : res.inviterNick}</div>
<div class="nick2">${res.inviteeNick.length > 5 ? res.inviteeNick.slice(0, 5) + '...' : res.inviteeNick}</div>
<img src="./images/xin.png" class="xin" alt="">
<span>情緣值</span>
<div class="score">${res.cpValue > 10000 ? (Math.floor(res.cpValue / 1000) / 10).toFixed(1) + 'w' : res.cpValue}</div>
</li>
`
})
$('.rank-wrap .list ul').append(str);
if (notTop1.length < 9) {
$('.rank-wrap .list ul li').eq(notTop1.length - 1).after(`<li><p>等你來上榜~</p></li>`)
}
if (notTop1.length == 0) {
$('.rank-wrap .list ul').append(`<li><p>等你來上榜~</p></li>`)
}
$('.rank-wrap .list ul li').on('click', '.txbox1,.txbox2', function () {
console.log(123456);
let uid = $(this).attr('uid')
console.log(uid);
if (uid) {
openPerson(uid)
}
})
// 自己排名
if (res.data.meRank) {
if (res.data.meRank.ranking == 0) {
$('.rank-wrap .myRank .num').removeClass('norank')
} else {
$('.rank-wrap .myRank .num').addClass('norank')
}
$('.rank-wrap .myRank .num').html(res.data.meRank.ranking == 0 ? '未上榜' : res.data.meRank.ranking);
$('.rank-wrap .myRank .txbox1 img').attr('src', res.data.meRank.inviterAvatar);
$('.rank-wrap .myRank .txbox2 img').attr('src', res.data.meRank.inviteeAvatar);
$('.rank-wrap .myRank .nick1').text(res.data.meRank.inviterNick.length > 5 ? res.data.meRank.inviterNick.slice(0, 5) + '...' : res.data.meRank.inviterNick)
if(res.data.meRank.inviteeNick){
$('.rank-wrap .myRank .nick2').text(res.data.meRank.inviteeNick.length > 5 ? res.data.meRank.inviteeNick.slice(0, 5) + '...' : res.data.meRank.inviteeNick)
}
$('.rank-wrap .myRank .score').html(`${res.data.meRank.cpValue > 10000 ? (Math.floor(res.data.meRank.cpValue / 1000) / 10).toFixed(1) + 'w' : res.data.meRank.cpValue}`);
}
hideLoading(layerIndex)
} else {
toastMsg(res.message)
hideLoading(layerIndex)
}
},
error(err) {
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 埋点接口
// event去充值=pay_show, 活动规则=rule_click, 排行榜奖励=list_click, 跳转个人主页=pages_click
function sendLog(event) {
networkRequest({
type: 'POST',
url: urlPrefix + '/act/valentineCp/log',
data: { event: event },
success(res) {
if (res.code === 200) {
// console.log(res);
}
},
error(err) {
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 点击跳转个人主页
$('.rank-wrap .list .no1 .tx').click(function () {
let uid = $(this).parent().attr('uid')
if (uid) {
openPerson(uid)
}
})
// 情缘信物投入+
$('.letter-wrap .but .add').click(function () {
let val = $('.letter-wrap .but input').val();
if (val >= 999) {
toastMsg('最多可輸入999')
$('.letter-wrap .but input').val(parseInt(999))
} else {
$('.letter-wrap .but input').val(parseInt(val) + 1)
}
})
// 情缘信物投入-
$('.letter-wrap .but .cut').click(function () {
let val = $('.letter-wrap .but input').val();
if (val <= 1) {
toastMsg('至少投入1')
$('.letter-wrap .but input').val(parseInt(1))
} else {
$('.letter-wrap .but input').val(parseInt(val) - 1)
}
})
// 情缘信物监听输入框
$('.letter-wrap .but').on('input', 'input', function () {
if ($(this).val() >= 999) {
toastMsg('最多可輸入999')
$('.letter-wrap .but input').val(parseInt(999))
} else if ($(this).val() <= 1) {
toastMsg('至少投入1')
$('.letter-wrap .but input').val(parseInt(1))
}
})
// 购买情缘信物按钮
$('.letter-wrap .get_letter').click(function () {
if (nowTime >= endTime) {
toastMsg('活動已結束~')
} else if (nowTime <= startTime) {
toastMsg('活動未開始~')
} else {
let id = $(this).attr('id')
let type = $(this).attr('type')
let num = $('.letter-wrap .but input').val()
if (num == 0) {
toastMsg('至少投入1')
return
}
if (canGet) {
console.log('id:', id, 'num:', num);
buy(id, num, type)
} else {
toastMsg('信物獲取中,請稍後~')
}
}
})
// 兑换好礼按钮输入框
// 投入+
$('.petition-wrap .gift-wrap li .but .add').click(function () {
let liIndex = $(this).parents('li').index()
let val = $('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val();
if (val >= 999) {
toastMsg('最多可輸入999')
$('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val(parseInt(999))
} else {
$('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val(parseInt(val) + 1)
}
})
// 投入-
$('.petition-wrap .gift-wrap li .but .cut').click(function () {
let liIndex = $(this).parents('li').index()
let val = $('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val();
if (val <= 1) {
toastMsg('至少投入1')
$('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val(parseInt(1))
} else {
$('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val(parseInt(val) - 1)
}
})
// 监听输入框
$('.petition-wrap .gift-wrap li').on('input', 'input', function () {
let liIndex = $(this).parents('li').index()
let val = $('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val();
if (val >= 999) {
toastMsg('最多可輸入999')
$('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val(parseInt(999))
} else if (val <= 1) {
toastMsg('至少投入1')
$('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val(parseInt(1))
}
})
// 兑换按钮
$('.petition-wrap .gift-wrap li .btn').click(function () {
let liIndex = $(this).parents('li').index()
let num = $('.petition-wrap .gift-wrap li').eq(liIndex).find('.but input').val();
let id = $('.petition-wrap .gift-wrap li').eq(liIndex).find('.btn').attr('id');
let type = $('.petition-wrap .gift-wrap li').eq(liIndex).find('.btn').attr('type');
buy(id, num, type)
})
// 靓号按钮输入框
// 投入+
$('.petition-wrap .number-wrap .but .add').click(function () {
let val = $('.petition-wrap .number-wrap .but input').val();
if (val >= 999) {
toastMsg('最多可輸入999')
$('.petition-wrap .number-wrap .but input').val(parseInt(999))
} else {
$('.petition-wrap .number-wrap .but input').val(parseInt(val) + 1)
}
})
// 投入-
$('.petition-wrap .number-wrap .but .cut').click(function () {
let val = $('.petition-wrap .number-wrap .but input').val();
if (val <= 1) {
toastMsg('至少投入1')
$('.petition-wrap .number-wrap .but input').val(parseInt(1))
} else {
$('.petition-wrap .number-wrap .but input').val(parseInt(val) - 1)
}
})
// 监听输入框
$('.petition-wrap .number-wrap .but').on('input', 'input', function () {
if ($(this).val() >= 999) {
toastMsg('最多可輸入999')
$('.petition-wrap .number-wrap .but input').val(parseInt(999))
} else if ($(this).val() <= 1) {
toastMsg('至少投入1')
$('.petition-wrap .number-wrap .but input').val(parseInt(1))
}
})
// 抽取靓号
$('.petition-wrap .number-wrap .btn').click(function () {
let id = $(this).attr('id');
let type = $(this).attr('type');
let num = $('.petition-wrap .number-wrap .but input').val();
buy(id, num, type)
})
// 关闭恭喜获得弹窗
$('.gx .gx_in .sure,.close').click(function () {
$('.gx').hide()
})
// 我的cp弹窗
$('.mycp').click(function () {
bodyScroolFun(true)
$('.mycpBox .mycp_in ul li').remove()
$('.mycpBox .mycp_in .box .tips').hide()
myCpList()
})
$('.mycpBox .close').click(function () {
bodyScroolFun(false)
cpOffset()
$('.mycpBox').hide();
})
// 监听我的cp滚动
$('.mycpBox .mycp_in .box').scroll(function () {
let scrollTop = $(this).scrollTop()
let scrollHeight = $('.mycpBox .mycp_in .box')[0].scrollHeight
let ulHeight = $(this).innerHeight()
if (scrollTop + ulHeight + 100 >= scrollHeight) {
$('.mycpBox .mycp_in .tips').show()
}
})
// cp奖励记录弹窗
$('.letter-wrap .cp_record').click(function () {
bodyScroolFun(true)
cpRecordPage = 1;
totalList = 0
$('.cpRecordBox .cpRecord_in .box li').remove();
$('.cpRecordBox .cpRecord_in .tips').hide();
cpRewardRecord(cpRecordPage)
})
$('.cpRecordBox .close').click(function () {
bodyScroolFun(false)
$('.cpRecordBox').hide();
})
// cp奖励记录监听滚动
$('.cpRecordBox .cpRecord_in .box').scroll(function () {
let scrollTop = $(this).scrollTop()
let scrollHeight = $('.cpRecordBox .cpRecord_in .box')[0].scrollHeight
let ulHeight = $(this).innerHeight()
if (scrollTop + ulHeight + 100 >= scrollHeight) {
if (cpRecordScroll) {
cpRecordPage++;
cpRewardRecord(cpRecordPage)
}
}
})
// 兑换好礼/靓号切换
var petitionType = 1 //1:兌換好禮 2:幸運靚號
$('.petition-wrap .chargeTab .item').click(function () {
let index = $(this).index();
$(this).addClass('itemact').siblings().removeClass('itemact')
if (index == 0) {
$('.petition-wrap .gift-wrap').show()
$('.petition-wrap .number-wrap').hide()
$('.petition-wrap .myticket .charge').html('兌換記錄')
petitionType = 1
} else {
$('.petition-wrap .gift-wrap').hide()
$('.petition-wrap .number-wrap').show()
$('.petition-wrap .myticket .charge').html('抽獎記錄')
petitionType = 2
}
})
// 兑换好礼记录/抽奖记录弹窗
$('.petition-wrap .charge').click(function () {
bodyScroolFun(true)
drawPage = 1;
if (petitionType == 1) {
$('.exchangeBox .exchange_in .box li').remove();
$('.exchangeBox .exchange_in .tips').hide();
// $('.exchangeBox').show();
} else {
$('.drawBox .draw_in .box li').remove();
$('.drawBox .draw_in .tips').hide();
// $('.drawBox').show();
}
getDrawRecord(drawPage, petitionType)
})
$('.drawBox .close').click(function () {
bodyScroolFun(false)
$('.drawBox').hide();
})
$('.exchangeBox .close').click(function () {
bodyScroolFun(false)
$('.exchangeBox').hide();
})
// 情签兑换记录监听滚动
$('.exchangeBox .exchange_in .box').scroll(function () {
let scrollTop = $(this).scrollTop()
let scrollHeight = $('.exchangeBox .exchange_in .box')[0].scrollHeight
let ulHeight = $(this).innerHeight()
if (scrollTop + ulHeight + 100 >= scrollHeight) {
if (drawScroll) {
drawPage++;
getDrawRecord(drawPage, petitionType)
}
}
})
// 抽奖记录监听滚动
$('.drawBox .draw_in .box').scroll(function () {
let scrollTop = $(this).scrollTop()
let scrollHeight = $('.drawBox .draw_in .box')[0].scrollHeight
let ulHeight = $(this).innerHeight()
if (scrollTop + ulHeight + 100 >= scrollHeight) {
if (drawScroll) {
drawPage++;
getDrawRecord(drawPage, petitionType)
}
}
})
// 规则弹窗
$('.rule').click(function () {
bodyScroolFun(true)
$('.ruleBox').show();
sendLog('rule_click')
})
$('.ruleBox .close').click(function () {
bodyScroolFun(false)
$('.ruleBox').hide();
})
// 榜單獎勵
$('.rank-wrap .reward').click(function () {
bodyScroolFun(true)
$('.rewardBox').show();
sendLog('list_click')
})
$('.rewardBox .close').click(function () {
bodyScroolFun(false)
$('.rewardBox').hide();
})
// 溫馨提示
$('.tishiBox .close').click(function () {
bodyScroolFun(false)
$('.tishiBox').hide();
})
// 去充值(pay_show=点击去充值埋点)
$('.tishiBox').on('click', '.recharge', function () {
if (browser.app) {
if (browser.android) {
let channel = pubInfo.deviceInfo.channel;
console.log(pubInfo.deviceInfo);
if (channel == "google") {
sendLog('pay_show')
window.androidJsObj.openChargePage(0);
} else {
sendLog('pay_show')
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
}
} else if (browser.ios) {
sendLog('pay_show')
window.webkit.messageHandlers.openChargePage.postMessage(null)
}
} else {
toastMsg('請在app內打開')
}
})
//跳转个人主页 pages_click=跳转主页埋点)
function openPerson(uid) {
if (browser.app) {
if (browser.ios) {
sendLog('pages_click')
window.webkit.messageHandlers.openPersonPage.postMessage(uid);
} else if (browser.android) {
if (androidJsObj && typeof androidJsObj === 'object') {
sendLog('pages_click')
window.androidJsObj.openPersonPage(uid);
}
}
} else {
toastMsg('請在app內打開')
}
}
// 控制body是否可以滑动
function bodyScroolFun(bool) {
if (bool) {
$('body').css('overflow', 'hidden');
} else {
$('body').css('overflow', 'auto');
}
}