1330 lines
40 KiB
JavaScript
1330 lines
40 KiB
JavaScript
|
||
//import $ from 'jquery';
|
||
import ConfigsJs from '../class/config.js';
|
||
import {storageObj,getLoginStatus,getUserInfo} from '../public/localstorage.js';
|
||
import Gettime from './time.js';
|
||
import LazyLoadingJs from '../class/lozyLoading.js';
|
||
import HeadJs from './head.js';
|
||
import CommonCctv from '../cctv/common.js';
|
||
//import layer from '../plugin/layer/layer.js';
|
||
|
||
const Configs = new ConfigsJs();
|
||
|
||
import { apiSaveStaTis,apiGetUserInfo} from '../public/api/index.js';
|
||
import { fetchApi,onError} from '../public/api/fetch.js';
|
||
|
||
const publicJs = {
|
||
strEquipmentCode: 'ios',
|
||
intEquipmentNumber: 3,
|
||
arrHideDomClass: [],
|
||
arrShowDomClass: [],
|
||
}
|
||
|
||
/**
|
||
* 公共初始化
|
||
*/
|
||
export function init() {
|
||
|
||
$(function () {
|
||
|
||
intCss()
|
||
|
||
memberCountDown()
|
||
|
||
//加载图片
|
||
const LazyLoading = new LazyLoadingJs();
|
||
LazyLoading.int()
|
||
|
||
initAddEvent()
|
||
|
||
outPutLog(navigator.userAgent)
|
||
|
||
//轮播加载
|
||
new Swiper('.swiper_top_pblic .swiper-container', {
|
||
pagination: '.swiper_top_pblic .swiper-pagination',
|
||
autoplay: {
|
||
delay: 5000,
|
||
},
|
||
slidesPerView: 1,
|
||
paginationClickable: true,
|
||
spaceBetween: 0,
|
||
loop: true,
|
||
});
|
||
|
||
//轮播加载-九宫格
|
||
intSwiperInCctvJiugongge()
|
||
|
||
CommonCctv.initBannerBottomPiao()
|
||
|
||
// scroll监听
|
||
document.onscroll = function () {
|
||
let onscroll_Top = document.documentElement.scrollTop || document.body.scrollTop;
|
||
if (onscroll_Top >= 200) {
|
||
$("#btnGotop").removeClass("yc")
|
||
} else {
|
||
$("#btnGotop").addClass("yc")
|
||
}
|
||
if (onscroll_Top > 50) {
|
||
$(".head_nav_logo").addClass("head_nav_black_logo")
|
||
} else {
|
||
$(".head_nav_logo").removeClass("head_nav_black_logo")
|
||
}
|
||
|
||
if(document.querySelector('.guide-right')){
|
||
var guideRight = document.querySelector('.guide-right');
|
||
var listTabs = document.querySelector('.list-tabs');
|
||
var guideRightRect = guideRight.getBoundingClientRect();
|
||
var listTabsRect = listTabs.getBoundingClientRect();
|
||
if (
|
||
guideRightRect.bottom > listTabsRect.top &&
|
||
guideRightRect.top < listTabsRect.bottom
|
||
) {
|
||
guideRight.style.visibility = 'hidden';
|
||
} else {
|
||
guideRight.style.visibility = 'visible';
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 转换HTTP链接为迅雷下载链接
|
||
* @param {String} strHttpUrl - 原始HTTP下载链接
|
||
* @return {String} 转换后的迅雷下载链接
|
||
*/
|
||
export function createThunderLink(strHttpUrl) {
|
||
const strThunderUrl = btoa('AA' + encodeURIComponent(strHttpUrl) + 'ZZ');
|
||
return 'thunder://' + strThunderUrl;
|
||
}
|
||
|
||
|
||
/**
|
||
* 创建并返回一个可以唤起FlashGet下载的链接
|
||
* @param {String} strDownloadUrl - 原始的下载链接
|
||
* @return {String} 生成的FlashGet下载链接
|
||
*/
|
||
export function createFlashGetLink(strDownloadUrl) {
|
||
|
||
// 对下载链接进行编码
|
||
const strEncodedUrl = encodeURIComponent(strDownloadUrl);
|
||
|
||
// FlashGet链接的协议和格式
|
||
const strFlashGetPrefix = 'flashget://';
|
||
const strFlashGetDownloadUrl = `${strFlashGetPrefix}${strEncodedUrl}`;
|
||
|
||
//const strFlashGetSuffix = '&[http://www.yourwebsite.com]';
|
||
// const strFlashGetDownloadUrl = `${strFlashGetPrefix}${strEncodedUrl}${strFlashGetSuffix}`;
|
||
|
||
return strFlashGetDownloadUrl;
|
||
}
|
||
|
||
/**
|
||
* 设备信息 浏览器信息判断
|
||
* @returns obj
|
||
*/
|
||
export function detectBrowser() {
|
||
var userAgent = navigator.userAgent;
|
||
if (/QQBrowser/i.test(userAgent)) {
|
||
return "QQ";
|
||
} else if (/UCBrowser/i.test(userAgent)) {
|
||
return "UC";
|
||
} else if (/BIDUBrowser/i.test(userAgent)) {
|
||
return "Baidu";
|
||
} else if (/Quark/i.test(userAgent)) {
|
||
return "Quark";
|
||
} else if (/360SE/i.test(userAgent)) {
|
||
return "360";
|
||
} else if (/iPhone|iPad|iPod/i.test(userAgent)) {
|
||
return "iOS";
|
||
} else if (/(?:Android)/.test(userAgent)) {
|
||
return "Android";
|
||
} else {
|
||
return "other";
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 设备信息 浏览器信息判断
|
||
* @returns obj
|
||
*/
|
||
export function Equipment() {
|
||
var ua = navigator.userAgent,
|
||
isWindowsPhone = /(?:Windows Phone)/.test(ua),
|
||
isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
|
||
isAndroid = /(?:Android)/.test(ua),
|
||
isFireFox = /(?:Firefox)/.test(ua),
|
||
isChrome = /(?:Chrome|CriOS)/.test(ua),
|
||
isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
|
||
isPhone = /(?:iPhone)/.test(ua) && !isTablet,
|
||
isPc = !isPhone && !isAndroid && !isSymbian;
|
||
return {
|
||
isTablet: isTablet,
|
||
isPhone: isPhone,
|
||
isAndroid: isAndroid,
|
||
isPc: isPc
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 返回浏览器标识
|
||
* @returns str
|
||
*/
|
||
export function detectBrowserOrDevice() {
|
||
|
||
let strUserAgent = navigator.userAgent.toLowerCase();
|
||
|
||
if (strUserAgent.includes('ucbrowser') || strUserAgent.includes('ucweb')) {
|
||
return 'UCBrowser';
|
||
}
|
||
|
||
if (strUserAgent.includes('quark')) {
|
||
return 'QuarkBrowser';
|
||
}
|
||
|
||
if (strUserAgent.includes('vivo')) {
|
||
return 'VIVODevice';
|
||
}
|
||
|
||
if (strUserAgent.includes('qq') || strUserAgent.includes('QQ')) {
|
||
return 'QQBrowser';
|
||
}
|
||
|
||
if (strUserAgent.includes('baidu') || strUserAgent.includes('Baidu')) {
|
||
return 'BaiduBrowser';
|
||
}
|
||
|
||
return 'Unknown';
|
||
}
|
||
|
||
|
||
/**
|
||
* 判断是否360 浏览器
|
||
* @returns str
|
||
*/
|
||
export function is360Browser() {
|
||
var ua = navigator.userAgent.toLowerCase();
|
||
var is360 = false;
|
||
|
||
// 检测外壳类型
|
||
var isChrome = ua.indexOf('chrome') > -1;
|
||
var isIEOrEdge = ua.indexOf('trident') > -1 || ua.indexOf('edge/') > -1;
|
||
|
||
// 使用mime类型判断
|
||
function mime(where, value) {
|
||
var mimeTypes = navigator.mimeTypes;
|
||
for (var mt in mimeTypes) {
|
||
if (mimeTypes[mt][where] === value) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// 通过特定的mime类型判断360浏览器
|
||
if (mime('type', 'application/vnd.chromium.remoting-viewer')) {
|
||
// 判断是否为360极速浏览器
|
||
if(isChrome && typeof window.chrome !== "undefined") {
|
||
is360 = true;
|
||
}
|
||
// 判断是否为360安全浏览器
|
||
else if (isIEOrEdge) {
|
||
is360 = true;
|
||
}
|
||
}
|
||
|
||
return is360;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 公共跳转点击事件
|
||
* @param {string} strHref
|
||
* @param int intId
|
||
* @param int intStatisticsType
|
||
* @param int intOnsiteOrOffsite
|
||
*/
|
||
export function clickEvent(strHref, intId, intStatisticsType = 5, intOnsiteOrOffsite = 501) {
|
||
|
||
// 增加点击统计
|
||
fetchStatistics(intId, intStatisticsType)
|
||
|
||
if (intOnsiteOrOffsite == 501) {
|
||
//站外链接
|
||
operationAdomJump(strHref)
|
||
} else {
|
||
//站内链接
|
||
//中文链接 不需要 base64
|
||
operationAdomJump(strHref, false)
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 返回历史记录页面
|
||
* @param {number} stepsBackwards 要回退的步数
|
||
*/
|
||
export function navigateBackFn(stepsBackwards) {
|
||
|
||
const historyStack = JSON.parse(localStorage.getItem('historyStack')) || [];
|
||
const restrictedPaths = ['/member/login.html', '/member/register.html', '/member/email-retrieve-passw.html', '/member/retrieve-password.html','/member/email-verification.html'];
|
||
|
||
// 先将要回退的URLs弹出堆栈
|
||
for (let i = 0; i < stepsBackwards && historyStack.length; i++) {
|
||
historyStack.pop();
|
||
}
|
||
|
||
// 从堆栈中取一个URL
|
||
let targetURL = historyStack.pop();
|
||
|
||
// 如果目标URL包含受限制的路径,则继续向后回退
|
||
while (targetURL && restrictedPaths.some(path => targetURL.includes(path))) {
|
||
targetURL = historyStack.pop();
|
||
}
|
||
|
||
// 存储更新后的历史堆栈
|
||
localStorage.setItem('historyStack', JSON.stringify(historyStack));
|
||
|
||
// 如果 targetURL 为 undefined 或者堆栈为空,则默认跳转到 '/home.html'
|
||
window.location.href = targetURL || '/home.html';
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 公共元素-绑定点击事件-初始化
|
||
*/
|
||
export function initAddEvent() {
|
||
// 点击 遮挡层 关闭登录提示弹窗
|
||
$(".j-close-occlusion-popous").on("click", () => {
|
||
tapOcclusionLayerHidePopUp()
|
||
});
|
||
|
||
// 点击电影搜索触发搜索框
|
||
$('a.searchmovie').on("click", () => {
|
||
$('input.sinput').focus();
|
||
});
|
||
|
||
//h5点击搜索按钮
|
||
$(".searchstart-on").on("click", () => {
|
||
$("#search_input_h5").removeClass("yc")
|
||
$(this).children().addClass('yc')
|
||
})
|
||
//h5点击搜索按钮x
|
||
$(".remove_search_btn").on("click", () => {
|
||
$("#search_input_h5").addClass("yc")
|
||
$(".searchstart-on").children().removeClass('yc')
|
||
})
|
||
//h5点击显示侧边导航按钮
|
||
$(".sitenav-on").on("click", () => {
|
||
$(".left-head-nav").animate({
|
||
left: '0',
|
||
});
|
||
})
|
||
//h5点击关闭侧边导航按钮x
|
||
$(".sitenav-off").on("click", () => {
|
||
$(".left-head-nav").animate({
|
||
left: '-500px',
|
||
});
|
||
})
|
||
|
||
// 点击 回到顶部
|
||
$(".j-btn-go-top").on("click", () => {
|
||
document.body.scrollTop = 0;
|
||
document.documentElement.scrollTop = 0;
|
||
})
|
||
|
||
// 点击 悬浮按钮 刷新
|
||
$(".j-btn-reload").on("click", () => {
|
||
window.location.reload();
|
||
})
|
||
|
||
// 分享
|
||
$(".j-share").on("click", function () {
|
||
|
||
let strDom = $(this).attr('data-sharedom');
|
||
let strCopyVal = $(this).attr('data-copyval') ?? '复制成功,打开微信,发给色友';
|
||
let strShareHref = setShareHref(Configs.get('SHARE_DOMAIN'));
|
||
let strShareContent = `
|
||
<div >
|
||
${document.title}<br>
|
||
${strShareHref}<br>
|
||
迅速来围观<br>
|
||
微信如果打不开就复制地址浏览器打开<br>
|
||
包括复制的内容也不一样。<br>
|
||
</div>
|
||
`
|
||
$(strDom).val(strShareHref)
|
||
copyFun(strDom, strCopyVal)
|
||
if (navigator.share) {
|
||
navigator.share({
|
||
title: Configs.get('WEB_NAME') + '-' + document.title,
|
||
text: strShareContent,
|
||
url: strShareHref
|
||
}).then(() => {
|
||
console.log('Thanks for sharing!');
|
||
})
|
||
.catch(console.error);
|
||
}
|
||
})
|
||
|
||
// 复制-
|
||
$(".j-copy").on("click", function () {
|
||
let strDom = $(this).attr('data-dom');
|
||
let strCopyVal = $(this).attr('data-cp-val') ?? '复制成功';
|
||
//copyFun(strDom, strCopyVal)
|
||
copyByInput(strDom, strCopyVal)
|
||
})
|
||
|
||
// 复制-input
|
||
$(".j-copy-input").on("click", function () {
|
||
let strDom = $(this).attr('data-dom');
|
||
let strCopyVal = $(this).attr('data-cp-val') ?? '复制成功';
|
||
//copyFun(strDom, strCopyVal)
|
||
copyByInput(strDom, strCopyVal)
|
||
})
|
||
|
||
// 复制-非input
|
||
$(".j-copy-select").on("click", function () {
|
||
let strDom = $(this).attr('data-dom');
|
||
let strCopyVal = $(this).attr('data-cp-val') ?? '复制成功';
|
||
copyFun(strDom, strCopyVal)
|
||
})
|
||
|
||
// 客服击点击
|
||
$(".j-customer-service-click").on("click", (event) => {
|
||
let DomCurrent = event.currentTarget
|
||
let strHref = $(DomCurrent).attr('data-href') ?? '/home.html';
|
||
let strType = $(DomCurrent).attr('data-gotype') ?? 1;
|
||
if(checkIsLoginFn()){
|
||
strType = 2
|
||
pageJumpFn({ 'url': strHref, 'url_type': strType })
|
||
}
|
||
|
||
})
|
||
|
||
// 站点元素点击
|
||
$(".j-event-click").on("click", (event) => {
|
||
let DomCurrent = event.currentTarget
|
||
let strHref = $(DomCurrent).attr('data-href') ?? '/home.html';
|
||
let strType = $(DomCurrent).attr('data-gotype') ?? 1;
|
||
pageJumpFn({ 'url': strHref, 'url_type': strType })
|
||
})
|
||
|
||
$(".dialog-close").on('click', function () {
|
||
$('.msg-dialog').hide();
|
||
$('.msg-dialog2').hide();
|
||
$('.vip-dialog').hide();
|
||
$('#custom-dialog-ADO3').hide();
|
||
});
|
||
|
||
// 悬浮按钮 分享
|
||
$(".share_make_money").on('click', function () {
|
||
$(".share_make_money .open").show()
|
||
$(".share_make_money .no-open").hide()
|
||
let time = setTimeout(() => {
|
||
pageJumpFn({ 'url': '/member/my-promotion.html', 'url_type': 1 })
|
||
clearTimeout(time)
|
||
}, 100)
|
||
});
|
||
|
||
|
||
$(".btnGoBack").on('click', function () {
|
||
navigateBackFn(1)
|
||
});
|
||
|
||
|
||
}
|
||
|
||
/**
|
||
* 轮播加载-九宫格
|
||
*/
|
||
export function intSwiperInCctvJiugongge() {
|
||
if (document.querySelector(".list-tabs")) {
|
||
var nameArr = ['热门推荐', '成人游戏', '在线约炮', '赚钱娱乐'];
|
||
new Swiper('.list-tabs .swiper-container', {
|
||
pagination: {
|
||
el: '.list-tabs .list-tabs-header',
|
||
clickable: true,
|
||
renderBullet: function (index, className) {
|
||
return '<div class="list-tabs-item ' + className + '">' + nameArr[index] + '</div>';
|
||
},
|
||
},
|
||
on: {
|
||
progress: function (progress) {
|
||
var left = progress.progress * (nameArr.length - 1) / (nameArr.length)
|
||
$('.list-tabs-slider').css("left", left * 100 + "%")
|
||
let height = 230
|
||
if (progress.progress == '-0') {
|
||
height = $(".Boutique-list").height()
|
||
let time = setInterval(() => {
|
||
if (progress.progress == '-0') {
|
||
$(".swipercctv").height($(".Boutique-list").height())
|
||
clearInterval(time)
|
||
}
|
||
}, 100 * 70)
|
||
}
|
||
if (progress.progress == '0.3333333333333333') {
|
||
height = $(".live-broadcast-list").height()
|
||
let time = setInterval(() => {
|
||
if (progress.progress == '0.3333333333333333') {
|
||
$(".swipercctv").height($(".live-broadcast-list").height())
|
||
clearInterval(time)
|
||
}
|
||
}, 100 * 70)
|
||
}
|
||
if (progress.progress == '0.6666666666666666') {
|
||
height = $(".kall-warp").height()
|
||
let time = setInterval(() => {
|
||
if (progress.progress == '0.6666666666666666') {
|
||
$(".swipercctv").height($(".kall-warp").height())
|
||
clearInterval(time)
|
||
}
|
||
}, 100 * 70)
|
||
}
|
||
if (progress.progress == '1') {
|
||
height = $(".games-warp").height()
|
||
let time = setInterval(() => {
|
||
if (progress.progress == '1') {
|
||
$(".swipercctv").height($(".games-warp").height())
|
||
clearInterval(time)
|
||
}
|
||
}, 100 * 70)
|
||
}
|
||
if (progress.progress < '-0.01') {
|
||
height = $(".Boutique-list").height()
|
||
}
|
||
if (progress.progress > '-0.3') {
|
||
height = $(".Boutique-list").height()
|
||
}
|
||
if (progress.progress > '0.01') {
|
||
height = $(".live-broadcast-list").height()
|
||
}
|
||
if (progress.progress > '0.34') {
|
||
height = $(".kall-warp").height()
|
||
}
|
||
if (progress.progress > '0.67') {
|
||
height = $(".games-warp").height()
|
||
}
|
||
$(".swipercctv").height(height)
|
||
},
|
||
},
|
||
autoplay: false,
|
||
slidesPerView: 1,
|
||
paginationClickable: true,
|
||
spaceBetween: 10,
|
||
loop: false,
|
||
});
|
||
|
||
setTimeout(() => {
|
||
$(".swipercctv").height($(".Boutique-list").height())
|
||
}, 2000)
|
||
setTimeout(() => {
|
||
$(".swipercctv").height($(".Boutique-list").height())
|
||
}, 5000)
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 终身会员倒计时
|
||
*/
|
||
export function memberCountDown() {
|
||
setInterval(() => {
|
||
var djs_time = localStorage.getItem('djs_time')
|
||
if (djs_time) {
|
||
if (djs_time < 1 * 60 * 60) {
|
||
djs_time = 23 * 60 * 60
|
||
}
|
||
djs_time -= 1
|
||
} else {
|
||
djs_time = 23 * 60 * 60
|
||
}
|
||
localStorage.setItem('djs_time', djs_time)
|
||
var djs_obj = Gettime.TimeFramtHms(djs_time * 1000)
|
||
var djs_str = djs_obj.h + ':' + djs_obj.m + ':' + djs_obj.s
|
||
$(".djs_time").text(djs_str)
|
||
}, 1000)
|
||
}
|
||
|
||
export function intCss() {
|
||
(function (c, d) {
|
||
var e = document.documentElement || document.body,
|
||
a = "orientationchange" in window ? "orientationchange" : "resize",
|
||
b = function () {
|
||
var f = e.clientWidth;
|
||
e.style.fontSize = (f >= 750) ? "16px" : 100 * (f / 750) + "px"
|
||
};
|
||
b();
|
||
c.addEventListener(a, b, false)
|
||
})(window);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 前端根据类名显示隐藏,不同设备的广告
|
||
* return viod
|
||
*/
|
||
export function hideCctvDomByEquipmentClass() {
|
||
if (Equipment().isPhone) {
|
||
publicJs.strEquipmentCode = 'ios';
|
||
publicJs.intEquipmentNumber = 3;
|
||
publicJs.arrHideDomClass = ['.equipment_pc', '.equipment_android', '.equipment_pc_android']
|
||
publicJs.arrShowDomClass = ['.equipment_ios', '.equipment_pc_ios', '.equipment_h5']
|
||
} else if (Equipment().isAndroid) {
|
||
publicJs.strEquipmentCode = 'android';
|
||
publicJs.intEquipmentNumber = 2;
|
||
publicJs.arrHideDomClass = ['.equipment_pc', '.equipment_ios', '.equipment_pc_ios']
|
||
publicJs.arrShowDomClass = ['.equipment_android', '.equipment_pc_android', '.equipment_h5']
|
||
} else if (Equipment().isPc) {
|
||
publicJs.strEquipmentCode = 'pc';
|
||
publicJs.intEquipmentNumber = 1;
|
||
publicJs.arrHideDomClass = ['.equipment_h5', '.equipment_android', '.equipment_ios']
|
||
publicJs.arrShowDomClass = ['.equipment_pc', '.equipment_pc_android', '.equipment_pc_ios']
|
||
}
|
||
publicJs.arrHideDomClass.forEach((item) => {
|
||
var elements = document.querySelectorAll(item)
|
||
for (var a = 0; a < elements.length; a++) {
|
||
elements[a].style.display = 'none';
|
||
}
|
||
})
|
||
// publicJs.arrShowDomClass.forEach((item) => {
|
||
// var elements = document.querySelectorAll(item)
|
||
// for (var a = 0; a < elements.length; a++) {
|
||
// elements[a].style.display = 'block';
|
||
// }
|
||
// })
|
||
}
|
||
|
||
/**
|
||
* 将ArrayBuffer转换为Base64字符串
|
||
* @param buffer buffer
|
||
* @returns {string}
|
||
*/
|
||
export function arrayBufferToBase64(buffer) {
|
||
let strBinary = '';
|
||
const bytes = new Uint8Array(buffer);
|
||
for (let i = 0; i < bytes.byteLength; i++) {
|
||
strBinary += String.fromCharCode(bytes[i]);
|
||
}
|
||
return window.btoa(strBinary);
|
||
}
|
||
|
||
/**
|
||
* 生成随机数
|
||
* 生成任意长度随机字母数字组合
|
||
* @param int boolAnyLength 是否任意长度
|
||
* @param int intMin 任意长度最小位[固定位数]
|
||
* @param int intmax 任意长度最大位
|
||
* @returns string
|
||
*/
|
||
export function agenerateLetterAndNumber(boolAnyLength, intMin, intmax) {
|
||
let strRndStr = "",
|
||
ingIange = intMin,
|
||
arrOrg = [
|
||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
||
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
||
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',];
|
||
|
||
if (boolAnyLength) {
|
||
ingIange = Math.round(Math.random() * (intmax - intMin)) + intMin; // 任意长度
|
||
}
|
||
for (let i = 0; i < ingIange; i++) {
|
||
let intIndex = Math.round(Math.random() * (arrOrg.length - 1));
|
||
strRndStr += arrOrg[intIndex];
|
||
}
|
||
return strRndStr;
|
||
}
|
||
|
||
/**
|
||
* 提取url参数的方法
|
||
* @param {string} strCode
|
||
* @returns {string}
|
||
*/
|
||
export function getValFromBrowserAddress(strCode) {
|
||
var strQuery = window.location.search;
|
||
var Params = new URLSearchParams(strQuery);
|
||
var strSearchVal = Params.get(strCode);
|
||
return strSearchVal;
|
||
}
|
||
|
||
/**
|
||
* layer 弹窗提示
|
||
* @param {string} strContent
|
||
* @param int intTime
|
||
*/
|
||
export function layerPopup(strContent, intTime) {
|
||
layer.open({
|
||
shadeClose: false,
|
||
skin: 'msg',
|
||
content: strContent,
|
||
time: intTime
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 提取图片后缀
|
||
* @param {string} strPath
|
||
* @returns {string}
|
||
*/
|
||
export function getImageSuffix(strPath) {
|
||
var intLastIndex = strPath.lastIndexOf(".");
|
||
var strSuffix = strPath.substr(intLastIndex + 1);
|
||
return strSuffix
|
||
}
|
||
|
||
/**
|
||
* 替换 域名
|
||
* @param {string} strNewDoamin
|
||
* @param {string} strUrl
|
||
* @returns {string}
|
||
*/
|
||
export function replaceDomainFun(strNewDoamin, strUrl) {
|
||
console.log('strNewDoamin')
|
||
console.log(strNewDoamin)
|
||
console.log(strUrl)
|
||
var reg = /^http(s)?:\/\/(.*?)\//;
|
||
return strUrl.replace(reg, strNewDoamin + '/')
|
||
}
|
||
|
||
/**
|
||
* 从 Configs 里 根据key 获取值
|
||
* @param array arrConfig
|
||
* @param {string} strKey
|
||
* @param {string} strDefaule
|
||
* @returns {string}
|
||
*/
|
||
export function getValInConfigs(arrConfig, strKey, strDefaule) {
|
||
let intIndex = arrConfig.findIndex((item) => strKey == item.conf_code)
|
||
if (intIndex != -1) {
|
||
return arrConfig[intIndex].conf_val
|
||
}
|
||
return strDefaule
|
||
}
|
||
|
||
/**
|
||
* 复制功能
|
||
* @param Element event
|
||
* @param {string} strContent
|
||
* @param int ingTime
|
||
* j-copy data-dom data-cp-val
|
||
*/
|
||
export function copyFun(event, strContent = '复制成功!', intTime = 3) {
|
||
const range = document.createRange();
|
||
range.selectNode(document.querySelector(event));
|
||
const selection = window.getSelection();
|
||
if (selection.rangeCount > 0) selection.removeAllRanges();
|
||
selection.addRange(range);
|
||
document.execCommand("copy");
|
||
if (strContent) {
|
||
layer.open({
|
||
shadeClose: false,
|
||
skin: "msg",
|
||
content: strContent,
|
||
time: intTime
|
||
});
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 复制 input 里的内容
|
||
* @param Element event
|
||
* @param {string} strContent
|
||
* @param int intTime
|
||
* j-copy data-dom data-cp-val
|
||
*/
|
||
export function copyByInput(event, strContent = '复制成功!', intTime = 3) {
|
||
let copyVal = document.querySelector(event).innerText
|
||
const input = document.createElement("input"); // 直接构建input
|
||
input.value = copyVal.trim(); // 设置内容
|
||
document.body.appendChild(input); // 添加临时实例
|
||
input.select(); // 选择实例内容
|
||
document.execCommand("Copy"); // 执行复制
|
||
document.body.removeChild(input); // 删除临时实例
|
||
layer.open({
|
||
shadeClose: false,
|
||
skin: "msg",
|
||
content: strContent,
|
||
time: intTime
|
||
});
|
||
}
|
||
|
||
|
||
/**
|
||
* 统计事件
|
||
* @param int intId
|
||
* @param int intStatisticsType
|
||
*/
|
||
export function fetchStatistics(intId, intStatisticsType = 5) {
|
||
|
||
let postData = {
|
||
'id':intId,
|
||
'type':intStatisticsType,
|
||
}
|
||
fetchApi(apiSaveStaTis, postData,false, onError,false)
|
||
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 页面跳转 事件处理
|
||
* @param object obj url:跳转地址 , url_type :跳转类型 , is_news:是否新窗口
|
||
* @returns boolean
|
||
* class=".j-event-click" data-href="" data-gotype=""
|
||
*/
|
||
export function pageJumpFn(obj) {
|
||
let strHref = obj.url
|
||
let intHrefType = obj.url_type
|
||
let intIsOpenNewsWindows = obj.is_news ? obj.is_news : 1
|
||
//外部地址 统一新窗口打开
|
||
if (intHrefType == 2 || intIsOpenNewsWindows == 2) {
|
||
operationAdomJump(strHref)
|
||
return false
|
||
}
|
||
if (strHref.indexOf('.apk') != -1 || intIsOpenNewsWindows == 1) {
|
||
location.href = strHref
|
||
return false
|
||
}
|
||
operationAdomJump(strHref)
|
||
return false
|
||
}
|
||
|
||
/**
|
||
* 操作a标签跳转事件
|
||
* @param String strHref
|
||
* @param boolean boolIsNoReFerRer
|
||
* @returns
|
||
*/
|
||
export function operationAdomJump(strHref, boolIsNoReFerRer = true) {
|
||
if (!boolIsNoReFerRer) {
|
||
$("#target_a_click").attr('rel', '')
|
||
} else {
|
||
$("#target_a_click").attr('rel', 'noreferrer')
|
||
}
|
||
$("#target_a_click").attr('href', strHref)
|
||
$("#target_span_click").click()
|
||
return false
|
||
}
|
||
|
||
/**
|
||
* 分享地址 拼接参数
|
||
* @param {string} strHref
|
||
* @returns {string}
|
||
*/
|
||
export function shareHrefSplicingParameters(strHref) {
|
||
var intMuReferrerId = 0
|
||
if (getLoginStatus()) {
|
||
var UserInfo = getLoginStatus()
|
||
if(UserInfo){
|
||
intMuReferrerId = UserInfo.mu_id
|
||
}
|
||
}
|
||
if (String(intMuReferrerId).length > 0) {
|
||
strHref += '?mu_referrer_id=' + intMuReferrerId
|
||
}
|
||
|
||
let strChannelVal = (localStorage.getItem(EncAndDec.encryptData('dlfx_channelcode')) ? localStorage.getItem(EncAndDec.encryptData('dlfx_channelcode')) : '')
|
||
if (strChannelVal.length > 0) {
|
||
if (strHref.indexOf('?') != -1) {
|
||
strHref += '&channel=' + strChannelVal
|
||
} else {
|
||
strHref += '?channel=' + strChannelVal
|
||
}
|
||
}
|
||
return strHref
|
||
}
|
||
|
||
/**
|
||
* 设置分享地址
|
||
* @param {string} strShareDomain
|
||
* @param {string} strCurrentDoamin
|
||
* @returns {string}
|
||
*/
|
||
export function setShareHref(strShareDomain = null, strCurrentDomain = null) {
|
||
if (strCurrentDomain == null) {
|
||
strCurrentDomain = window.location.origin + window.location.pathname
|
||
}
|
||
if (strShareDomain == null) {
|
||
strShareDomain = Configs.get('SHARE_DOMAIN')
|
||
}
|
||
let strShareHref = shareHrefSplicingParameters(strCurrentDomain)
|
||
return strShareDomain + '?url=' + Base64UrlEncode(strShareHref);
|
||
}
|
||
|
||
/**
|
||
* base64
|
||
* @param {*} str
|
||
* @returns
|
||
*/
|
||
export function Base64UrlEncode(str) {
|
||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
|
||
function toSolidBytes(match, p1) {
|
||
return String.fromCharCode('0x' + p1);
|
||
}));
|
||
}
|
||
|
||
/**
|
||
* 输出日志
|
||
* @param {string} log
|
||
*/
|
||
export function outPutLog(log) {
|
||
if (getValFromBrowserAddress('outlog')) {
|
||
console.log(log)
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 检查登录状态
|
||
* @returns boolean
|
||
*/
|
||
export function checkIsLoginFn() {
|
||
//获取本地储存登录状态,判断是否登录
|
||
var loginStatus = JSON.parse(localStorage.getItem(storageObj.loginStatus))
|
||
if (!loginStatus || loginStatus === null || loginStatus === false ) {
|
||
$(".no_login_status_tip").removeClass("yc")
|
||
$(".tip_zdc_body").removeClass("yc")
|
||
return false
|
||
} else {
|
||
return true
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 检查是否已经登录
|
||
* @returns boolean
|
||
*/
|
||
export function checkIsMemberFn() {
|
||
//获取本地储存登录状态,判断是否登录
|
||
var boolMemberToken = localStorage.getItem(storageObj.tokenKey)
|
||
var boolLoginStatus = localStorage.getItem(storageObj.loginStatus)
|
||
//获取本地储存,判断是否登录会员
|
||
var boolIsMember = localStorage.getItem(storageObj.isMember)
|
||
if (!boolMemberToken) {
|
||
$(".no_login_status_tip").removeClass("yc")
|
||
$(".tip_zdc_body").removeClass("yc")
|
||
return false
|
||
}
|
||
if (!boolLoginStatus) {
|
||
$(".no_login_status_tip").removeClass("yc")
|
||
$(".tip_zdc_body").removeClass("yc")
|
||
return false
|
||
}
|
||
if (!boolIsMember || boolIsMember == 'false') {
|
||
$(".no_vip_status_tip").removeClass("yc")
|
||
$(".tip_zdc_body").removeClass("yc")
|
||
return false
|
||
} else {
|
||
|
||
return true
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 检查是否会员
|
||
* @returns boolean
|
||
*/
|
||
export function checkIsMemberStatus() {
|
||
//获取本地储存登录状态,判断是否登录
|
||
var boolMemberToken = localStorage.getItem(storageObj.tokenKey)
|
||
var boolLoginStatus = localStorage.getItem(storageObj.loginStatus)
|
||
//获取本地储存,判断是否登录会员
|
||
var boolIsMember = localStorage.getItem(storageObj.isMember)
|
||
if (!boolMemberToken) {
|
||
return false
|
||
}
|
||
if (!boolLoginStatus) {
|
||
return false
|
||
}
|
||
if (!boolIsMember || boolIsMember == 'false') {
|
||
return false
|
||
} else {
|
||
return true
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化 历史记录
|
||
* 返回历史记录页面
|
||
*/
|
||
export function intiHistoryHref() {
|
||
let strCurrentLocation = window.location.href
|
||
let arrHistoryStack = JSON.parse(localStorage.getItem('historyStack')) || [];
|
||
|
||
if (arrHistoryStack.length > 30) {
|
||
arrHistoryStack = arrHistoryStack.slice(-20);
|
||
}
|
||
|
||
if (strCurrentLocation != arrHistoryStack[arrHistoryStack.length - 1]) {
|
||
arrHistoryStack.push(strCurrentLocation);
|
||
}
|
||
//返回上一级
|
||
localStorage.setItem('historyStack', JSON.stringify(arrHistoryStack));
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 会员页面跳转
|
||
* @param {*} strHref
|
||
*/
|
||
export function goMerberPageFn(strHref) {
|
||
pageJumpFn({ 'url': strHref, 'url_type': 1 })
|
||
}
|
||
|
||
/**
|
||
* 获取用户信息
|
||
*/
|
||
export function getPublictUserInfo() {
|
||
|
||
let postData = {}
|
||
fetchApi(apiBindPhone, postData,successFun, onError,false)
|
||
function successFun(res) {
|
||
if (res.code == '000') {
|
||
var data = res.data
|
||
localStorage.setItem(storageObj.userInfo, JSON.stringify(data))
|
||
let timestamp = Date.parse(new Date());
|
||
if (data.mu_vip_expired != null) {
|
||
let vipTimesStamp = new Date(data.mu_vip_expired).getTime()
|
||
if (vipTimesStamp > timestamp) {
|
||
//console.log('会员',data.mu_vip_expired)
|
||
localStorage.setItem(storageObj.isMember, true)
|
||
} else {
|
||
//console.log('会员过期',data.mu_vip_expired)
|
||
localStorage.setItem(storageObj.isMember, false)
|
||
}
|
||
} else {
|
||
//console.log('不是会员')
|
||
localStorage.setItem(storageObj.isMember, false)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 点击遮挡层隐藏弹窗
|
||
* @returns
|
||
*/
|
||
export function tapOcclusionLayerHidePopUp() {
|
||
if (document.querySelector(".comicdetails-web")) {
|
||
return false
|
||
} else {
|
||
$(".no_login_status_tip").addClass("yc")
|
||
$(".no_vip_status_tip").addClass("yc")
|
||
$(".free_vip_data_tip").addClass("yc")
|
||
$(".tip_zdc_body").addClass("yc")
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 二维码点击事件
|
||
*/
|
||
export function initQrcodeFn() {
|
||
bindLongPressAction(".j-long-press-to-save-the-qrcode-btn", saveErCode);
|
||
}
|
||
|
||
/**
|
||
* 绑定长按和点击事件
|
||
* @param {string} selector
|
||
* @param {function} actionFn
|
||
*/
|
||
function bindLongPressAction(selector, actionFn) {
|
||
let timeOutEvent = null;
|
||
|
||
$(selector).on({
|
||
touchstart: (e) => {
|
||
timeOutEvent = setTimeout(() => {
|
||
timeOutEvent = null;
|
||
actionFn();
|
||
}, 400);
|
||
},
|
||
touchmove: () => {
|
||
clearTimeout(timeOutEvent);
|
||
timeOutEvent = null;
|
||
},
|
||
touchend: () => {
|
||
if (timeOutEvent) {
|
||
actionFn();
|
||
}
|
||
clearTimeout(timeOutEvent);
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 保存二维码图片
|
||
*/
|
||
export function saveErCode() {
|
||
layerPopup("拼命保存中。。");
|
||
html2canvas(document.querySelector(".j-qrcode-img")).then(canvas => {
|
||
const imgBase64 = canvas.toDataURL();
|
||
downloadImage(imgBase64, ".j-qr-code-pupop");
|
||
});
|
||
}
|
||
|
||
// 下载二维码
|
||
export function downloadImage(imgUrl, hideDom = null) {
|
||
const a = document.createElement("a");
|
||
a.download = generateFilename(imgUrl);
|
||
a.href = imgUrl;
|
||
a.dispatchEvent(new MouseEvent("click"));
|
||
|
||
const layerIndexTc = layerPopup("拼命保存中。。");
|
||
layer.close(layerIndexTc);
|
||
showDownloadFeedback();
|
||
$(hideDom).hide();
|
||
}
|
||
|
||
/**
|
||
* 根据提供的图片 URL 下载图片
|
||
* @param {string} strImageUrl 图片的 URL 地址
|
||
*/
|
||
export function downloadImageFromUrl(strImageUrl) {
|
||
// 创建一个 Image 对象来加载图片
|
||
let image = new Image();
|
||
image.crossOrigin = 'anonymous'; // 设置跨域访问以解决潜在的跨域问题
|
||
|
||
image.onload = function() {
|
||
// 图片加载完成后,使用 Canvas 来处理图片
|
||
let canvas = document.createElement('canvas');
|
||
canvas.width = image.width;
|
||
canvas.height = image.height;
|
||
|
||
// 在 Canvas 上绘制图像
|
||
let ctx = canvas.getContext('2d');
|
||
ctx.drawImage(image, 0, 0);
|
||
|
||
// 将 Canvas 转换为 Base64 编码的 PNG 图片
|
||
let strDataUrl = canvas.toDataURL('image/png');
|
||
|
||
//return strDataUrl;
|
||
|
||
// 创建并触发一个用于下载的临时链接
|
||
let downloadLink = document.createElement('a');
|
||
downloadLink.href = strDataUrl;
|
||
downloadLink.download = 'downloadedImage.png'; // 指定下载文件的默认名称
|
||
document.body.appendChild(downloadLink);
|
||
downloadLink.click();
|
||
document.body.removeChild(downloadLink);
|
||
};
|
||
|
||
// 设置图片源为提供的 URL
|
||
image.src = strImageUrl;
|
||
}
|
||
|
||
/**
|
||
* 根据imgUrl生成文件名
|
||
* @param {string} imgUrl
|
||
*/
|
||
function generateFilename(imgUrl) {
|
||
const timestamp = new Date().getTime();
|
||
return imgUrl.substring(22, 30) + timestamp + ".png";
|
||
}
|
||
|
||
/**
|
||
* 提供下载反馈信息
|
||
*/
|
||
function showDownloadFeedback() {
|
||
const ua = navigator.userAgent.toLowerCase();
|
||
const isIos = ua.includes("iphone") || ua.includes("ipad");
|
||
const message = isIos
|
||
? "请稍后打开右上角下载查看,保存到相册!"
|
||
: "请稍后相册查看!";
|
||
layerPopup(message, 3)
|
||
|
||
}
|
||
|
||
/**
|
||
* 搜索词 限制
|
||
*
|
||
* @param {string} keyword
|
||
* @returns
|
||
*/
|
||
export function isSearchValid(keyword) {
|
||
let arrTipWord = [
|
||
"输入不规范!调整姿势再来一炮!",
|
||
"666 能不能好好撸 !",
|
||
"搜索词不规范!",
|
||
"哎呀,你的搜索好像跑偏了!调整一下再试试吧!",
|
||
"偷偷告诉你,这样搜可是找不到宝藏的哦~",
|
||
"哎哟喂,小伙伴,这样的搜索方法不科学呀!",
|
||
"你的搜索有些与众不同,重新输入一下,说不定有惊喜哦~",
|
||
"呼叫搜索卫星…哔…哔…接收到了一个不规范的信号,请再输入一次~",
|
||
"哈哈,这样的搜索真是少见!再给我一个机会吧~",
|
||
"哇塞,你的搜索技巧真是独树一帜!试试别的关键词如何?",
|
||
"小心哦,搜得太野可能会唤出藏宝图,不信你调整一下再试试~",
|
||
"哟吼,看来我们的搜索引擎遇到了一点小挑战,再输入一次吧!",
|
||
"嘿,这样搜真的大丈夫吗?不如换个方式,说不定就中大奖了呢~",
|
||
"宇宙中有无数秘密,但这个搜索方式似乎不是探索的正确方法,再来一次吧!",
|
||
"听说精准的搜索关键词会带你去一个神秘的地方,想试试看吗?",
|
||
"用心感受,你会发现正确的搜索关键词其实就在眼前,再试一次~",
|
||
"哇哦,你的搜索好像触碰到了平行宇宙!调整一下,我们再从这个维度开始~",
|
||
"难道这就是传说中的秘密搜索技巧?开玩笑的,重新输入试试~",
|
||
"喂,搜索引擎喊你别捣乱~",
|
||
"这搜法...你是外星人吗?",
|
||
"唉哟,搜疯了?再试试!",
|
||
"搜得有点野,再来一遍?",
|
||
"你点的是搜索,不是自动写诗哦~",
|
||
"咦?这是在下棋吗?",
|
||
"小心,乱搜会招来外星侵略!",
|
||
"搜索引擎有点懵,再输一次?",
|
||
"不搜点正常的吗?哈哈~",
|
||
"哎呀,你这是要搜地球外的秘密吗?",
|
||
"搜索引擎喊你别逗它了~",
|
||
"看来你是搜索高手,再试试看?",
|
||
"嗯...你确定这不是外星语?",
|
||
"警告:再这样搜,我要放笑气了!",
|
||
"刚刚的输入让搜索引擎开了个小差~",
|
||
];
|
||
|
||
// 从arrTipWord数组中随机选择一个提示词
|
||
const randomTip = arrTipWord[Math.floor(Math.random() * arrTipWord.length)];
|
||
|
||
// 计算字符串长度(考虑汉字)
|
||
const keywordLen = Array.from(keyword).reduce((count, char) => {
|
||
return count + (char.charCodeAt(0) > 127 ? 3 : 1); // 如果字符是汉字,加3,否则加1
|
||
}, 0);
|
||
|
||
// 限制搜索关键词长度: 一个汉字=3 ,2-10个汉字
|
||
if (keywordLen < 6 || keywordLen > 30) {
|
||
layerPopup(randomTip, 3)
|
||
return false;
|
||
}
|
||
|
||
// 如果是纯数字,归类为刷
|
||
if (/^\d+$/.test(keyword)) {
|
||
layerPopup(randomTip, 3)
|
||
return false;
|
||
}
|
||
|
||
// 纯英文,归类为刷
|
||
if (/^[a-zA-Z]+$/.test(keyword)) {
|
||
layerPopup(randomTip, 3)
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 搜索事件初始化
|
||
*/
|
||
export function initOnclcikSearch() {
|
||
|
||
function handleSearchClick(strKeyword) {
|
||
if (checkIsLoginFn()) {
|
||
if (isSearchValid(strKeyword)) {
|
||
var intTimestamp = Date.now();
|
||
pageJumpFn({ 'url': `/search/${strKeyword}/1.html?v=${intTimestamp}`, 'url_type': 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
let domSearchInput = document.querySelector('.j-search-input')
|
||
domSearchInput.addEventListener('keydown', function (event) {
|
||
// 检测是否为回车键被按下
|
||
if (event.key === 'Enter' || event.keyCode === 13) {
|
||
event.preventDefault(); // 防止默认的提交表单行为(如果有)
|
||
handleSearchClick(this.value)
|
||
}
|
||
});
|
||
$(".j-head-search").on('click', function (event) {
|
||
event.preventDefault();
|
||
handleSearchClick(domSearchInput.value);
|
||
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 从数组获取几个随机数据
|
||
* @param {*} arr
|
||
* @param {*} intCount
|
||
* @returns
|
||
*/
|
||
export function getRandomElements(arr, intCount) {
|
||
// 首先对数组进行随机排序
|
||
let shuffled = arr.sort(() => 0.5 - Math.random());
|
||
|
||
// 然后获取前5个元素(或者整个数组,如果它的长度小于5)
|
||
return shuffled.slice(0, intCount);
|
||
}
|
||
|
||
|
||
/**
|
||
* 激活浮动窗口移动功能
|
||
* @param {*} domClassAOrId 元素class 或者id
|
||
*/
|
||
export function EnableFloatingWindowMovement(domClassAOrId) {
|
||
// 获取容器和窗口尺寸
|
||
let Container = $(domClassAOrId);
|
||
let IntContainerWidth = Container.width();
|
||
let IntContainerHeight = Container.height();
|
||
let IntWindowWidth = $(window).width();
|
||
let IntWindowHeight = $(window).height();
|
||
|
||
// 定义起始和移动坐标
|
||
let IntStartX, IntStartY, IntStartOffsetX, IntStartOffsetY;
|
||
let IntMoveX, IntMoveY;
|
||
let IntLeftBoundary, IntRightBoundary, IntTopBoundary, IntBottomBoundary;
|
||
|
||
Container.on({
|
||
// 触摸开始
|
||
touchstart: function (e) {
|
||
let Touch = e.originalEvent.targetTouches[0];
|
||
IntStartX = Touch.pageX;
|
||
IntStartY = Touch.pageY;
|
||
IntStartOffsetX = Container.offset().left;
|
||
IntStartOffsetY = Container.offset().top;
|
||
|
||
// 计算移动边界
|
||
IntLeftBoundary = IntStartX - IntStartOffsetX;
|
||
IntRightBoundary = IntWindowWidth - IntContainerWidth + IntLeftBoundary;
|
||
IntTopBoundary = IntStartY - IntStartOffsetY;
|
||
IntBottomBoundary = IntWindowHeight - IntContainerHeight + IntTopBoundary - 20;
|
||
},
|
||
// 触摸移动
|
||
touchmove: function (e) {
|
||
e.preventDefault();
|
||
let Touch = e.originalEvent.targetTouches[0];
|
||
IntMoveX = Touch.clientX;
|
||
IntMoveY = Touch.clientY;
|
||
|
||
// 边界处理
|
||
IntMoveX = Math.max(IntLeftBoundary, Math.min(IntMoveX, IntRightBoundary));
|
||
IntMoveY = Math.max(IntTopBoundary, Math.min(IntMoveY, IntBottomBoundary));
|
||
|
||
// 更新容器位置
|
||
Container.css({
|
||
'left': IntMoveX + IntStartOffsetX - IntStartX,
|
||
'top': IntMoveY + IntStartOffsetY - IntStartY,
|
||
});
|
||
},
|
||
// 触摸结束
|
||
touchend: function () {
|
||
Container.css({
|
||
'left': '',
|
||
'top': IntMoveY + IntStartOffsetY - IntStartY,
|
||
'right': 0
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
|
||
export default publicJs;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|