Files
peko-h5/view/peko/home/js/index.js
2024-01-22 21:52:55 +08:00

202 lines
6.9 KiB
JavaScript

let urlPrefix = getUrlPrefix()
let browser = checkVersion()
// 封装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 () {
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);
if (browser.ios) {
url = ios;
} else if (browser.android) {
url = and;
}
console.log(and, ios);
// if (androidSkipType == 0) {
// }
hideLoading(layerIndex)
animatedImplementFun(0);
},
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}%)`);
console.log('上滑');
animatedImplementFun(index);
}
}
//下滑
else if (endY - startY >= 50) {
if (index > 0) {
index = index - 1;
$('.pagesBox').css("transform", `translateY(-${index * touchLength}%)`);
console.log('下滑');
animatedImplementFun(index);
}
}
})
// 动画调用
function animatedImplementFun (index) {
if (index == 0) {
animatedFun($(`body .h5 .pagesBox .page1 .pageTxte1`), ['animate__zoomInUp',]);
animatedFun($(`body .h5 .pagesBox .page1 .h5Ios`), ['animate__fadeInLeft',]);
animatedFun($(`body .h5 .pagesBox .page1 .h5And`), ['animate__fadeInRight',]);
} else if (index == 1) {
animatedFun($(`body .h5 .pagesBox .page2 .pageText2`), ['animate__bounce',]);
animatedFun($(`body .h5 .pagesBox .page2 .pagetx1`), ['animate__heartBeat',]);
animatedFun($(`body .h5 .pagesBox .page2 .pagetx2`), ['animate__heartBeat',]);
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 .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 .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').click(function () {
window.location.href = 'https://api.pekolive.com/peko/modules/pay/index.html?channelType=4'
})
// PC苹果下载按钮
$('body .pc .pcIos, html .pc .pcIos').click(function () {
window.location.href = ios;
})
// PC安卓下载按钮
$('body .pc .pcIos, html .pc .pcAnd').click(function () {
window.location.href = and;
})
// h5跳转充值
$('body .header .diamound, html .header .diamound').click(function () {
window.location.href = 'https://api.pekolive.com/peko/modules/pay/index.html?channelType=4'
})
// h5展开菜单
$('body .header .more, html .header .more').click(function () {
$('.menu').css("height", "100%");
})
// h5收起菜单
$('body .h5 .menu .top .close, html .h5 .menu .top .close').click(function () {
$('.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("height", "0%");
$('.pagesBox').css("transform", `translateY(-${0}%)`);
} else if (i == 2) {
window.location.href = '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 () {
window.location.href = and;
})
// h5首页苹果下载
$('body .h5 .pagesBox .page1 .h5Ios').click(function () {
window.location.href = ios;
})
// h5自动识别普通下载
$('body .h5 .pagesBox .pages .downioad').click(function () {
if (browser.ios) {
window.location.href = ios;
} else if (browser.android) {
window.location.href = and;
}
})