Files
eparty-h5/view/eparty/activity/monthlyRecharge/js/index.js

390 lines
14 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
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'
})
}
var countupTime;//倒计时容器
var isLock = true;
var page = 1;
var wealth;
var limitWealth;
// 初始化函數
$(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(() => {
if (browser.android) {
window.androidJsObj.closeWebView()
} else {
window.webkit.messageHandlers.closeWebView.postMessage(null)
}
})
fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言
langReplace = window.lang.replace;
localLang = window.lang;
translateFun();
getConfig();
}, 100)
})
// 处理SVGA
document.addEventListener('DOMContentLoaded', function () {
function loadSVGA(containerId, svgaPath) {
var container = document.getElementById(containerId);
var player = new SVGA.Player(container);
var parser = new SVGA.Parser();
parser.load(svgaPath, function (videoItem) {
player.setVideoItem(videoItem);
player.startAnimation();
});
}
// loadSVGA('zj100', './svga/zj100.svga');
// loadSVGA('zj300', './svga/zj300.svga');
// loadSVGA('zj500', './svga/zj500.svga');
// loadSVGA('zj1000', './svga/zj1000.svga');
});
function translateFun() {
var langReplace = window.lang.replace;
var localLang = window.lang;
$('.text1').text(langReplace(localLang.demoModule.text1));
$('.text2').text(langReplace(localLang.demoModule.text2));
$('.text3').text(langReplace(localLang.demoModule.text3));
$('.text4').text(langReplace(localLang.demoModule.text4));
$('.text5').text(langReplace(localLang.demoModule.text5));
$('.text6').text(langReplace(localLang.demoModule.text6));
$('.text7').text(langReplace(localLang.demoModule.text7));
$('.text8').text(langReplace(localLang.demoModule.text8));
$('.text9').text(langReplace(localLang.demoModule.text9));
$('.text10').text(langReplace(localLang.demoModule.text10));
$('.text11').text(langReplace(localLang.demoModule.text11));
$('.text12').text(langReplace(localLang.demoModule.text12));
$('.text13').text(langReplace(localLang.demoModule.text13));
$('.text14').text(langReplace(localLang.demoModule.text14));
$('.text15').text(langReplace(localLang.demoModule.text15));
$('.text16').text(langReplace(localLang.demoModule.text16));
$('.text26').text(langReplace(localLang.demoModule.text26));
if (browser.android) {
$('.text24').text(langReplace(localLang.demoModule.text25))
} else {
$('.text24').text(langReplace(localLang.demoModule.text24))
}
}
// 配置接口
function getConfig() {
showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '/activity/h5/charge/monthRank',
data: {
uid: pubInfo.uid
// uid: 100014
},
success(res) {
if (res.code === 200) {
wealth = res.data.wealth;
limitWealth = res.data.limitWealth;
// 处理是否我的充值展示
if (res.data.rechargeUser) {
$('.myRecharge').hide();
} else {
$('.myRecharge').show();
}
// 处理倒计时
countup(res.data.endTime - res.timestamp);
// 处理当前余额
$('.myRecharge p b').text('$' + res.data.usb);
$('.myRecharge p .avatar').attr('src', res.data.avatar);
// 渲染档位
res.data.activityLevelUserVo.forEach((res, i) => {
$(`.recharge${i + 1} .bottom .but`).attr('level', res.level);
// 处理按钮状态
if (res.receiveStatus == false) {
if (res.receiveSwitch) {
$(`.recharge${i + 1} .bottom .but`).attr('click', 1);
$(`.recharge${i + 1} .bottom .but`).addClass('act');
} else {
$(`.recharge${i + 1} .bottom .but`).attr('click', 0);
$(`.recharge${i + 1} .bottom .but`).removeClass('act');
}
} else {
$(`.recharge${i + 1} .bottom .but`).attr('click', 0);
$(`.recharge${i + 1} .bottom .but`).removeClass('act');
$(`.recharge${i + 1} .bottom .but`).text(langReplace(localLang.demoModule.text23));
}
// 处理前三
if (wealth > limitWealth) {
res.userVos.forEach((val, index) => {
$(`.recharge${i+1} .bottom .topBox .no${index + 1} .tx`).attr('src', val.avatar);
})
} else {
$(`.recharge${i+1} .bottom .topTitle`).hide();
$(`.recharge${i+1} .bottom .topBox`).hide();
$(`.recharge${i+1} .bottom`).css('height', '2.7rem')
$(`.recharge${i+1} .content`).css('margin-top', '1rem')
$(`.recharge${i+1} .top .title`).css('top', '1.2rem')
}
})
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error(err) {
hideLoading(layerIndex)
toastMsg(langReplace(localLang.demoModule.layerIndex3))
}
})
}
// 跳转充值
$('.myRecharge .but').click(function () {
// if (browser.android) {
// let channel = pubInfo.deviceInfo.channel;
// if (channel == "google") {
// window.androidJsObj.openChargePage(6);
// } else {
// window.location.href = urlPrefix + '/eparty/modules/pay/index.html?channelType=4';
// }
// } else if (browser.ios) {
// let channel = pubInfo.deviceInfo.channel;
// if (channel == "appstore") {
// window.webkit.messageHandlers.openChargePage.postMessage(null);
// } else {
// window.location.href = urlPrefix + '/eparty/modules/pay/index.html?channelType=4';
// }
// }
if(browser.android){
window.androidJsObj.openChargePage(6);
}
})
// 打开规则弹窗
$('.header .rule_icon').click(function () {
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.text17));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.text18));
$('.pub ').show();
bodyScroolFun(true);
})
// 打开我的充值弹窗
$('.myRecharge p img').click(function () {
$('.pub .pub_in .centent').addClass('myRechargeText');
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.text19));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.text20));
$('.pub ').show();
bodyScroolFun(true);
})
// 打开定制礼物弹窗
$('.recharge1000 .content .rewardImg .why').click(function () {
$('.pub .pub_in .centent').addClass('myRechargeTextWhy');
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.text21));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.text22));
$('.pub ').show();
bodyScroolFun(true);
})
// 关闭弹窗
$('.pub .pub_in .close').click(function () {
$('.pub .pub_in .centent').removeClass('myRechargeText');
$('.pub .pub_in .centent').removeClass('myRechargeTextWhy');
$('.pub ').hide();
bodyScroolFun(false);
})
// 倒計時
function countup(leftTime) {
clearTimeout(countupTime)
//獲取當前時間
// var now = nowTime;
var d = 0;
var h = 0;
var m = 0;
var s = 0;
//定義變數 d,h,m,s保存倒計時的時間
var d, h, m, s;
//遞歸每秒調⽤countTime⽅法顯⽰動態時間效果
if (leftTime > 0) {
d = getzf(Math.floor(leftTime / 1000 / 60 / 60 / 24));
h = getzf(Math.floor(leftTime / 1000 / 60 / 60 % 24));
m = getzf(Math.floor(leftTime / 1000 / 60 % 60));
s = getzf(Math.floor(leftTime / 1000 % 60));
//將倒計時賦值到div中
$('.header .time .day b').text(d);
$('.header .time .hour b').text(h);
$('.header .time .min b').text(m);
$('.header .time .sec b').text(s);
} else {
getConfig();
}
if (leftTime > 0) {
leftTime = leftTime - 1000;
}
countupTime = setTimeout(function () {
countup(leftTime);
}, 1000);
}
//补0操作
function getzf(num) {
if (parseInt(num) < 10) {
num = '0' + num;
}
return num;
}
// 领取按钮
$('.recharges .bottom .but').click(function () {
var level = $(this).attr('level');
var click = $(this).attr('click');
if (click == 1) {
showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '/activity/h5/charge/monthRecv',
data: { uid: pubInfo.uid, level },
success(res) {
if (res.code === 200) {
getConfig();
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error(err) {
hideLoading(layerIndex)
toastMsg(langReplace(localLang.demoModule.layerIndex3))
}
})
}
})
// 打开8000座驾弹窗
$('.recharge8000 .content .whyShiping').click(function () {
$('.pub .pub_in .centent').addClass('myRechargeTextWhy');
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.carTitle));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.carText));
$('.pub ').show();
bodyScroolFun(true);
})
// 打开10000座驾弹窗
$('.recharge10000 .content .whyShiping').click(function () {
$('.pub .pub_in .centent').addClass('myRechargeTextWhy');
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.carTitle));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.carText));
$('.pub ').show();
bodyScroolFun(true);
})
// 打开20000座驾弹窗
$('.recharge20000 .content .whyShiping').click(function () {
$('.pub .pub_in .centent').addClass('myRechargeTextWhy');
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.carTitle));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.carText));
$('.pub ').show();
bodyScroolFun(true);
})
// 打开10000头饰弹窗
$('.recharge10000 .content .whyToushi').click(function () {
$('.pub .pub_in .centent').addClass('myRechargeTextWhy');
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.headdressTitle));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.headdressText));
$('.pub ').show();
bodyScroolFun(true);
})
// 打开20000头饰弹窗
$('.recharge20000 .content .whyToushi').click(function () {
$('.pub .pub_in .centent').addClass('myRechargeTextWhy');
$('.pub .pub_in .title').html(langReplace(localLang.demoModule.headdressTitle));
$('.pub .pub_in .centent').html(langReplace(localLang.demoModule.headdressText));
$('.pub ').show();
bodyScroolFun(true);
})
// 打开mp4弹窗
$('.recharge3000 .bo').click(function () {
var video = document.getElementById('zjVideo');
video.play();
bodyScroolFun(true);
$('.video3000').show();
})
// 打开mp4弹窗
$('.recharge5000 .bo').click(function () {
var video = document.getElementById('zjVideo5000');
video.play();
bodyScroolFun(true);
$('.video5000').show();
})
// 打开mp4弹窗
$('.recharge8000 .bo').click(function () {
var video = document.getElementById('zjVideo8000');
video.play();
bodyScroolFun(true);
$('.video8000').show();
})
// 打开mp4弹窗
$('.recharge10000 .bo').click(function () {
var video = document.getElementById('zjVideo10000');
video.play();
bodyScroolFun(true);
$('.video10000').show();
})
// 打开mp4弹窗
$('.recharge20000 .bo').click(function () {
var video = document.getElementById('zjVideo20000');
video.play();
bodyScroolFun(true);
$('.video20000').show();
})
// 关闭mp4弹窗
$('.video .close').click(function () {
var video3000 = document.getElementById('zjVideo3000');
var video5000 = document.getElementById('zjVideo5000');
var video8000 = document.getElementById('zjVideo8000');
var video10000 = document.getElementById('zjVideo10000');
var video20000 = document.getElementById('zjVideo20000');
video.pause();
video3000.pause();
video5000.pause();
video8000.pause();
video10000.pause();
video20000.pause();
bodyScroolFun(false);
$('.video').hide();
})
// 监听播放完毕事件
var video = document.getElementById('zjVideo');
video.addEventListener('ended', function () {
video.pause();
bodyScroolFun(false);
$('.video').hide();
});