var domain_str = '/api' var ccgt_domain = 'http://cc.lzjoy.com' window.addEventListener('message',function(event){ if(event.data.message == "login-close"){ window.location.href = "http://music.52jianpu.com/pianomusic"; }else if(event.data.message == "reload-close"){ location.reload(); }else if(event.data.message == "page-close"){ $('.login-iframe').hide(); } }, false); (function() { var date = new Date(); var YMD = date.getFullYear() + '-'; YMD += (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; YMD += date.getDate() + '-'; YMD += date.getHours() + '_'; YMD += date.getMinutes() + '_'; YMD += date.getSeconds(); var cc_hm = document.createElement("script"); cc_hm.setAttribute('type','text/javascript'); cc_hm.setAttribute('charset','utf-8'); cc_hm.src = "http://music.52jianpu.com/pianomusic/api/web/tool/DynamicJs?v="+YMD; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(cc_hm, s); })(); function getUrlParam(name){ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } function getUrlParamData(){ var url = window.location.href var loc = url.substring(url.lastIndexOf('/') + 1, url.length) var arr = loc.split('.') arr = arr ? arr[0].split('_') : [] return arr } function setCookie(name, value, days = 30) { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var host = window.location.host.split('.'); if(host.length>=2) { var domain = host[host.length-2] + '.' + host[host.length-1]; } else { var domain = host[host.length-1]; } if (bIsIpad) { //document.cookie = name + "=" + escape(value) + ';path=/;domain=music.52jianpu.com/pianomusic'; document.cookie = name + "=" + escape(value) + ';path=/;domain='+domain; } else { var Days = days; var exp = new Date(); exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ';path=/;domain='+domain; } } function getCookie(name) { var strcookie = document.cookie; //获取cookie字符串 var arrcookie = strcookie.split("; "); //分割 //遍历匹配 for (var i = 0; i < arrcookie.length; i++) { var arr = arrcookie[i].split("="); if (arr[0] == name) { return arr[1]; } } return ""; } var identity = { getServiceUid: function() { return getCookie('service_uid') }, getUid: function() { return getCookie('ccgq_uid') }, getServiceKey: function() { return getCookie('service_key') }, getCcgqUuid: function() { if (typeof window.localStorage === 'undefined') { console.warn('浏览器过低,需升级到更高版本'); alert('浏览器过低,需升级到更高版本'); return ''; } var self = this; var current_uuid= window.localStorage.getItem('ccgq_current_uuid') || ''; if (!current_uuid) { current_uuid = ''; setTimeout(function () { try { self.loadScriptThenCallback('http://music.52jianpu.com/pianomusic/lib/lzjoys101/res/statics/web/fingerprintjs.js', function () { FingerprintJS.load().then(fp => { // The FingerprintJS agent is ready. // Get a visitor identifier when you'd like to. fp.get().then(result => { // This is the visitor identifier: if(result.visitorId) { window.localStorage.setItem('ccgq_current_uuid', 'p0003ccgq'+result.visitorId); } }); }); }); } catch (e) { console.error("GetUuid - " + e.name + ": " + e.message); } }, 50); } return current_uuid; }, getServiceType: function() { return getCookie('service_type') }, getCcUsername: function() { var username = getCookie('cc_username') return unescape(username) }, getIsVip: function() { var isvip = getCookie('cc_is_vip') return parseInt(isvip) }, getVipDte: function() { var vipDate = getCookie('cc_vip_date') //格式化掉 时分秒 var newDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(vipDate) return newDate ? newDate[0] : '' }, getUserphoto: function() { var cc_userphoto = getCookie('cc_userphoto') return decodeURIComponent(cc_userphoto) }, getCcgqUid: function() { return getCookie('ccgq_uid') }, getPHPSESSID: function() { return getCookie('PHPSESSID') }, //加载脚本,成功以后执行回调函数 loadScriptThenCallback: function(script_path, funCallback, callbackParams) { var script = document.createElement("script"); script.type = "text/javascript"; script.src = script_path; if (script.addEventListener) { script.addEventListener("load", function() { console.log('已加载 ' + script_path); funCallback(callbackParams); }, false) } else { if (script.attachEvent) { script.attachEvent("onreadystatechange", function() { var target = window.event.srcElement; if (target.readyState == "loaded") { console.log('已加载: ' + script_path); funCallback(callbackParams); } }) } else { alert('当前浏览器版本不支持'); } } window.document.body.appendChild(script); } } var operation = { add: function(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)) return (arg1 * m + arg2 * m) / m }, sub: function(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)) return (arg1 * m - arg2 * m) / m }, mul: function(arg1, arg2) { var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); try { m += s1.split(".")[1].length } catch (e) {} try { m += s2.split(".")[1].length } catch (e) {} return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m) }, div: function(arg1, arg2) { var t1 = 0, t2 = 0, r1, r2; try { t1 = arg1.toString().split(".")[1].length } catch (e) {} try { t2 = arg2.toString().split(".")[1].length } catch (e) {} r1 = Number(arg1.toString().replace(".", "")) r2 = Number(arg2.toString().replace(".", "")) return (r1 / r2) * Math.pow(10, t2 - t1); }, add_p1: function(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)) m = (arg1 * m + arg2 * m) / m return m.toFixed(1) }, sub_p1: function(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)) m = (arg1 * m - arg2 * m) / m return m.toFixed(1) }, mul_p1: function(arg1, arg2) { var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); try { m += s1.split(".")[1].length } catch (e) {} try { m += s2.split(".")[1].length } catch (e) {} m = Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m) return m.toFixed(1) }, div_p1: function(arg1, arg2) { var t1 = 0, t2 = 0, r1, r2; try { t1 = arg1.toString().split(".")[1].length } catch (e) {} try { t2 = arg2.toString().split(".")[1].length } catch (e) {} r1 = Number(arg1.toString().replace(".", "")) r2 = Number(arg2.toString().replace(".", "")) m = (r1 / r2) * Math.pow(10, t2 - t1) return m.toFixed(1) }, } function handleTabs() { var _actives = $('.tab-header li'); _actives.click(function (params) { var _this = $(this); var _lis = $(_actives).siblings(); var _tabHeaderId = _this.attr('data-tab-header-id'); var _dataActive = _this.parent().attr('data-active'); var _tabBody = $('.' + _dataActive).children(); for (var index = 0; index < _lis.length; index++) { const element = _lis[index]; $(element).removeClass('active'); } if (_tabBody) { for (var index = 0; index < _tabBody.length; index++) { const element = _tabBody[index]; $(element).css('display', 'none'); if ($(element).attr('data-tab-body-id') == _tabHeaderId) { $(element).css('display', 'block'); } } } _this.addClass('active'); $(window).trigger('scroll'); }); // 检查登录状态 var _cc_username = identity.getCcUsername() var _cc_userid = identity.getServiceUid() var _userphoto = identity.getUserphoto() var _isvip = identity.getIsVip() if(_userphoto){ $('.user_info .user_name').text(_cc_username) $('.user_id span').text(_cc_userid) $('.user-head-box img').attr('src', _userphoto) $('.user-head-box img').attr('title', _cc_username) $('.user_info .head-img img').attr('src', _userphoto) $('.usr_tool_box .userinfo>a').attr('href', '/member/' + _cc_userid + '.htm') $('.user-head-box').show() if(_isvip){ $('.user-head-box').addClass('vip') } } if(_cc_username){ $('.user_info .user_name').text(_cc_username) } if(_cc_userid){ $('.user_id span').text(_cc_userid) $('.usr_tool_box .userinfo>a').attr('href', '/member/' + _cc_userid + '.htm') $('.login-box').css('display', 'none') }else{ $('.login-box').css('display', 'block') } } function getImageWidth(url,callback){ var img = new Image(); img.src = url; // 如果图片被缓存,则直接返回缓存数据 if(img.complete){ callback(img.width, img.height); }else{ // 完全加载完毕的事件 img.onload = function(){ callback(img.width, img.height); } } } function convertBase64UrlToBlob(urlData){ var bytes = window.atob(urlData.split(',')[1]); //去掉url的头,并转换为byte //处理异常,将ascii码小于0的转换为大于0 var ab = new ArrayBuffer(bytes.length); var ia = new Uint8Array(ab); for (var i = 0; i < bytes.length; i++) { ia[i] = bytes.charCodeAt(i); } return new Blob( [ab] , {type : 'image/png'}); } function getByteLen(val){ var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; } else { len += 1; } } return len; } function deleteCookie() { clearCookie('ccgq_uid'); clearCookie('cdb_uid'); clearCookie('cdb_ccgqcookie'); clearCookie('cdb_usernamecookie'); clearCookie('cdb_auth'); clearCookie('service_type'); clearCookie('service_key'); clearCookie('service_uid'); clearCookie('cc_username'); clearCookie('cc_userphoto'); clearCookie('cc_is_vip'); } function clearCookie(name) { setCookie(name, "", -1); } function isMobile() { var userAgentInfo = navigator.userAgent; var mobileAgents = [ "Android", "iPhone", "SymbianOS", "Windows Phone", "iPad","iPod"]; var mobile_flag = false; //根据userAgent判断是否是手机 for (var v = 0; v < mobileAgents.length; v++) { if (userAgentInfo.indexOf(mobileAgents[v]) > 0) { mobile_flag = true; break; } } var screen_width = window.screen.width; var screen_height = window.screen.height; //根据屏幕分辨率判断是否是手机 if(screen_width < 500 && screen_height < 800){ mobile_flag = true; } return mobile_flag; } function loadInstall(jump_url) { var loc = $('.opern_name').attr('data-oid') var newPar = parseInt(loc); if('string' == typeof jump_url) { var data = "{\"ccpiano\":\"" + jump_url + "\"}"; } else { if(newPar > 0){ var data = "{\"ccpiano\":\"ccpiano://detail/single/" + newPar + "\"}"; }else{ var data = "{\"ccpiano\":\"ccpiano://start/\"}"; } } new OpenInstall({ appKey: "mdc65i", apkFileName: 'chongchongmusic.apk', preferWakeup: true, onready: function () { m = this if (navigator.userAgent.match(/(iPad);?/i)) { window.location = "http://apps.apple.com/cn/app/id1080634885?l=zh&ls=1"; } else { m.wakeupOrInstall(); return false; } } }, data); } function loginShow(){ if(isMobile()){ loadInstall() return } //加载区号 var getTimeZoneApi = domain_str +'/home/user/getTimeZoneApi'; $.ajax({ type: "GET", contentType: "application/json", url: getTimeZoneApi, dataType: 'json', data: { service_key: identity.getServiceKey(), ccgq_uuid: identity.getCcgqUuid(), service_type: identity.getServiceType(), uid: identity.getUid(), platform: 'web-ccgq', }, success: function(res) { if(res.returnCode == '0000'){ for(var i = 0; i < res.datas.length; i++){ var html = '
  • ' + res.datas[i].countryName +' '+ res.datas[i].number +'
  • '; $('.select_list_box ul').append(html); } } } }); $('.login_iframe').show() } function loginClose(){ $('.login_iframe').hide() } function addhit(hittype) { var hiturl = "http://cc.lzjoy.com/?urlparam=pad/index/stat0001&platform=web-ccgq&type=" + hittype; $.ajax({ url: hiturl, context: document.body, success: function () {} }); } function formatDate() { var nowDate = new Date(); var year = nowDate.getFullYear(); var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1; var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate(); var hour = nowDate.getHours()< 10 ? "0" + nowDate.getHours() : nowDate.getHours(); var minute = nowDate.getMinutes()< 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes(); var second = nowDate.getSeconds()< 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds(); return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second; } function accAdd(num1,num2){ //两个浮点数求和 var r1,r2,m; try{ r1 = num1.toString().split('.')[1].length; }catch(e){ r1 = 0; } try{ r2=num2.toString().split(".")[1].length; }catch(e){ r2=0; } m = Math.pow(10,Math.max(r1,r2)); // return (num1*m+num2*m)/m; return Math.round(num1*m+num2*m)/m; } function accSub(num1,num2){ // 两个浮点数相减 var r1,r2,m; try{ r1 = num1.toString().split('.')[1].length; }catch(e){ r1 = 0; } try{ r2=num2.toString().split(".")[1].length; }catch(e){ r2=0; } m=Math.pow(10,Math.max(r1,r2)); n=(r1>=r2)?r1:r2; return (Math.round(num1*m-num2*m)/m).toFixed(n); } function accDiv(num1,num2){ // 两数相除 var t1,t2,r1,r2; try{ t1 = num1.toString().split('.')[1].length; }catch(e){ t1 = 0; } try{ t2=num2.toString().split(".")[1].length; }catch(e){ t2=0; } r1=Number(num1.toString().replace(".","")); r2=Number(num2.toString().replace(".","")); return (r1/r2)*Math.pow(10,t2-t1); } function accMul(num1,num2){ // 两数相乘 var m=0,s1=num1.toString(),s2=num2.toString(); try{m+=s1.split(".")[1].length}catch(e){}; try{m+=s2.split(".")[1].length}catch(e){}; return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m); } //判断是否拥有新人劵业务 function getMyNewCoupon(service_uid, service_key, ccgq_uuid, service_type, uid){ setCookie('ccgq_new_coupon', 0); var getMyCouponList = domain_str + '/home/coupon/getMyCouponList'; $.ajax({ type: "GET", dataType:"json", url: getMyCouponList, data: { service_type: 'ccgq', platform:'web-ccgq', service_uid: identity.getServiceUid(), service_key: identity.getServiceKey(), ccgq_uuid: identity.getCcgqUuid(), service_type: identity.getServiceType(), uid: identity.getUid(), }, success: function(res) { if(res.returnCode == '0000'){ couponList = res.datas.list.length > 0 ? res.datas.list[0] : null; if(couponList){ if(couponList.vtype == '10002'){ setCookie('ccgq_new_coupon', 1, 1); topadv(); return; } } } $('header .pc .adv').hide(); } }); } function topadv(){ if(!isMobile()){ /*if(window.location.pathname != '/login.htm' && window.location.pathname != '/generate/login.htm'){ $('header .pc .adv').empty(); $('header .pc').prepend('
    '); $('body>section').css({'padding-top':'2.1rem'}); $('body>main').css({'padding-top':'.3rem'}); $('body>main .community_container').css({'padding-top':'2rem'}); $('body>.SLibraryBanner1').css({'margin-top':'157px'}); $('body>.SLibraryBanner').css({'margin-top':'157px'}); $('body>#content-box').css({'padding-top':'260px'}); $('body>section.manage_my_spectrum_set_box').css({'padding-top':'2.5rem'}); $('body>section.manage_my_video').css({'padding-top':'2.5rem'}); $('body>section.manage_my_message').css({'padding-top':'2.5rem'}); $('body>section.manage_my_vip').css({'padding-top':'2.5rem'}); $('body>section.manage_my_money').css({'padding-top':'2.5rem'}); }*/ if(window.location.pathname == '/' || window.location.pathname == '/generate/home.htm') { //首页弹窗 popup(); if(!identity.getUid()){ $('#header .reg a').show(); } } $('.vip-yh70').show(); } } function popup(){ if(!isMobile()){ var old_time = getCookie('ccgq_popup'); old_time = parseInt(old_time); var d = new Date(); var now = d.getTime(); var param=null, expire_millisecond=24*60*60*1000, src="http://music.52jianpu.com/pianomusic/lib/lzjoys201/res/statics/fileupload/51f54fab69cb61d045920ab9686c61f0.png", strClickCallBack='toBuyVipPage'; if ('function' == typeof cc_get_popup_param ) { param = cc_get_popup_param(); if ('undefined' != typeof param) { if (param['expire_millisecond']) expire_millisecond=param['expire_millisecond']; if (param['src']) src=param['src']; if (param['strClickCallBack']) strClickCallBack=param['strClickCallBack']; } } if(!old_time || (old_time + expire_millisecond) < now){ $("body").append(''); var d = new Date(); var n = d.getTime(); setCookie('ccgq_popup', n, 1); } } } function popup2(){ $("body").append(''); } //popup3(); function popup3(){ if(!isMobile()){ var old_time = getCookie('ccgq_popup2'); old_time = parseInt(old_time); var d = new Date(); var now = d.getTime(); if(!old_time || (old_time + 24*60*60*1000) < now){ $("body").append(''); var d = new Date(); var n = d.getTime(); setCookie('ccgq_popup2', n, 1); } } } function closePopup(){ $('.popup-active').hide(); } function copyToClipboard(txt) { if(window.clipboardData){ window.clipboardData.clearData(); window.clipboardData.setData("Text", txt); alert('复制成功!') }else{ alert('请手动复制!') } } function toBuyVipPageH5(){ if(!identity.getUid()){ $("body").append(''); return; } window.location.href = "/sheetplayer/ccgq_h5.html"; return; } window.onload = function(){ handleTabs() };