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;
}
function getStyle(ele,attr){
return window.getComputedStyle ? window.getComputedStyle(ele, null)[attr] : ele.currentStyle[attr];
}
var gObj = {
};
gObj.flag = true;
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'
};
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)); }return value;
}
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); 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, presto: u.indexOf('Presto') > -1, 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/), android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, iPhone: u.indexOf('iPhone') > -1, iPad: u.indexOf('iPad') > -1, webApp: u.indexOf('Safari') == -1, weixin: u.indexOf('MicroMessenger') > -1, qq: u.match(/\sQQ/i) == "qq", weibo: u.match(/WeiBo/i) == "weibo", };}(),language: (navigator.browserLanguage || navigator.language).toLowerCase()
};
var isWeibo = false;
gObj.isWeibo = false;
if(browser.versions.mobile) {
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") {
}if(browser.versions.ios) {
}if(browser.versions.android) {
}
}
function getStrCount(scrstr, armstr) {
var count = 0;while(scrstr.indexOf(armstr) >= 1) {
scrstr = scrstr.replace(armstr, "")count++;}return count;
}
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>');imgscrool('#header');$('.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;}})}}});
}
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;}
}
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, jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone','updateAppMessageShareData','updateTimelineShareData']}wx.config(obj);if(browser.versions.mobile) {
var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i) == "micromessenger") {
wx.ready(function() {
WeixinJSBridge.call('showOptionMenu');$("#preloader").hide();wx.onMenuShareAppMessage(shareObj);wx.onMenuShareTimeline(shareObj);wx.onMenuShareQQ(shareObj);wx.onMenuShareQZone(shareObj);wx.onMenuShareWeibo(shareObj);wx.updateAppMessageShareData(shareObj);wx.updateTimelineShareData(shareObj);});wx.error(function(res) {
});} else {
$("#preloader").hide();}} else {
$("#preloader").hide();}}});
}
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);
}
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;}
}
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); btn.disabled = false;btn.value = '获取验证码';nums = 60; }
}
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;
};
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 + " " + 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;};
};
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)
}
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;
}
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); var y = Number(touch.clientY); var startX = x;document.addEventListener('touchmove', function(ev) {
var oEvent = ev || event;var touch = oEvent.touches[0]; var x = Number(touch.clientX); var y = Number(touch.clientY); 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)
}
function NumOfEpisode(num) {
var tmp = 0; var tol = 0; var arr = new Array(); 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;
}
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}}
}
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;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)';}})
}
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)$(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()})};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; 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)) {
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() {
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)";};var index = 1;var timer = setInterval(function() {
index++;addTransition();setTranslateX(-index * w);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";}}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)) {
if(distanceX > 0) {
index--; } else {
index++; }addTransition();setTranslateX(-index * w);setPoint();}else {
addTransition();setTranslateX(-index * w);}startX = 0;moveX = 0;distanceX = 0;isMove = false;clearInterval(timer);timer = setInterval(function() {
index++;addTransition();setTranslateX(-index * w);setPoint();}, 3000);});
}
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", source: gObj.videoUrl, autoplay: false, width: "100%", height: "400px", cover: gObj.videoPic,playsinline: true});if(fn) {
fn();}}});
}
function adCountdown(total, adplaytime, fn) {
$('.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); $('.adBtn').hide(); if(fn) {
fn();}}}, 1000);$(".adClose").click(function() {
clearInterval(clock); $('.adBtn').hide();if(fn) {
fn();$(".adClose").off('click');}})
}
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();})})
}
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();})})
}
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", source: 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)
}