debug
This commit is contained in:
@@ -30,6 +30,25 @@
|
||||
// );
|
||||
// } catch (err) { }
|
||||
// })();
|
||||
function formatNovelUrl(strPinYin, intNId) {
|
||||
return strNovelUrlTemp
|
||||
.replace('{strPinYin}', encodeURIComponent(strPinYin))
|
||||
.replace('{intNId}', intNId);
|
||||
}
|
||||
|
||||
function formatNovelChapterUrl(strPinYin, intNId, intSort,intPage=0) {
|
||||
return strNovelChapterUrlTemp
|
||||
.replace('{strPinYin}', encodeURIComponent(strPinYin))
|
||||
.replace('{intNId}', intNId)
|
||||
.replace('{intChapterPage}', intPage)
|
||||
.replace('{intChapterSort}', intSort);
|
||||
}
|
||||
|
||||
function formatSearchUrl(strKey,intPage=1) {
|
||||
return strSearchUrlTemp
|
||||
.replace('{strSearchKeywords}', strKey)
|
||||
.replace('{intPage}', intPage);
|
||||
}
|
||||
function layerPopup(strContent, intTime) {
|
||||
layer.open({
|
||||
shadeClose: false,
|
||||
@@ -39,23 +58,6 @@ function layerPopup(strContent, intTime) {
|
||||
});
|
||||
}
|
||||
|
||||
// 添加收藏
|
||||
function incShouCangFun(intId){
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', "/sc?intId="+intId, true);
|
||||
xhr.setRequestHeader('accept', 'application/x.hubserver.admin+json');
|
||||
xhr.send();
|
||||
xhr.onreadystatechange = function () {
|
||||
|
||||
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||
layerPopup('收藏成功',3)
|
||||
}
|
||||
if (xhr.readyState == 4 && xhr.status == 0) {
|
||||
layerPopup('操作太频繁,稍后再试',3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const strBookshelfKey = window.location.hostname + 'strBookshelfKey';
|
||||
const strHistoryKey = window.location.hostname + 'strHistoryKey';
|
||||
|
||||
@@ -100,25 +102,28 @@ function displayShujia() {
|
||||
|
||||
shujia.forEach(book => {
|
||||
const bookElement = document.createElement('div');
|
||||
let strNovelUrl = formatNovelUrl(book.n_name_pinyin, book.n_id)
|
||||
let strNovelChapterUrl = formatNovelChapterUrl(book.n_name_pinyin, book.n_id, book.c_sort_num)
|
||||
let strSearchUrl = formatSearchUrl(book.n_author, 1)
|
||||
bookElement.className = 'book-item';
|
||||
bookElement.innerHTML = `
|
||||
<div class="list-header">
|
||||
<div class="block_img">
|
||||
<a href="/xq/${book.xsxq_id}-${book.xsxq_source_id}-${book.xsxq_source_seo_id}.html">
|
||||
<a href='${strNovelUrl}'>
|
||||
<img class="pre-img lozad" data-encrypted="false"
|
||||
src="/assets/images/loading_img_bg_default.jpg?v={site:cfg code='STATIC_FILE_VERSION' encode='false'/}"
|
||||
data-src="${book.xsxq_feng_mian_url}">
|
||||
src="/static/img/default.jpg"
|
||||
data-src="${book.n_cover_path}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="block_txt">
|
||||
<p class="p1">
|
||||
<a href="/xq/${book.xsxq_id}-${book.xsxq_source_id}-${book.xsxq_source_seo_id}.html"></a>
|
||||
<a href='${strNovelUrl}'></a>
|
||||
</p>
|
||||
<h2><a href="/xq/${book.xsxq_id}-${book.xsxq_source_id}-${book.xsxq_source_seo_id}.html">${book.xsxq_ming_zi}</a></h2>
|
||||
<p class="xiaoshuo_info"><span>${book.xsfl_name} </span><span> ${book.xsxq_zhuang_tai}</span> <span> ${book.xsxq_zuozhe}</span></p>
|
||||
<h2><a href='${strNovelUrl}'>${book.n_name}</a></h2>
|
||||
<p class="xiaoshuo_info"><span>${book.n_category ?? ''} </span><span> ${book.n_status}</span> <span> ${book.n_author}</span></p>
|
||||
<p class="xiaoshuo_maioshu">
|
||||
<a class="ellipsis" href="/xq/${book.xsxq_id}-${book.xsxq_source_id}-${book.xsxq_source_seo_id}.html">
|
||||
${book.xsxq_jie_shao}
|
||||
<a class="ellipsis" href='${strNovelUrl}'>
|
||||
${book.n_description ?? ''}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
@@ -130,78 +135,6 @@ function displayShujia() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 生成二维码
|
||||
async function generateQRCode() {
|
||||
var qrcodeCanvas = document.querySelector('.js-qr .qrcode');
|
||||
var url = window.location.href;
|
||||
|
||||
// 清空二维码画布
|
||||
qrcodeCanvas.innerHTML = '';
|
||||
|
||||
// 使用 qrcode.min.js 生成二维码
|
||||
var qrcode = new QRCode(qrcodeCanvas, {
|
||||
text: url,
|
||||
width: 80,
|
||||
height: 80
|
||||
});
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000)); // 等待1秒钟,确保二维码已经生成完成
|
||||
|
||||
// 将二维码转换为图片并设置 img 标签的 src 属性
|
||||
var qrcodeImgElement = qrcodeCanvas.querySelector('.qrcode img');
|
||||
if (qrcodeImgElement) {
|
||||
var dataURL = qrcodeImgElement.src;
|
||||
|
||||
// 设置下载链接
|
||||
var downloadLink = document.querySelector('.site-qrcode.js-qr');
|
||||
downloadLink.href = dataURL;
|
||||
} else {
|
||||
console.error('二维码生成失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 关闭弹窗的函数
|
||||
function closeIndexPopup(id) {
|
||||
let popup = document.getElementById('index-zxcv-puoup-' + id);
|
||||
if (popup) {
|
||||
popup.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// 检查并显示弹窗的函数
|
||||
function checkAndShowPopup(id) {
|
||||
let lastShown = localStorage.getItem('popup-' + id + '-lastShown');
|
||||
let now = Date.now();
|
||||
let oneHour = 60 * 60 * 1000;
|
||||
|
||||
if (!lastShown || now - lastShown > oneHour) {
|
||||
let popup = document.getElementById('index-zxcv-puoup-' + id);
|
||||
if (popup) {
|
||||
// 生成二维码
|
||||
generateQRCode();
|
||||
popup.style.display = 'block';
|
||||
localStorage.setItem('popup-' + id + '-lastShown', now);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 点击顶部保存网站
|
||||
function showSiteTips(id) {
|
||||
let popup = document.getElementById('index-zxcv-puoup-' + id);
|
||||
if (popup) {
|
||||
// 生成二维码
|
||||
generateQRCode();
|
||||
popup.style.display = 'block';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 监听滚动事件隐藏头部
|
||||
function throttlingFnV2(fn, delay) {
|
||||
let lastCall = 0;
|
||||
@@ -215,19 +148,9 @@ function throttlingFnV2(fn, delay) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换顶部会员信息
|
||||
*/
|
||||
function checkoutHuiyuanTip(){
|
||||
if($(".huiyuan-btn-top")){
|
||||
if(checkIsLoginFn()){
|
||||
$(".huiyuan-btn-top").attr('href',"/info")
|
||||
$(".huiyuan-btn-top").text('会员')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
checkoutHuiyuanTip()
|
||||
// checkoutHuiyuanTip()
|
||||
if ($(".novel-reader").length === 0) {
|
||||
let _scrollY = 0; // 记录上一次滚动位置
|
||||
let nav = $('.v-s-nav-box-h'); // 获取导航栏元素
|
||||
@@ -318,20 +241,11 @@ $(function () {
|
||||
checkAndShowPopup(DomIndePpopupId);
|
||||
});
|
||||
|
||||
//$('[data-toggle="tooltip"]').tooltip();
|
||||
//$('[data-toggle="popover"]').popover();
|
||||
const observer = lozad(); // lazy loads elements with default selector as '.lozad'
|
||||
observer.observe();
|
||||
window._$lozad = observer;
|
||||
|
||||
// sweetalert2弹窗配置
|
||||
// const SSwal = Swal.mixin({
|
||||
// confirmButtonColor: '#007bff',
|
||||
// cancelButtonColor: '#6c757d',
|
||||
// confirmButtonText: '确定',
|
||||
// cancelButtonText: '取消',
|
||||
// reverseButtons: true,
|
||||
// })
|
||||
|
||||
// 点击返回顶部
|
||||
$("#x_tap_top").on("click", function () {
|
||||
$("body, html").animate(
|
||||
@@ -343,113 +257,12 @@ $(function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
// 跑马灯
|
||||
if(document.querySelector("#scroll-outer")){
|
||||
const outer = document.getElementById('scroll-outer')
|
||||
const innter = document.getElementById('scroll-inner')
|
||||
const outerWidth = outer.getBoundingClientRect().width
|
||||
const innerWidth = innter.getBoundingClientRect().width
|
||||
const lastText = document.getElementById('last-text')
|
||||
const padding = 20
|
||||
const middle = innerWidth / 2
|
||||
let translate = 0
|
||||
if (middle - padding > outerWidth) {
|
||||
setInterval(() => {
|
||||
translate = translate >= middle ? 0.5 : (translate + 0.5)
|
||||
innter.style.transform = `translate3d(${-translate}px, 0, 0)`
|
||||
}, 10)
|
||||
} else {
|
||||
lastText.style.display = 'none'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const FloatManager = (function() {
|
||||
const floadzxcvxy = document.getElementById('fload-zxcv-xy');
|
||||
if(floadzxcvxy){
|
||||
let x = window.innerWidth / 2 - 25;
|
||||
let y = window.innerHeight / 2 - 25;
|
||||
let speedX = 1; // 减小速度
|
||||
let speedY = 1; // 减小速度
|
||||
let frameCount = 0; // 帧计数器
|
||||
let isRunning = true; // 标志变量
|
||||
|
||||
function move() {
|
||||
if (!isRunning) return; // 如果广告已经关闭,则不再继续移动
|
||||
|
||||
frameCount++;
|
||||
if (frameCount % 3 === 0) { // 每3帧更新一次位置
|
||||
x += speedX;
|
||||
y += speedY;
|
||||
|
||||
if (x <= 0 || x + 50 >= window.innerWidth) {
|
||||
speedX = -speedX;
|
||||
}
|
||||
if (y <= 0 || y + 50 >= window.innerHeight) {
|
||||
speedY = -speedY;
|
||||
}
|
||||
|
||||
floadzxcvxy.style.left = x + 'px';
|
||||
floadzxcvxy.style.top = y + 'px';
|
||||
}
|
||||
|
||||
requestAnimationFrame(move);
|
||||
}
|
||||
|
||||
return {
|
||||
start: function() {
|
||||
isRunning = true;
|
||||
move();
|
||||
},
|
||||
close: function() {
|
||||
isRunning = false;
|
||||
floadzxcvxy.style.display = 'none';
|
||||
}
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
let indexPuopZxcv = document.querySelector('#close-btn');
|
||||
if (indexPuopZxcv) {
|
||||
FloatManager.start();
|
||||
indexPuopZxcv.addEventListener('click', function(event) {
|
||||
event.stopPropagation(); // 阻止事件冒泡
|
||||
event.preventDefault(); // 阻止默认行为
|
||||
FloatManager.close();
|
||||
});
|
||||
}
|
||||
// document.getElementById('close-btn').addEventListener('click', function(event) {
|
||||
// event.stopPropagation(); // 阻止事件冒泡
|
||||
// event.preventDefault(); // 阻止默认行为
|
||||
// FloatManager.close();
|
||||
// });
|
||||
|
||||
|
||||
});
|
||||
|
||||
// function FloatManagerCloseFn(event) {
|
||||
// event.stopPropagation(); // 阻止事件冒泡
|
||||
// event.preventDefault(); // 阻止默认行为
|
||||
// FloatManager.close();
|
||||
// }
|
||||
|
||||
// 没用到
|
||||
// function ypshare() {
|
||||
// clipboard = new ClipboardJS(".content-box");
|
||||
// $("#copyUrlx").val(`本站永久域名:${document.domain},请收藏!防止丢失,永不迷路!`);
|
||||
// clipboard.on("success", function (e) {
|
||||
// e.clearSelection();
|
||||
// clipboard.destroy();
|
||||
// });
|
||||
// clipboard.on("error", function (e) {
|
||||
// clipboard.destroy();
|
||||
// });
|
||||
// }
|
||||
|
||||
(function () {
|
||||
|
||||
|
||||
function setRem() {
|
||||
const maxWidth = 600; // PC端的最大宽度
|
||||
const designWidth = 750; // 设计稿宽度
|
||||
@@ -477,394 +290,4 @@ $(function () {
|
||||
|
||||
|
||||
})();
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
//底飘-关闭
|
||||
var footerZxcv = document.querySelector('#floating-zxcv-close-btn');
|
||||
if (footerZxcv) {
|
||||
footerZxcv.addEventListener('click', function(event) {
|
||||
event.stopPropagation(); // 阻止事件冒泡
|
||||
event.preventDefault(); // 阻止默认行为
|
||||
$(".floating-zxcv").hide()
|
||||
});
|
||||
}
|
||||
|
||||
var swiperss = document.querySelectorAll('.swiper-container-index');
|
||||
swiperss.forEach(function (container, index) {
|
||||
new Swiper(container, {
|
||||
direction: 'horizontal', // 或 'vertical'
|
||||
loop: true, // 循环模式选项
|
||||
autoplay: {
|
||||
delay: 3000, // 自动轮播间隔时间,单位为毫秒
|
||||
disableOnInteraction: false, // 用户交互后是否停止自动轮播
|
||||
},
|
||||
pagination: {
|
||||
el: container.querySelector('.swiper-pagination'),
|
||||
clickable: true,
|
||||
},
|
||||
navigation: {
|
||||
nextEl: container.querySelector('.swiper-button-next'),
|
||||
prevEl: container.querySelector('.swiper-button-prev'),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function adjustSwiperHeights() {
|
||||
// 获取所有 .swiper-top-zxcv 容器
|
||||
const swiperContainers = document.querySelectorAll('.swiper-top-zxcv');
|
||||
swiperContainers.forEach(container => {
|
||||
// 查找当前容器内的活动滑块图片
|
||||
const activeSlide = container.querySelector('.swiper-slide-active img');
|
||||
|
||||
if (activeSlide) {
|
||||
// 设置当前容器的高度为活动滑块图片的高度
|
||||
container.style.height = activeSlide.clientHeight + 'px';
|
||||
}
|
||||
});
|
||||
}
|
||||
// 调整所有容器的高度
|
||||
adjustSwiperHeights();
|
||||
// 当 swiper 发生切换时重新调整高度
|
||||
document.querySelectorAll('.swiper-container').forEach(swiper => {
|
||||
const swiperInstance = swiper.swiper;
|
||||
if (swiperInstance) {
|
||||
swiperInstance.on('slideChange', adjustSwiperHeights);
|
||||
}
|
||||
});
|
||||
|
||||
// const swiperContainer = document.querySelector('.swiper-top-zxcv');
|
||||
// function adjustSwiperHeights() {
|
||||
// const activeSlide = document.querySelector('.swiper-slide-active img');
|
||||
// if (activeSlide) {
|
||||
// swiperContainer.style.height = activeSlide.clientHeight + 'px';
|
||||
// }
|
||||
// }
|
||||
// adjustSwiperHeights();
|
||||
var swiper = new Swiper('.swiper-top-zxcv', {
|
||||
direction: 'horizontal', // 或 'vertical'
|
||||
loop: true, // 循环模式选项
|
||||
autoplay: {
|
||||
delay: 3000, // 自动轮播间隔时间,单位为毫秒
|
||||
disableOnInteraction: false, // 用户交互后是否停止自动轮播
|
||||
},
|
||||
// 如果需要分页器
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true,
|
||||
},
|
||||
// 如果需要前进后退按钮
|
||||
navigation: {
|
||||
nextEl: '.swiper-button-next',
|
||||
prevEl: '.swiper-button-prev',
|
||||
},
|
||||
// 如果需要滚动条
|
||||
scrollbar: {
|
||||
el: '.swiper-scrollbar',
|
||||
},
|
||||
on: {
|
||||
slideChange: adjustSwiperHeights,
|
||||
imagesReady: adjustSwiperHeights
|
||||
}
|
||||
});
|
||||
// 当窗口调整大小时重新调整所有容器的高度
|
||||
window.addEventListener('resize', adjustSwiperHeights);
|
||||
|
||||
// yp-detail
|
||||
if(document.querySelector('#s-poster-swiper')){
|
||||
var swiperyp = new Swiper('#s-poster-swiper', {
|
||||
direction: 'horizontal', // 或 'vertical'
|
||||
loop: true, // 循环模式选项
|
||||
autoplay: {
|
||||
delay: 3000, // 自动轮播间隔时间,单位为毫秒
|
||||
disableOnInteraction: false, // 用户交互后是否停止自动轮播
|
||||
},
|
||||
// 如果需要分页器
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true,
|
||||
},
|
||||
// 如果需要前进后退按钮
|
||||
navigation: {
|
||||
nextEl: '.swiper-button-next',
|
||||
prevEl: '.swiper-button-prev',
|
||||
},
|
||||
// 如果需要滚动条
|
||||
scrollbar: {
|
||||
el: '.swiper-scrollbar',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 直播
|
||||
if(document.querySelector('.zaixianzhibo-web')){
|
||||
const barrageContainer = document.querySelector('.s-live-item');
|
||||
const barrageItems = document.querySelectorAll('.barrage-item');
|
||||
const containerWidth = barrageContainer.offsetWidth;
|
||||
|
||||
function setAnimation(item, delay, duration) {
|
||||
item.style.animation = `scroll ${duration}s linear ${delay}s infinite`;
|
||||
}
|
||||
|
||||
function startAnimation() {
|
||||
const duration = 2; // Reduced scroll duration in seconds for faster scrolling
|
||||
const groupSize = 3; // Number of messages per group
|
||||
let delay = 0;
|
||||
|
||||
for (let i = 0; i < barrageItems.length; i += groupSize) {
|
||||
const group = Array.from(barrageItems).slice(i, i + groupSize);
|
||||
group.forEach((item, index) => {
|
||||
const itemWidth = item.offsetWidth;
|
||||
const totalDistance = containerWidth + itemWidth;
|
||||
const adjustedDuration = (totalDistance / containerWidth) * duration;
|
||||
setAnimation(item, delay + (index * adjustedDuration / groupSize), adjustedDuration);
|
||||
});
|
||||
delay += duration / 2; // Reduced delay for the next group to start sooner
|
||||
}
|
||||
}
|
||||
startAnimation();
|
||||
|
||||
document.getElementById('js-reload').addEventListener('click', function() {
|
||||
const currentUrl = window.location.href;
|
||||
const version = new Date().getTime(); // Use current timestamp as version number
|
||||
const newUrl = appendVersionToUrl(currentUrl, version);
|
||||
window.location.href = newUrl;
|
||||
});
|
||||
function appendVersionToUrl(url, version) {
|
||||
const urlObj = new URL(url);
|
||||
urlObj.searchParams.set('t', version);
|
||||
return urlObj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(document.querySelector('.cryouxi-web')){
|
||||
let tabs = $("#s-game-wrap .s-game-tag");
|
||||
let mySwiper = new Swiper('#s-game-wrap .swiper', {
|
||||
on: {
|
||||
slideChangeTransitionEnd: function () {
|
||||
tabs.removeClass("active").eq(this.activeIndex).addClass("active")
|
||||
},
|
||||
},
|
||||
});
|
||||
tabs.on("click",function(){
|
||||
let currIdx = $(this).index();
|
||||
tabs.removeClass("active").eq(currIdx).addClass("active");
|
||||
mySwiper.slideTo(currIdx, 300, false);
|
||||
});
|
||||
tabs.eq(0).click();
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(function () {
|
||||
$('.s-select-wrap').on('click', '.pretty-select', function() {
|
||||
var $currentWrap = $(this).closest('.s-select-wrap');
|
||||
var $currentPrettySelectWrap = $(this).closest('.pretty-select-wrap');
|
||||
|
||||
// 移除所有兄弟元素的子元素的 active 类
|
||||
$('.s-select-wrap').find('.pretty-select-wrap').removeClass('active');
|
||||
|
||||
// 切换当前元素的 active 类
|
||||
if ($currentPrettySelectWrap.hasClass('active')) {
|
||||
$currentPrettySelectWrap.removeClass('active');
|
||||
} else {
|
||||
$currentPrettySelectWrap.addClass('active');
|
||||
}
|
||||
});
|
||||
|
||||
// 处理选项点击事件
|
||||
$('.pretty-options li').on('click', function() {
|
||||
var selectedText = $(this).text();
|
||||
var $currentPrettySelect = $(this).closest('.pretty-select-wrap').find('.pretty-select');
|
||||
var $currentPrettyOptions = $(this).closest('.pretty-options');
|
||||
|
||||
// 更新 pretty-select 的文本
|
||||
$currentPrettySelect.text(selectedText);
|
||||
|
||||
// 移除所有选项的 selected 类
|
||||
$currentPrettyOptions.find('li').removeClass('selected');
|
||||
|
||||
// 添加 selected 类到当前选项
|
||||
$(this).addClass('selected');
|
||||
|
||||
// 隐藏选项列表
|
||||
$(this).closest('.pretty-select-wrap').removeClass('active');
|
||||
});
|
||||
|
||||
// 点击外部隐藏所有的 active 类
|
||||
$(document).on('click', function(event) {
|
||||
if (!$(event.target).closest('.s-select-wrap').length) {
|
||||
$('.pretty-select-wrap').removeClass('active');
|
||||
}
|
||||
});
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
if(document.querySelector('.pagination-click')){
|
||||
document.querySelector('.pagination-click').addEventListener('click', function() {
|
||||
var pageInput = document.querySelector('.page-link.pagination-num');
|
||||
var pageNum = pageInput.value ? parseInt(pageInput.value, 10) : 1;
|
||||
var maxPage = parseInt(this.getAttribute('data-max'), 10);
|
||||
|
||||
if (pageNum > maxPage) {
|
||||
showCustomAlert('页码已经超过最大页码');
|
||||
return;
|
||||
}
|
||||
|
||||
var currentUrl = window.location.href;
|
||||
var urlObj = new URL(currentUrl);
|
||||
var path = urlObj.pathname + urlObj.search;
|
||||
|
||||
var searchParams = new URLSearchParams(urlObj.search);
|
||||
if (searchParams.has('page')) {
|
||||
searchParams.set('page', pageNum);
|
||||
} else {
|
||||
searchParams.append('page', pageNum);
|
||||
}
|
||||
|
||||
// var newUrl = urlObj.origin + urlObj.pathname + '?' + searchParams.toString();
|
||||
// var newUrl = urlObj.origin + urlObj.pathname
|
||||
|
||||
var newUrl = urlObj.pathname.replace(/(\d+)\.html$/, pageNum + '.html');
|
||||
newUrl = urlObj.origin + newUrl
|
||||
|
||||
console.log(newUrl);
|
||||
|
||||
window.open(newUrl);
|
||||
});
|
||||
}
|
||||
if(document.querySelector('#js-set-qr')){
|
||||
document.getElementById('js-set-qr').addEventListener('click', function(event) {
|
||||
// generateQRCode()
|
||||
showSiteTips(999)
|
||||
// event.preventDefault();
|
||||
// generateQRCode(window.location.href, '永不丢失二维码.png');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function showCustomAlert(message) {
|
||||
var alertBox = document.getElementById('custom-alert');
|
||||
alertBox.textContent = message;
|
||||
alertBox.classList.add('show');
|
||||
setTimeout(function() {
|
||||
alertBox.classList.remove('show');
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function copyUrlxs(url) {
|
||||
var tempInput = document.createElement('input');
|
||||
tempInput.style.position = 'absolute';
|
||||
tempInput.style.left = '-9999px';
|
||||
tempInput.value = url;
|
||||
document.body.appendChild(tempInput);
|
||||
tempInput.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(tempInput);
|
||||
showCustomAlert('复制成功,打开聊天工具,发给狼友');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享地址 拼接参数
|
||||
* @param {string} strHref
|
||||
* @returns {string}
|
||||
*/
|
||||
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}
|
||||
*/
|
||||
function setShareHref(strShareDomain = null, strCurrentDomain = null) {
|
||||
if (strCurrentDomain == null) {
|
||||
strCurrentDomain = window.location.origin + window.location.pathname
|
||||
}
|
||||
if (strShareDomain == null) {
|
||||
strShareDomain = "https://"+document.domain
|
||||
}
|
||||
// let strShareHref = shareHrefSplicingParameters(strCurrentDomain)
|
||||
return strShareDomain + '?url=' + Base64UrlEncode(strCurrentDomain);
|
||||
}
|
||||
/**
|
||||
* base64
|
||||
* @param {*} str
|
||||
* @returns
|
||||
*/
|
||||
function Base64UrlEncode(str) {
|
||||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
|
||||
function toSolidBytes(match, p1) {
|
||||
return String.fromCharCode('0x' + p1);
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* 检查登录状态
|
||||
* @returns boolean
|
||||
*/
|
||||
function checkIsLoginFn() {
|
||||
//获取本地储存登录状态,判断是否登录
|
||||
let loginStatusKey = window.location.hostname+'loginStatus'
|
||||
var loginStatus = localStorage.getItem(loginStatusKey)
|
||||
if (!loginStatus || loginStatus == null || loginStatus == false || loginStatus == 'false') {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
//noback
|
||||
if (location.href.indexOf('source=1') >= 0) {
|
||||
setHistory()
|
||||
}
|
||||
|
||||
function setHistory() {
|
||||
history.pushState(null, null, document.URL);
|
||||
setTimeout(function() {
|
||||
window.addEventListener('popstate', function() {
|
||||
history.pushState(null, null, document.URL);
|
||||
let strRand = agenerateLetterAndNumber(false,5,10)
|
||||
let strGoWeb = '/?v='+strRand
|
||||
window.location.href= strGoWeb;
|
||||
})
|
||||
}, 0);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user