当前位置: 代码迷 >> 综合 >> 公共方法-functions.js
  详细解决方案

公共方法-functions.js

热度:87   发布时间:2023-10-12 16:37:21.0
//深拷贝
function objDeepCopy(source) {
    var sourceCopy = source instanceof Array ? [] : {
    };for (var item in source) {
    sourceCopy[item] = typeof source[item] === 'object' ? objDeepCopy(source[item]) : source[item];}return sourceCopy;
}//原生js获取元素属性
function getStyle(ele,attr){
    return  window.getComputedStyle ?  window.getComputedStyle(ele, null)[attr] : ele.currentStyle[attr];
}
/*全局对象*/
var gObj = {
    };
gObj.flag = true;
/*签名*/
// 调用函数获取当前设备的cookie标识
gObj.cookie_val = getCookie("identity_id");
gObj.timeDifference = '';
function getNowTime() {
    var nowTime = gObj.timeDifference + new Date().getTime();return 'clienttimestamp=' + nowTime + "&clientsign=" + md5s("201705&" + nowTime) + "&clientver=201705&clientappversion=3.3.5";
}
gObj.parameterObj = {
    clientappkey: 'Liangsanfenzhong010',clientchannel: '00000000000000000000000000000003',clientimei: gObj.cookie_val,clientos: 'web',clientosversion: 'web',clientdevicetoken: 'web',clientlat: '0.0',clientlng: '0.0',clientnetworktype: 'WIFI',clientphone: '00000000000',clientscreenwidth: window.screen.width,clientscreenheight: window.screen.height,clientapptype: '3'
};
/*获取当前设备的cookie标识*/
function getCookie(cookie_name) {
    var allcookies = document.cookie;var cookie_pos = allcookies.indexOf(cookie_name); //索引的长度if(cookie_pos != -1) {
    cookie_pos += cookie_name.length + 1; //这里容易出问题,所以请大家参考的时候自己好好研究一下var cookie_end = allcookies.indexOf(";", cookie_pos);if(cookie_end == -1) {
    cookie_end = allcookies.length;}var value = unescape(allcookies.substring(cookie_pos, cookie_end)); //这里就可以得到你想要的cookie的值了。。。}return value;
}
/*获取时间差的公共方法*/
//function timeCommonFuc(fn){
    
// $.ajax({
    
// type: "get",
// url: "/app/fenzhongkeji/sysMessage/getServerTime.json",
// async: true,
// dataType: 'json',
// success: function(dataBack) {
    
// if(dataBack.status != 1) {
    
