278 lines
9.8 KiB
JavaScript
278 lines
9.8 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 ios;
|
|
var and;
|
|
var url;
|
|
var androidSkipType;
|
|
var iosSkipType;
|
|
// 初始化函數
|
|
$(function () {
|
|
$(document).ready(function () {
|
|
var deviceWidth = document.documentElement.clientWidth;
|
|
if (deviceWidth > 768) {
|
|
document.documentElement.style.fontSize = deviceWidth / 19.20 + 'px';
|
|
} else {
|
|
// document.documentElement.style.fontSize = deviceWidth / 7.50 + 'px';
|
|
}
|
|
});
|
|
window.onresize = function () {
|
|
var deviceWidth = document.documentElement.clientWidth;
|
|
// console.log('deviceWidth', deviceWidth);
|
|
if (deviceWidth > 768) {
|
|
document.documentElement.style.fontSize = deviceWidth / 19.20 + 'px';
|
|
} else {
|
|
// document.documentElement.style.fontSize = deviceWidth / 7.50 + 'px';
|
|
}
|
|
}
|
|
getInfoFromClient();
|
|
getConfig();
|
|
})
|
|
// 獲取配置接口
|
|
function getConfig () {
|
|
showLoading();
|
|
networkRequest({
|
|
type: 'GET',
|
|
url: urlPrefix + '/official/config',
|
|
success (res) {
|
|
// 處理聯繫方式
|
|
$(`.contactUs_pub .contactUs_pub_in ul .li1 span`).html(`<b>Wehchat:</b> ${res.data.contact0}`);
|
|
$(`.contactUs_pub .contactUs_pub_in ul .li2 span`).html(`<b>Line:</b> ${res.data.contact1}`);
|
|
$(`.contactUs_pub .contactUs_pub_in ul .li3 span`).html(`<b>Email:</b> ${res.data.contact2}`);
|
|
// 賦值下載
|
|
and = res.data.androidUrl;
|
|
ios = res.data.iosUrl;
|
|
androidSkipType = res.data.androidSkipType;
|
|
iosSkipType = res.data.iosSkipType;
|
|
// console.log(browser);
|
|
$('body .h5 .pagesBox .pages .downioad').show();
|
|
if (browser.ios) {
|
|
url = ios;
|
|
$('body .h5 .pagesBox .pages .downioad').attr('src', './images/h5Ios.png');
|
|
} else if (browser.android) {
|
|
url = and;
|
|
$('body .h5 .pagesBox .pages .downioad').attr('src', './images/h5And.png');
|
|
}
|
|
$('body .h5 .pagesBox .page2 .downioad,body .h5 .pagesBox .page3 .downioad,body .h5 .pagesBox .page4 .downioad').attr('src', './images/downioad.png');
|
|
$('.pc-bg').show();
|
|
hideLoading(layerIndex)
|
|
animatedImplementFun(0);
|
|
},
|
|
error (err) {
|
|
hideLoading(layerIndex)
|
|
}
|
|
})
|
|
}
|
|
// 点击记录接口
|
|
function officialClick (downloadType, downloadUrl) {
|
|
// showLoading();
|
|
networkRequest({
|
|
type: 'GET',
|
|
url: urlPrefix + '/official/click',
|
|
data: { downloadType, downloadUrl },
|
|
success (res) {
|
|
},
|
|
error (err) {
|
|
hideLoading(layerIndex)
|
|
}
|
|
})
|
|
}
|
|
// 監聽滑動事件
|
|
let startY
|
|
var length = $('.h5 .pages').length - 1;//
|
|
var index = 0;
|
|
var touchLength = 100;
|
|
$('body .h5').on('touchstart', function (e) {
|
|
startY = e.touches[0].pageY
|
|
})
|
|
$('body .h5').on('touchend', function (e) {
|
|
let endY = e.originalEvent.changedTouches[0].pageY
|
|
// 上滑
|
|
if (startY - endY >= 50) {
|
|
if (index > length - 1) {
|
|
return;
|
|
} else {
|
|
index = index + 1;
|
|
$('.pagesBox').css("transform", `translateY(-${index * touchLength}%)`);
|
|
animatedImplementFun(index);
|
|
}
|
|
}
|
|
//下滑
|
|
else if (endY - startY >= 50) {
|
|
if (index > 0) {
|
|
index = index - 1;
|
|
$('.pagesBox').css("transform", `translateY(-${index * touchLength}%)`);
|
|
animatedImplementFun(index);
|
|
}
|
|
}
|
|
})
|
|
// 動畫調用
|
|
function animatedImplementFun (index) {
|
|
if (index == 0) {
|
|
animatedFun($(`body .h5 .pagesBox .page1 .pageTxte1`), ['animate__fadeInLeft',]);
|
|
animatedFun($(`body .h5 .pagesBox .page1 .pageTxte2`), ['animate__fadeInRight',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page1 .downioad`), ['animate__wobble',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page1 .down`), ['animate__slideInDown',]);
|
|
} else if (index == 1) {
|
|
// animatedFun($(`body .h5 .pagesBox .page2 .pageText2`), ['animate__bounce',]);
|
|
animatedFun($(`body .h5 .pagesBox .page2 .pagetx1`), ['animate__bounceInRight',]);
|
|
animatedFun($(`body .h5 .pagesBox .page2 .pagetx2`), ['animate__bounceInLeft',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page2 .down`), ['animate__slideInDown',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page2 .downioad`), ['animate__wobble',]);
|
|
} else if (index == 2) {
|
|
// animatedFun($(`body .h5 .pagesBox .page3 .pageText3`), ['animate__rubberBand',]);
|
|
animatedFun($(`body .h5 .pagesBox .page3 .page3Icon1`), ['animate__lightSpeedInRight',]);
|
|
animatedFun($(`body .h5 .pagesBox .page3 .page3Icon2`), ['animate__lightSpeedInLeft',]);
|
|
animatedFun($(`body .h5 .pagesBox .page3 .page3Icon3`), ['animate__lightSpeedInRight',]);
|
|
animatedFun($(`body .h5 .pagesBox .page3 .page3Icon4`), ['animate__lightSpeedInLeft',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page3 .down`), ['animate__slideInDown',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page3 .downioad`), ['animate__slideInUp',]);
|
|
|
|
} else if (index == 3) {
|
|
// animatedFun($(`body .h5 .pagesBox .page4 .pageText4 `), ['animate__rubberBand',]);
|
|
animatedFun($(`body .h5 .pagesBox .page4 .page4Icon1 `), ['animate__lightSpeedInLeft',]);
|
|
animatedFun($(`body .h5 .pagesBox .page4 .page4Icon2 `), ['animate__lightSpeedInRight',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page4 .down`), ['animate__slideInDown',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page4 .downioad `), ['animate__slideInUp',]);
|
|
} else if (index == 4) {
|
|
// animatedFun($(`body .h5 .pagesBox .page5 .pageTxte5 `), ['animate__jackInTheBox',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page5 .contactUs `), ['animate__flipInY',]);
|
|
// animatedFun($(`body .h5 .pagesBox .page5 .downioad `), ['animate__slideInUp',]);
|
|
}
|
|
}
|
|
// 處理動畫
|
|
function animatedFun (dom, arrClass) {
|
|
// 獲取元素
|
|
const element = dom;
|
|
// 添加動畫
|
|
element.addClass(...arrClass);
|
|
// 監聽動畫結束
|
|
element[0].addEventListener('animationend', () => {
|
|
element.removeClass(...arrClass);
|
|
});
|
|
}
|
|
// pc跳轉充值
|
|
$('body .pc .header .diamound, html .pc .header .diamound,body .homePc .diamound, html .homePc .diamound').click(function () {
|
|
window.location = 'https://api.pekolive.com/peko/modules/payPc/index.html?channelType=4'
|
|
})
|
|
// PC蘋果下載按鈕
|
|
$('html .pc .pcIos').click(function () {
|
|
if (ios) {
|
|
officialClick(0, ios);
|
|
window.location = ios;
|
|
} else {
|
|
toastMsg('暫未開放下載,詳情請聯繫客服')
|
|
}
|
|
})
|
|
// PC安卓下載按鈕
|
|
$('html .pc .pcAnd').click(function () {
|
|
if (and) {
|
|
officialClick(1, and);
|
|
window.location = and;
|
|
} else {
|
|
toastMsg('暫未開放下載,詳情請聯繫客服')
|
|
}
|
|
})
|
|
// h5跳轉充值
|
|
$('body .header .diamound, html .header .diamound').click(function () {
|
|
window.location = 'https://api.pekolive.com/peko/modules/pay/index.html?channelType=4'
|
|
})
|
|
// h5展開菜單
|
|
$('body .header .more, html .header .more').click(function () {
|
|
$('.menu').css("z-index", "4");
|
|
$('.menu').css("height", "100%");
|
|
})
|
|
// h5收起菜單
|
|
$('body .h5 .menu .top .close, html .h5 .menu .top .close').click(function () {
|
|
$('.menu').css("z-index", "1");
|
|
$('.menu').css("height", "0%");
|
|
})
|
|
// 菜單選項按鈕
|
|
$('body .h5 .menu ul li, html .h5 .menu ul li').click(function () {
|
|
var i = $(this).index() + 1;
|
|
if (i == 1) {
|
|
$('.menu').css("z-index", "1");
|
|
$('.menu').css("height", "0%");
|
|
$('.pagesBox').css("transform", `translateY(-${0}%)`);
|
|
index = 0;
|
|
} else if (i == 2) {
|
|
window.location = 'https://api.pekolive.com/peko/modules/h5Income/login.html'
|
|
} else {
|
|
$('.menu').css("height", "0%");
|
|
$('.contactUs_pub').show();
|
|
}
|
|
})
|
|
// 關閉聯繫我們彈窗
|
|
$('body .contactUs_pub .contactUs_pub_in .sClose').click(function () {
|
|
$('.contactUs_pub').hide();
|
|
})
|
|
// 打開聯繫我們彈窗
|
|
$('.page5 .contactUs').click(function () {
|
|
$('.contactUs_pub').show();
|
|
})
|
|
// h5首頁安卓下載
|
|
$('body .h5 .pagesBox .page1 .h5And').click(function () {
|
|
if (and) {
|
|
officialClick(1, and);
|
|
window.location = and;
|
|
} else {
|
|
toastMsg('暫未開放下載,詳情請聯繫客服')
|
|
}
|
|
})
|
|
// h5首頁蘋果下載
|
|
$('body .h5 .pagesBox .page1 .h5Ios').click(function () {
|
|
if (ios) {
|
|
officialClick(0, ios);
|
|
window.location = ios;
|
|
} else {
|
|
toastMsg('暫未開放下載,詳情請聯繫客服')
|
|
}
|
|
})
|
|
// h5自動識別普通下載
|
|
$('body .h5 .pagesBox .pages .downioad').click(function () {
|
|
if (url) {
|
|
if (browser.ios) {
|
|
officialClick(0, url);
|
|
window.location = url;
|
|
} else if (browser.android) {
|
|
officialClick(1, url);
|
|
window.location = url;
|
|
} else {
|
|
$('.menu').css("z-index", "1");
|
|
$('.pagesBox').css("transform", `translateY(-${0}%)`);
|
|
index = 0;
|
|
}
|
|
} else {
|
|
toastMsg('暫未開放下載,詳情請聯繫客服')
|
|
}
|
|
})
|
|
// 禁止瀏覽器下拉刷新
|
|
|
|
document.addEventListener('touchmove', event => {
|
|
event.preventDefault()
|
|
}, { passive: false }) |