debug
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
export class Base64Url {
|
||||
encode(str) {
|
||||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
|
||||
function toSolidBytes(match, p1) {
|
||||
return String.fromCharCode('0x' + p1);
|
||||
}));
|
||||
}
|
||||
}
|
||||
97
code/public/template/shikong/huiyuan/js/class/VideoPlayer.js
Normal file
97
code/public/template/shikong/huiyuan/js/class/VideoPlayer.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import { apiGetVideoInfo } from '../public/api/index.js';
|
||||
import { fetchApi,onError} from '../public/api/fetch.js';
|
||||
class VideoPlayer {
|
||||
constructor(intPayStatus, intVideoId, CctvOpening, strVideoPlayUrl, strDownUrl) {
|
||||
this.intPayStatus = intPayStatus;
|
||||
this.intVideoId = intVideoId;
|
||||
this.CctvOpening = CctvOpening;
|
||||
this.strVideoPlayUrl = strVideoPlayUrl;
|
||||
this.strDownUrl = strDownUrl;
|
||||
}
|
||||
|
||||
init() {
|
||||
this.intDplay();
|
||||
}
|
||||
|
||||
intDplay() {
|
||||
if (this.intPayStatus !== 1 && checkIsMemberFn()) {
|
||||
this.fetchVideoInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.shouldShowCctvOpening()) {
|
||||
this.setupCctvOpening();
|
||||
} else {
|
||||
this.startMainVideo();
|
||||
}
|
||||
}
|
||||
|
||||
fetchVideoInfo() {
|
||||
|
||||
let strApiUrl = apiGetVideoInfo + '?vid=' + this.intVideoId;
|
||||
fetchApi(strApiUrl, null,successFn, onError)
|
||||
function successFn(res) {
|
||||
if (res.code == '000') {
|
||||
videoInfoJs.setDownUrl(res.data.downurl);
|
||||
videoInfoJs.setPlayUrl(res.data.playurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shouldShowCctvOpening() {
|
||||
const disallowedDevices = ['UCBrowser', 'QuarkBrowser', 'VIVODevice'];
|
||||
return this.CctvOpening.length > 0 &&
|
||||
!checkIsMemberStatus() &&
|
||||
!disallowedDevices.includes(detectBrowserOrDevice());
|
||||
}
|
||||
|
||||
setupCctvOpening() {
|
||||
this.strCctvHref = this.CctvOpening[0].href;
|
||||
this.strCctvUrl = this.CctvOpening[0].cover;
|
||||
this.strCctvUrl.indexOf(".m3u8") > 0 ? this.showCctvVideo() : this.showCctvImg();
|
||||
this.bindCctvClickEvent();
|
||||
}
|
||||
|
||||
showCctvVideo() {
|
||||
this.boolIsShowCctvVideo = true;
|
||||
this.intCountDownTimes = this.intCctvOpeningTimes;
|
||||
$(".isShow_cctv_video").show();
|
||||
this.beforePlay(this.strCctvUrl, true);
|
||||
}
|
||||
|
||||
showCctvImg() {
|
||||
this.boolIsShowCctvImg = true;
|
||||
this.intCountDownTimes = this.intCctvOpeningTimes;
|
||||
$(".isShow_cctv_img img").attr('src', this.strCctvUrl);
|
||||
$(".isShow_cctv_img").show();
|
||||
}
|
||||
|
||||
bindCctvClickEvent() {
|
||||
if (this.cctvEventBound) return;
|
||||
$(".isShow_cctv_video").on('click', () => {
|
||||
if (this.intCountDownTimes === this.intCctvOpeningTimes) {
|
||||
this.beforePlay(this.strCctvUrl);
|
||||
return;
|
||||
}
|
||||
if (checkIsLoginFn()) {
|
||||
$(".isShow_cctv_img, .isShow_cctv_video").hide();
|
||||
this.intCountDownTimes = 0;
|
||||
clearInterval(this.CctvInterval);
|
||||
this.setPlayUrl(this.strVideoPlayUrl);
|
||||
}
|
||||
});
|
||||
this.cctvEventBound = true;
|
||||
}
|
||||
|
||||
startMainVideo() {
|
||||
this.intCountDownTimes = 0;
|
||||
this.setPlayUrl(this.strVideoPlayUrl);
|
||||
this.setDownUrl(this.strDownUrl);
|
||||
}
|
||||
|
||||
// ... Any other methods or helpers you might need can be added here.
|
||||
}
|
||||
|
||||
// 使用方式:
|
||||
// const player = new VideoPlayer(intPayStatus, intVideoId, CctvOpening, strVideoPlayUrl, strDownUrl);
|
||||
// player.init();
|
||||
130
code/public/template/shikong/huiyuan/js/class/cctv.js
Normal file
130
code/public/template/shikong/huiyuan/js/class/cctv.js
Normal file
@@ -0,0 +1,130 @@
|
||||
import EncAndDec from '../public/enc.js'
|
||||
import {Equipment,clickEvent} from '../public/commonFun.js';
|
||||
|
||||
/**
|
||||
* 广告
|
||||
*/
|
||||
class Cctvs {
|
||||
|
||||
constructor() {
|
||||
// 初始化数据
|
||||
this.arrCctvs = this.getAll();
|
||||
this.currentEquipmentData = this.getCurrentEquipmentData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定点击事件
|
||||
* 所有广告点击
|
||||
* class="j-cctv-click" data-href="${data.href}" data-id="${data.id}" data-onsite-or-offsite="${data.onsite_or_offsite}"
|
||||
*/
|
||||
addEvent() {
|
||||
$(document).on("click", ".j-cctv-click", function(event) {
|
||||
event.stopPropagation(); // 阻止事件冒泡
|
||||
event.preventDefault(); // 阻止默认行为
|
||||
let strHref = $(this).attr('data-href') ?? '';
|
||||
let intId = $(this).attr('data-id') ?? '';
|
||||
let strOnsiteOrOffsite = $(this).attr('data-onsite-or-offsite') ?? '';
|
||||
console.log(strHref)
|
||||
clickEvent(strHref, intId, 5, strOnsiteOrOffsite)
|
||||
})
|
||||
|
||||
$(document).on("click", ".j-cctv-click-dp", function(event) {
|
||||
let strHref = $(this).attr('data-href') ?? '';
|
||||
let intId = $(this).attr('data-id') ?? '';
|
||||
let strOnsiteOrOffsite = $(this).attr('data-onsite-or-offsite') ?? '';
|
||||
clickEvent(strHref, intId, 5, strOnsiteOrOffsite)
|
||||
})
|
||||
|
||||
$(".j-close-float-pupous").on("click", () => {
|
||||
$("#coupletLeft").addClass("yc")
|
||||
$("#coupletRight").addClass("yc")
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取所有广告数据
|
||||
* @returns array
|
||||
*/
|
||||
getAll() {
|
||||
return
|
||||
let strCtvEncoded = EncAndDec.decryptData(cctvEncodedData, configDecData.MIAO_API_ENCRYPT_KEY);
|
||||
let CtvEncoded = JSON.parse(strCtvEncoded)
|
||||
|
||||
return CtvEncoded.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前设备的数据
|
||||
* @returns array
|
||||
*/
|
||||
getCurrentEquipmentData() {
|
||||
let currentEquipmentData = []
|
||||
return
|
||||
this.arrCctvs.forEach(function (item) {
|
||||
if (item.status == 1) { // 启用
|
||||
if (Equipment().isAndroid) {
|
||||
// 所有设备 + H5(安卓+IOS) + 安卓+ (PC+安卓)
|
||||
if (item.equipment == 400 || item.equipment == 402 || item.equipment == 403 || item.equipment == 405) {
|
||||
currentEquipmentData.push(item)
|
||||
}
|
||||
|
||||
} else if (Equipment().isPhone) {
|
||||
// 所有设备 + H5(安卓+IOS) + IOS+ (PC+IOS)
|
||||
if (item.equipment == 400 || item.equipment == 402 || item.equipment == 404 || item.equipment == 406) {
|
||||
currentEquipmentData.push(item)
|
||||
}
|
||||
|
||||
} else {
|
||||
// 所有设备 + PC + (PC+安卓) + (PC+ios)
|
||||
if (item.equipment == 400 || item.equipment == 401 || item.equipment == 405 || item.equipment == 406) {
|
||||
currentEquipmentData.push(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return currentEquipmentData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件读取广告数据
|
||||
* @param {int} intType
|
||||
* @param {int} intLocation
|
||||
* @param {array} arrPageId
|
||||
* @returns array
|
||||
*/
|
||||
getDataByWhere(intType, intLocation, arrPageId) {
|
||||
return
|
||||
let arrCctv = []
|
||||
this.currentEquipmentData.forEach(Cctv => {
|
||||
if (Cctv.type == intType && Cctv.location == intLocation) {
|
||||
arrPageId.forEach(intPageId => {
|
||||
if(Cctv.page_id == intPageId){
|
||||
arrCctv.push(Cctv)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
return arrCctv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建横幅 dom
|
||||
* @param {array} arrCctv
|
||||
* @param {string} strTip
|
||||
*/
|
||||
createBananerDom(arrCctv, strTip = null) {
|
||||
let DomCctv = ''
|
||||
arrCctv.forEach((item, index) => {
|
||||
if (item) {
|
||||
DomCctv += this.CreateCctvBannerTopDom(item, index, strTip);
|
||||
}
|
||||
})
|
||||
return DomCctv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default Cctvs
|
||||
49
code/public/template/shikong/huiyuan/js/class/config.js
Normal file
49
code/public/template/shikong/huiyuan/js/class/config.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import EncAndDec from '../public/enc.js'
|
||||
|
||||
/**
|
||||
* 后台-网站配置数据
|
||||
*/
|
||||
class Configs {
|
||||
|
||||
constructor() {
|
||||
// 初始化配置数据
|
||||
this.arrConfigs = this.getAll();
|
||||
|
||||
}
|
||||
|
||||
// 添加或更新配置项
|
||||
set(key, value) {
|
||||
this.arrConfigs[key] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置项
|
||||
* @param {string} strKey
|
||||
* @param {string} strType
|
||||
* @returns string | int | null
|
||||
*/
|
||||
get(strKey,strType=null) {
|
||||
return
|
||||
let intIndex = this.arrConfigs.findIndex((item) => strKey == item.conf_code)
|
||||
let strVal = intIndex != -1 ? this.arrConfigs[intIndex].conf_val : null;
|
||||
if(strType == 'int' && strVal != null)[
|
||||
strVal = parseInt(strVal)
|
||||
]
|
||||
return strVal;
|
||||
}
|
||||
|
||||
// 读取所有配置数据
|
||||
getAll() {
|
||||
return
|
||||
let configEncoded = EncAndDec.decryptData(configEncodedData, configDecData.MIAO_API_ENCRYPT_KEY);
|
||||
configEncoded = JSON.parse(configEncoded)
|
||||
return configEncoded.data;
|
||||
}
|
||||
}
|
||||
export default Configs ;
|
||||
|
||||
|
||||
// 使用示例
|
||||
// var configs = new Configs();
|
||||
// console.log(Configs.get('PLAY_CCTV_OPENING_TIME','int'));
|
||||
// console.log(configs.get('PLAY_CCTV_OPENING_TIME','int')); // 输出特定配置:blue
|
||||
73
code/public/template/shikong/huiyuan/js/class/lozyLoading.js
Normal file
73
code/public/template/shikong/huiyuan/js/class/lozyLoading.js
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
import { asyncFunction} from '../public/api/fetch.js';
|
||||
|
||||
import ConfigsJs from './config.js';
|
||||
const Configs = new ConfigsJs();
|
||||
/*
|
||||
* 调用
|
||||
* 引入 LazyLoading.js
|
||||
* img 绑定类名 jqlazyload
|
||||
* img 绑定属性 data-wh=0.69 值根据实质需求定,因为如果图片不设置高度,offsettop 获取的值不准确
|
||||
* img dat-original="真实地址"
|
||||
* img src="懒加载图片"
|
||||
* import LazyLoadingJs from '../class/lozyLoading';
|
||||
* const LazyLoading = new LazyLoadingJs();
|
||||
* LazyLoading.int()
|
||||
*/
|
||||
class LazyLoading {
|
||||
constructor() {
|
||||
// 初始化配置数据
|
||||
this.arrImgDom = document.querySelectorAll('.jqlazyload');
|
||||
}
|
||||
|
||||
int() {
|
||||
var config = {
|
||||
rootMargin: '0px',
|
||||
threshold: 0,
|
||||
}
|
||||
let observer = new IntersectionObserver((entries, self) => {
|
||||
entries.forEach((entry) => {
|
||||
if (entry.isIntersecting) {
|
||||
let domImg = entry.target
|
||||
let strImgSrc = domImg.dataset.original
|
||||
if (strImgSrc) {
|
||||
if (strImgSrc.indexOf('encry') >= 0) {
|
||||
asyncFunction(strImgSrc + '?v=' + Configs.get('COVER_VERSION'))
|
||||
.then(result => {
|
||||
// 异步操作成功时的回调
|
||||
let base64Content = `data:image/png;base64,${result}`;
|
||||
domImg.src = base64Content
|
||||
this.setImgHeightFun(domImg)
|
||||
})
|
||||
.catch(error => {
|
||||
// 异步操作失败时的回调
|
||||
console.error(error);
|
||||
});
|
||||
} else {
|
||||
domImg.src = strImgSrc
|
||||
domImg.classList.remove("jqlazyload");
|
||||
this.setImgHeightFun(domImg)
|
||||
}
|
||||
}
|
||||
// 解除观察
|
||||
self.unobserve(entry.target)
|
||||
}
|
||||
})
|
||||
}, config)
|
||||
|
||||
this.arrImgDom.forEach((image) => {
|
||||
observer.observe(image)
|
||||
})
|
||||
}
|
||||
|
||||
setImgHeightFun(element) {
|
||||
let imgDataWh = element.getAttribute('data-wh')
|
||||
if (imgDataWh) {
|
||||
let $height = element.getBoundingClientRect().width * Number(imgDataWh)
|
||||
element.style.height = $height + 'px';
|
||||
}
|
||||
element.classList.remove('jqlazyload');
|
||||
}
|
||||
}
|
||||
|
||||
export default LazyLoading;
|
||||
Reference in New Issue
Block a user