// $('#preloader .errMessage span').html(dataBack.message).fadeIn(800);
// return;
// }
// var serverTime = dataBack.data.serverTime;
// var nowTime = new Date().getTime();
// gObj.timeDifference = serverTime - nowTime;
// if(fn) fn();
// }
// })
//}
/*2018-4-26获取验证码方法封装*/
/** 封装验证码倒计时对象* 调用规则,必须是input type="button"元素来调用* 例如:* <input type="button" class="get_code" value="获取验证码"></input>* var newCode = new GetCode($('.get_code').get(0));* newCode.sendCode();* */
function GetCode (element){
    this._init_(element);
}
GetCode.prototype = {
    constructor : GetCode,_init_ : function(element) {
    this.clock = '';this.nums = 60;this.btn = element;},sendCode: function (){
    this.btn.disabled = true; //将按钮置为不可点击this.btn.value = this.nums + '秒后可重发';var that = thisthis.clock = setInterval(this.doLoop(that), 1000); //一秒执行一次},/*需要注意的地方*/doLoop: function(that){
    var fuc = function(){
    that.nums--;if(that.nums > 0) {
    that.btn.value = that.nums + '秒后可重发';} else {
    clearInterval(that.clock); //清除js定时器that.btn.disabled = false;that.btn.value = '获取验证码';that.nums = 60; //重置时间}}return fuc;	}
}//判断访问终端
var browser = {
    versions: function() {
    var u = navigator.userAgent,app = navigator.appVersion;return {
    trident: u.indexOf('Trident') > -1, //IE内核presto: u.indexOf('Presto') > -1, //opera内核webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器iPad: u.indexOf('iPad') > -1, //是否iPadwebApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)qq: u.match(/\sQQ/i) == "qq", //是否QQweibo: u.match(/WeiBo/i) == "weibo", //是否微博};}(),language: (navigator.browserLanguage || navigator.language).toLowerCase()
};/*判断是否是微博*/
var isWeibo = false;
gObj.isWeibo = false;
if(browser.versions.mobile) {
     //判断是否是移动设备打开。browser代码在下面var ua = navigator.userAgent.toLowerCase(); //获取判断用的对象if(ua.match(/MicroMessenger/i) == "micromessenger") {
    //在微信中打开}if(ua.match(/WeiBo/i) == "weibo") {
    isWeibo = true;gObj.isWeibo = true;}if(ua.match(/QQ/i) == "qq") {
    //在QQ空间打开}if(browser.versions.ios) {
    //是否在IOS浏览器打开}if(browser.versions.android) {
    //是否在安卓浏览器打开}
}
//统计字符串中特定字符串的个数
function getStrCount(scrstr, armstr) {
     //scrstr 源字符串 armstr 特殊字符var count = 0;while(scrstr.indexOf(armstr) >= 1) {
    scrstr = scrstr.replace(armstr, "")count++;}return count;
}/*=======================================banner条 Start=======================================*/
function bannerSlider(){
    //头部轮播图var headerURL = '/aiyaya/app/system/ad/advertise.json?' + getNowTime();$.ajax({
    type: "post",url: headerURL,async: true,data: gObj.parameterObj,dataType: 'json',success: function(res) {
    console.log(res)var status = res.status;var str = '';if(status == 1) {
    var dataList = res.data;for(var i = 0; i < dataList.length; i++) {
    if(dataList[i].adstyle == 1){
    str += '<li class="fl logoLi"><a href="#"><img class="fl" src="' + dataList[i].adpicture + '" alt="" /><span class="playIcon"></span></a><p class="fl"><span class="logo">'+dataList[i].adtitle+'</span></br><span class="txt">'+dataList[i].adcontents+'</span></p><button class="fr">打开</button></li>'}else{
    str += '<li class="fl"><a href="#"><img class="fl" src="' + dataList[i].adpicture + '" alt="" /><span class="playIcon"></span></a><p class="fl txt">' + dataList[i].adtitle + '</p><button class="fr">打开</button></li>'}}$('.banner').html('<ul class="img">' + str + '</ul><ul class="num"></ul>');/*var data = {dataList: dataList};var html = template('bannerTemp', data);$('.banner .img').html(html);*/imgscrool('#header');//顶部点击跳转APP$('.img li').click(function() {
    if(gObj.isWeibo) {
    window.location.href = "http://a.app.qq.com/o/simple.jsp?pkgname=com.fengzhongkeji";} else {
    window.location.href = gObj.jumpAppPath;}})}}}); //头部结束
}
/*2018-3-1*/
/*鑾峰彇褰撳墠灞忓箷鐨勫?楂?*/
function getViewportSize () {
    return {
    width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,height:  document.documentElement.clientHeight || document.body.clientHeight || window.innerHeight };
}
function isSmallVideo(){
    if(browser.versions.android && browser.versions.weixin){
    return true;}else{
    return false;}
}
/*=======================================banner条 End=======================================*/
/*=======================================分享Start=======================================*/
function shareWX(shareObj){
    shareObj.desc = '哎呀鸭-儿童短视频平台';// 分享副标题var metaStr = '<meta name="description" itemprop="description" content="哎呀鸭-儿童短视频平台"/>' ;$('head').append(metaStr);				/*微信分享*/var url = encodeURIComponent(location.href.split('#')[0]);gObj.parameterObj.url = url;$.ajax({
    type: "post",url: "/aiyaya/app/fenzhongkeji/HttpXmlClient/getWeiXin.json?" + getNowTime(),data: gObj.parameterObj,dataType: 'json',success: function(data) {
    console.log(data);data = data.data;/*微信接口*/var appId = data.appId;var timestamp = data.timestamp;var nonceStr = data.nonceStr;var signature = data.signature;var obj = {
    debug: true, // 开启调试模式appId: appId, // 必填,公众号的唯一标识timestamp: timestamp, // 必填,生成签名的时间戳nonceStr: nonceStr, // 必填,生成签名的随机串signature: signature, // 必填,签名,见附录1jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone','updateAppMessageShareData','updateTimelineShareData']}/*权限验证配置*/wx.config(obj);if(browser.versions.mobile) {
     //判断是否是移动设备打开。browser代码在下面var ua = navigator.userAgent.toLowerCase(); //获取判断用的对象if(ua.match(/MicroMessenger/i) == "micromessenger") {
    wx.ready(function() {
    WeixinJSBridge.call('showOptionMenu');/*加载完数据,能分享的时候隐藏加载层*/$("#preloader").hide();/*1-分享给朋友*/wx.onMenuShareAppMessage(shareObj);/*2-分享给朋友圈*/wx.onMenuShareTimeline(shareObj);/*3-分享到QQ好友*/wx.onMenuShareQQ(shareObj);/*4-分享到QQ空间*/wx.onMenuShareQZone(shareObj);/*5-分享到腾讯微博*/wx.onMenuShareWeibo(shareObj);wx.updateAppMessageShareData(shareObj);wx.updateTimelineShareData(shareObj);});wx.error(function(res) {
    });} else {
    /*加载完数据,能分享的时候隐藏加载层*/$("#preloader").hide();}} else {
    $("#preloader").hide();}}});
}
/*=======================================分享End=======================================*/
/*=======================================linkedMe简单集成 start=======================================*/
function linkedMeFnc(){
    var dataObj = {
    };linkedme.init("adb46621c86d85be95641445092af93c", {
    type: "live"}, null);dataObj.type = "live";linkedme.link(dataObj, function(err, data) {
    if(err) {
    return err;} else {
    gObj.jumpAppPath = data.url;}}, false);
}/*=======================================linkedMe简单集成 End=======================================*//*** Created by Administrator on 2016/11/19.*/
/*获取查询字符串对象*/
function getUrlAttribute(url) {
    var url = url.replace('?', '').trim()if(url.length > 0) {
    var args = new Object();var pairs = url.split("&");for(var i = 0; i < pairs.length; i++) {
    var pos = pairs[i].indexOf("=");if(pos == -1)continue;var argname = pairs[i].substring(0, pos);var value = pairs[i].substring(pos + 1);value = decodeURIComponent(value);args[argname] = value;}//根据键名获取值return args;}
}
//删除url指定名称的参数,返回新的url
function removeUrlAttribute(url, name1, name2) {
    var str1 = url.split('?')[0] + '?';var url = url.split('?')[1]var str = '';if(url.length > 0) {
    var args = new Object();var pairs = url.split("&");for(var i = 0; i < pairs.length; i++) {
    var pos = pairs[i].indexOf("=");if(pos == -1)continue;var argname = pairs[i].substring(0, pos);var value = pairs[i].substring(pos + 1);value = decodeURIComponent(value);if(argname == name1 || argname == name2) {
    continue;}str += argname + '=' + value + '&';}return str1 + str.substr(0, str.length - 1);}
}
/*验证码倒计时*/
var clock = '';
var nums = 60;
var btn;function sendCode(thisBtn) {
    btn = thisBtn;btn.disabled = true; //将按钮置为不可点击btn.value = nums + '秒后可重发';clock = setInterval(doLoop, 1000); //一秒执行一次
}function doLoop() {
    nums--;if(nums > 0) {
    btn.value = nums + '秒后可重发';} else {
    clearInterval(clock); //清除js定时器btn.disabled = false;btn.value = '获取验证码';nums = 60; //重置时间}
}
/*==================================时间函数START============================================*/
//设置时间格式
var minute = 1000 * 60;
var hour = minute * 60;
var day = hour * 24;
var halfamonth = day * 15;
var month = day * 30;function getDateDiff(dateTimeStamp) {
    var now = new Date().getTime();var diffValue = now - dateTimeStamp;var monthC = diffValue / month;var weekC = diffValue / (7 * day);var dayC = diffValue / day;var hourC = diffValue / hour;var minC = diffValue / minute;if(monthC >= 1) {
    result = "发表于" + parseInt(monthC) + "个月前";} else if(weekC >= 1) {
    result = "发表于" + parseInt(weekC) + "周前";} else if(dayC >= 1) {
    result = "发表于" + parseInt(dayC) + "天前";} else if(hourC >= 1) {
    result = "发表于" + parseInt(hourC) + "个小时前";} else if(minC >= 1) {
    result = "发表于" + parseInt(minC) + "分钟前";} elseresult = "刚刚发表";return result;
};//时间格式封装,timeStamp:时间戳 |nowData:现在时间
function TimeLayout(timeStamp, nowDate, timeShow, publishMonth, publishYear, publishDate, publishHours, publishMinutes) {
    if(timeStamp < 7200000) {
    return timeShow = "1小时以前";} else if(timeStamp >= 7200000 && timeStamp < 86400000) {
    return timeShow = parseInt(timeStamp / 1000 / 60 / 60);} else if(timeStamp > 86400000 && nowDate == publishYear) {
    if(publishMonth < 10) {
    publishMonth = '0' + publishMonth};if(publishDate < 10) {
    publishDate = '0' + publishDate};if(publishHours < 10) {
    publishHours = '0' + publishHours};if(publishMinutes < 10) {
    publishMinutes = '0' + publishMinutes};return timeShow = publishMonth + '-' + publishDate + "&nbsp" + publishHours + ":" + publishMinutes;} else if(timeStamp > 86400000 && nowDate != publishYear) {
    if(publishMonth < 10) {
    publishMonth = '0' + publishMonth};if(publishDate < 10) {
    publishDate = '0' + publishDate};if(publishHours < 10) {
    publishHours = '0' + publishHours};if(publishMinutes < 10) {
    publishMinutes = '0' + publishMinutes};return timeShow = publishYear + '-' + publishMonth + '-' + publishDate;};
};
//时间格式封装,timeStamp:时间戳 |nowData:现在时间
function TimeLayoutnew(timeStamp, nowDate, timeShow, publishMonth, publishYear, publishDate, publishHours, publishMinutes) {
    var year = new Date().getFullYear();if(publishMonth < 10) {
    publishMonth = '0' + publishMonth};if(publishDate < 10) {
    publishDate = '0' + publishDate};if(publishHours < 10) {
    publishHours = '0' + publishHours};if(publishMinutes < 10) {
    publishMinutes = '0' + publishMinutes};if(Number(year) > Number(publishYear)) {
    return timeShow = publishYear + '-' + publishMonth + '-' + publishDate;} else {
    return timeShow = publishMonth + '-' + publishDate;}
}
//设置时间样式——播放器用
function add0(m) {
    return m < 10 ? '0' + m : m;
}function format(shijianchuo) {
    var time = new Date(shijianchuo);var y = time.getFullYear();var m = time.getMonth() + 1;var d = time.getDate();var h = time.getHours();var mm = time.getMinutes();var s = time.getSeconds();return y + '-' + add0(m) + '-' + add0(d)
}//获取当前时间戳——yymmhhddss
function getNowFormatDate() {
    var date = new Date();var month = date.getMonth() + 1;var strDate = date.getDate();if(month >= 1 && month <= 9) {
    month = "0" + month;}if(strDate >= 0 && strDate <= 9) {
    strDate = "0" + strDate;}var currentdate = date.getFullYear() + month + strDate + date.getHours() + date.getMinutes() + date.getSeconds();return currentdate;
}
//时间格式封装结束
/*==================================时间函数START============================================*//*** //下方更多视频和朋友圈转疯了列表*/function toRefurbish() {
    var oRefurbish = false; // 中间值 确认刷新var scrollT = 0; //document.addEventListener('touchstart', function(ev) {
    var oEvent = ev || event;var touch = oEvent.touches[0]; //获取第触点var x = Number(touch.clientX); //页面触点X坐标var y = Number(touch.clientY); //页面触点Y坐标var startX = x;document.addEventListener('touchmove', function(ev) {
    var oEvent = ev || event;var touch = oEvent.touches[0]; //获取第触点var x = Number(touch.clientX); //页面触点X坐标var y = Number(touch.clientY); //页面触点Y坐标var EndX = x;document.addEventListener('touchend', function(ev) {
    var oEvent = ev || event;if(EndX - startX >= 100 && oRefurbish == false && scrollT == 0) {
    oRefurbish = true;window.location.reload();}}, false);}, false);}, false)
}/*** 电视剧列表* [[1,2...15],[16,17,...30]]*/
function NumOfEpisode(num) {
    var tmp = 0; //15var tol = 0; //逢15进1var arr = new Array(); //每次进1push到数组中var iii = new Array();for(var i = 0; i < num; i++) {
    iii.push(i + 1);tmp++;if(tmp == 15) {
    tmp = 0;tol++;arr.push(iii);var iii = new Array();}}if(iii.length > 0) {
    arr.push(iii);}return arr;
}/*md5加密十次*/
function md5s(hash) {
    for(var i = 0; i < 10; i++) {
    hash = hex_md5(hash);}return hash;
}
/*预加载图片的方法*/
var loadImg = function(src, callback) {
    var oScript = new Image();oScript.src = src;oScript.onload = function() {
    if(typeof(callback) == "function") {
    callback();} else {
    return}}
}
/*=====================================轮播图START================================================*/
/*注册滑动事件*/
function ul_scroll(ulDom) {
    var startX = 0;var moveX = 0;var distanceX = 0;/*加移动限制*/var ulWidth = ulDom.offsetWidth;var bodyWidth = document.body.offsetWidth;// 移动的 范围var maxX = 0;var minX = bodyWidth - ulWidth;// 定义 移动的 偏差值var xDelay = 100;ulDom.addEventListener('touchstart', function(e) {
    moveX = 0;//记录起始值startX = e.touches[0].clientX;// 关闭 过渡效果ulDom.style.transition = 'none';})ulDom.addEventListener('touchmove', function(e) {
    //记录移动值moveX = e.touches[0].clientX - startX;// 为了保证 正好是在 范围内移动 需要对移动的距离进行修正if((moveX + distanceX) < (maxX + xDelay) && (moveX + distanceX) > (minX - xDelay)) {
    // 移动ulDom.style.transform = 'translateX(' + (moveX + distanceX) + 'px)';}})ulDom.addEventListener('touchend', function(e) {
    distanceX = distanceX + moveX;// 判断 当前的这个 distanceY 是否 超出了 范围 maxX = minX = // 如果 比最大的还要大if(distanceX > maxX) {
    distanceX = maxX;} else if(distanceX < minX) {
    distanceX = minX;}if(Math.abs(moveX) > 0) {
    // 添加过渡即可ulDom.style.transition = 'all .5s';// 移动回去ulDom.style.transform = 'translateX(' + distanceX + 'px)';}})
}/*更新如下: 1.解决了快速点击切换过快。现在连击切换有延迟。 2.解决了小圆点和左右按钮现在可以不要。而不会出现的bug 3.*/
//这是函数
function imgscrool(obj) {
    var moving = false;var width = $(obj + " .banner .img li").width();var i = 0;var clone = $(obj + " .banner .img li").first().clone();$(obj + " .banner .img").append(clone);var size = $(obj + " .banner .img li").size();for(var j = 0; j < size - 1; j++) {
    $(obj + " .banner .num").append("<li></li>");}$(obj + " .banner .num li").first().addClass("on");/*鼠标划入圆点*/if($(obj + " .banner .num li")) {
    $(obj + " .banner .num li").hover(function() {
    var index = $(this).index();i = index;$(obj + " .banner .img").stop().animate({
    left: -index * width}, 1000)$(this).addClass("on").siblings().removeClass("on")})};/*自动轮播*/var t = setInterval(function() {
    i++;move();}, 2000)/*对banner定时器的操作*/$(obj + " .banner").hover(function() {
    clearInterval(t);}, function() {
    t = setInterval(function() {
    i++;move();}, 2000)})if($(obj + " .banner .btn_l")) {
    /*向左的按钮*/$(obj + " .banner .btn_l").stop(true).click(function() {
    if(moving) {
    return;};moving = true;i--move();})/*向右的按钮*/$(obj + " .banner .btn_r").stop(true).click(function() {
    if(moving) {
    return;}moving = true;i++move()})};/*图片滑动 touch事件)*/var imageBox = $(obj + " .banner .img").get(0);var startX = 0;var moveX = 0;var distanceX = 0;var isMove = false;imageBox.addEventListener('touchstart', function(e) {
    clearInterval(t);startX = e.touches[0].clientX;});imageBox.addEventListener('touchmove', function(e) {
    isMove = true;moveX = e.touches[0].clientX;distanceX = moveX - startX; /*distanceX 值 正负*/var currX = -i * width + distanceX;$(obj + " .banner .img").stop(true).animate({
    left: currX}, 1000)});/*手指向左滑动*/imageBox.addEventListener('touchend', function(e) {
    if(isMove && (Math.abs(distanceX) > width / 30)) {
    /*5.当超过了一定的距离的时候 滚动 到上一张 或 下一张 (一定的距离 1/20 屏幕宽度 过渡)*/if(distanceX > 0) {
    i--move1();} else {
    i++;move1();}} else {
    move()}/*重置*/startX = 0;moveX = 0;distanceX = 0;isMove = false;/*添加定时器*/clearInterval(t);t = setInterval(function() {
    i++;move();}, 2000)});function move() {
    if(i == size) {
    $(obj + " .banner .img").css({
    left: 0})i = 1;}// 修改轮播每屏宽度if(i == -1) {
    $(obj + " .banner .img").css({
    left: -(size - 1) * width})i = size - 2;}$(obj + " .banner .img").stop(true).delay(200).animate({
    left: -i * width}, 1000, function() {
    moving = false;})if(i == size - 1) {
    $(obj + " .banner .num li").eq(0).addClass("on").siblings().removeClass("on")} else {
    $(obj + " .banner .num li").eq(i).addClass("on").siblings().removeClass("on")}}/*手指滑動圖片輪播函數*/function move1() {
    if(i == size) {
    $(obj + " .banner .img").css({
    left: 0})i = 1;}// 修改轮播每屏宽度if(i == -1) {
    $(obj + " .banner .img").css({
    left: -(size - 1) * width})i = size - 2;}$(obj + " .banner .img").stop(true).animate({
    left: -i * width}, 1000, function() {
    moving = false;})if(i == size - 1) {
    $(obj + " .banner .num li").eq(0).addClass("on").siblings().removeClass("on")} else {
    $(obj + " .banner .num li").eq(i).addClass("on").siblings().removeClass("on")}}
}/*第二种*/
/*轮播图*/
function banner() {
    /*获取到dom对象*/var banner = document.querySelector('.banner');var w = banner.offsetWidth;var imageBox = banner.querySelector('ul.img');var len = $('.img li').length;var pointBox = document.querySelector('ul.icon');var points = pointBox.querySelectorAll('li');/*添加过渡*/var addTransition = function() {
    imageBox.style.webkitTransition = "all .2s"; /*兼容*/imageBox.style.transition = "all .2s";};/*删除过渡*/var removeTransition = function() {
    imageBox.style.webkitTransition = "none"; /*兼容*/imageBox.style.transition = "none";};/*改变位子*/var setTranslateX = function(translateX) {
    imageBox.style.webkitTransform = "translateX(" + translateX + "px)";imageBox.style.transform = "translateX(" + translateX + "px)";};/*1.自动的滚动起来 (定时器,过渡)*/var index = 1;var timer = setInterval(function() {
    /*箱子滚动*/index++;/*加过渡*/addTransition();setTranslateX(-index * w);/*小标ul*/setPoint();}, 3000);/*绑定一个过渡结束事件*/imageBox.addEventListener('webkitTransitionEnd', function() {
    if(index >= 6) {
    index = 1;removeTransition();setTranslateX(-index * w);} else if(index <= 0) {
    index = 5;removeTransition();setTranslateX(-index * w);}});var setPoint = function() {
    /*把所有点的样式清除*/for(var i = 0; i < points.length; i++) {
    points[i].className = " ";}if(index >= 6) {
    points[0].className = "now";} else if(index <= 0) {
    points[4].className = "now";} else {
    points[index - 1].className = "now";}}/*3.图片滑动 touch事件)*/var startX = 0;var moveX = 0;var distanceX = 0;var isMove = false;imageBox.addEventListener('touchstart', function(e) {
    /*清除定时器*/clearInterval(timer);startX = e.touches[0].clientX;});imageBox.addEventListener('touchmove', function(e) {
    isMove = true;moveX = e.touches[0].clientX;distanceX = moveX - startX;/*将要去做定位*/var currX = -index * w + distanceX;/*删除过渡*/removeTransition();/*改变位子*/setTranslateX(currX);});imageBox.addEventListener('touchend', function(e) {
    /*当超过了一定的距离的时候 */if(isMove && (Math.abs(distanceX) > w / 30)) {
    /*5.当超过了一定的距离的时候 滚动 到上一张 或 下一张 (一定的距离 1/20 屏幕宽度 过渡)*/if(distanceX > 0) {
    index--; /*向右滑 上一张*/} else {
    index++; /*向左滑 下一张*/}addTransition();setTranslateX(-index * w);setPoint();}/*当不超过一定的滑动距离的时候*/else {
    /*4.当不超过一定的滑动距离的时候 吸附回去 定位回去 (一定的距离 1/3 屏幕宽度 过渡)*/addTransition();setTranslateX(-index * w);}/*重置*/startX = 0;moveX = 0;distanceX = 0;isMove = false;/*添加定时器*/clearInterval(timer);timer = setInterval(function() {
    /*箱子滚动*/index++;/*定位 过渡来做定位的 这样才有动画*//*加过渡*/addTransition();/*改变位子*/setTranslateX(-index * w);/*小标ul*/setPoint();}, 3000);});
}
/*===============================================轮播图END=====================================================*/
/*====================================防盗链加签名,访问阿里云数据需要权限-后面因为防盗链有问题就不用加签名了=====================================*/
function getVideoPower(gObj, fn) {
    $.ajax({
    type: "get",url: "/app/webVideo/getMSConfig.json?" + getNowTime(),async: true,dataType: 'json',success: function(data) {
    var configDataObj = data.data;var videoUrlOss = gObj.videoUrl.split('http://')[1];var videoUrlX = videoUrlOss.split('/')[0];if(configDataObj.customEndpoint == videoUrlX) {
    var client = new OSS.Wrapper({
    region: configDataObj.region,accessKeyId: configDataObj.accessKeyId,accessKeySecret: configDataObj.accessKeySecret,bucket: configDataObj.outBucket});videoUrlOss = videoUrlOss.substring(videoUrlOss.indexOf("\/") + 1, videoUrlOss.length);gObj.videoUrl = client.signatureUrl(videoUrlOss, {
    expires: configDataObj.expires});}//播放器gObj.player = new prismplayer({
    id: "J_prismPlayer", // 容器idsource: gObj.videoUrl, // 视频地址autoplay: false, //自动播放:否width: "100%", // 播放器宽度height: "400px", // 播放器高度cover: gObj.videoPic,playsinline: true});if(fn) {
    fn();}}});
}/*===========================================广告相关Start==============================================*/
/*广告倒计时*/
function adCountdown(total, adplaytime, fn) {
    /*倒计时div显示*/$('.adBtn').show();$('.adClose').hide(); /*关闭按钮隐藏状态*/$('.adSecond').html(total + 's'); /*显示广告总时长*/var i = 0;var clock = setInterval(function() {
    total--;i++;if(i == adplaytime) {
    $('.adClose').show(); /*显示关闭按钮*/};if(total > 0) {
    $(".adSecond").html(total + 's'); /*广告时长倒计时*/} else {
    clearInterval(clock); //清除js定时器$('.adBtn').hide(); /*最后隐藏倒计时div*/if(fn) {
    fn();}}}, 1000);$(".adClose").click(function() {
    clearInterval(clock); //清除js定时器$('.adBtn').hide();if(fn) {
    fn();$(".adClose").off('click');}})
}/*ios片尾广告封装*/
function adLastOne(gObj, adUrl, videoUrl, pasteradlist1) {
    gObj.player.on('ended', function() {
    $('.prism-controlbar').css('opacity', 0);gObj.player.loadByUrl(adUrl);var totalSecond = Math.floor(pasteradlist1.advideotime / 1000);var adplaytime = Math.floor(pasteradlist1.adplaytime / 1000);$('.adSecond').html(totalSecond + 's');$('.adBtn').show();$('.prism-big-play-btn').hide();gObj.player.off('ended');/*广告倒计时*/adCountdown(totalSecond, adplaytime, function() {
    $('.adBtn').remove();$('.prism-big-play-btn').hide();$('.prism-controlbar').css('opacity', 1);gObj.player.loadByUrl(videoUrl);gObj.player.pause();})})
}/*andriod片尾广告封装*/
function adLastAndriod(gObj, adUrl, videoUrl) {
    gObj.player.on('ended', function() {
    gObj.player.loadByUrl(adUrl);$('.prism-controlbar').css('opacity', 0);gObj.player.off('ended');gObj.player.on('ended', function() {
    gObj.player.loadByUrl(videoUrl);gObj.player.pause();})})
}/*ios片中广告封装*/
function adMiddle(gObj, pasteradlist1) {
    var adUrlMiddle = pasteradlist1.adpicture;var puttime = pasteradlist1.puttime;var Middletotal = Math.floor(pasteradlist1.advideotime / 1000);var MiddleAdplaytime = Math.floor(pasteradlist1.adplaytime / 1000);var getTime = setInterval(function() {
    var currentTime = Math.floor(gObj.player.getCurrentTime());if(currentTime == puttime) {
    clearInterval(getTime);gObj.player.pause();$('#adJ_prismPlayer').show();gObj.Adplayer = new prismplayer({
    id: "adJ_prismPlayer", // 容器idsource: adUrlMiddle, // 视频地址autoplay: true, //自动播放:否width: "100%", // 播放器宽度height: "400px", // 播放器高度playsinline: true});gObj.Adplayer.play();$('.prism-controlbar').css('opacity', 0);adCountdown(Middletotal, MiddleAdplaytime, function() {
    $('#adJ_prismPlayer').remove();$('.prism-controlbar').css('opacity', 1);gObj.player.play();$('.prism-big-play-btn').hide();})}}, 1000)
}
/*===========================================广告相关END==============================================*/
  相关解决方案