// 底部逻辑
var jq = jQuery.noConflict();
jq(function(){
// 禁止注册限制ProhibitReg
var isProhibintRegister = getQueryString("ProhibitReg");
if(isProhibintRegister == 1) prohibitRegister(2)
jq("#BtnRegister").on("click",function(event){
prohibitRegister(1,event)
})
jq(".hongmeng").on("click", function() {
layer.msg('鸿蒙版需要到鸿蒙手机应用市场下载')
});
// 禁止评论限制
prohibitComment()
//发布帖子限制
jq('#cont,#message,#title').on("focus",function(){
jq.get("http://music.52jianpu.com/tanqin/codeindex.php?d=member&c=checkPostRole&m=checkTime",function(data){
if(data == 0){
layer.msg('当前时间段(01:00-07:00)暂时无法发布评论或帖子。');
jq('#cont,#message,#title').blur();
};
});
jq.get("http://music.52jianpu.com/tanqin/codeindex.php?d=member&c=checkPostRole&m=index", function(data){
if(data == 0){
layer.msg('更换过头像、收藏过曲谱的用户才可以发表评论、发布帖子。')
jq('#cont,#message,#title').blur();
};
});
});
// 企业微信
jq("#BtnWeixin").on("click",function(){
var oHtml = '
方法1:电脑已安装微信,请点击下方按钮。

方法2:如点击不能跳转,请用微信扫一扫启动。

客服在线时间:工作日 9:00-18:00
'
layer.open({
title: '弹琴吧客服',
area: ['400px', '420px'],
content: oHtml,
btn: false,
skin: 'footer-kefu-box',
scrollbar: false,
shadeClose: false,
});
})
// 切换乐器
const logonType = jq(".name_0123").attr("data-type");
if(!logonType) return;
const loginName = jq(".name_0123").text();
const yueqiNum = getCookie('instrumentType');
if(yueqiNum && loginName) return;
const oHtml = ``
onLayerPopup(null,oHtml,null,'800px','yueqi-change-box',null,null)
jq(".yueqi-change-box").on("click","li",function(){
const yueqiType = jq(this).attr("data-type");
const yuepuLink = yueqiJson[yueqiType].homeUrl;
const expirationDate = new Date();
expirationDate.setDate(expirationDate.getDate() + 7); // 7天后过期
document.cookie = 'instrumentType=' + yueqiType + '; expires=' + expirationDate.toUTCString() + '; path=/';
window.location.href = yuepuLink;
})
})
// 公共弹窗
function onLayerPopup(title, content, btnText, area, skin, yesCallback, noCallback, endCallback) { // 公共弹窗
layer.open({
title: title,
content: content,
shadeClose: false,
btn: btnText,
area: area,
skin: skin,
yes: function(){
yesCallback ? yesCallback() : layer.closeAll()
},
btn2: noCallback,
end: endCallback
});
}
// 禁止注册限制
function prohibitRegister(type,event){
if(event) event.preventDefault();
jq.post("http://music.52jianpu.com/tanqin/codeindex.php?d=api&c=getSetting&m=common",function(res){
var resData = JSON.parse(res);
if(resData.data.code == '1000'){
if(resData.data.result.pcProhibitRegSwitch.value == 1){
layer.confirm(resData.data.result.pcProhibitRegMessage.value, {
title: '温馨提示',
skin: 'layer-post-popup',
area: ['400px'],
btn: ['知道了']
}, function(){
if(type == 1) {
layer.closeAll();
} else {
layer.closeAll();
let url = new URL(window.location.href);
url.searchParams.delete('ProhibitReg');
window.history.replaceState({}, document.title, url.toString());
}
});
} else {
if(type == 1) {
var linkUrl = jq("#BtnRegister").attr("href");
window.location.href = linkUrl
} else {
let url = new URL(window.location.href);
url.searchParams.delete('ProhibitReg');
window.history.replaceState({}, document.title, url.toString());
}
}
}
})
}
// 禁止评论限制
function prohibitComment(){
jq(".btn-publish,.fabu_btn_1110,.fabuyuepu,#btnUpdataVideo").on("click",function(event){
event.preventDefault();
var that = jq(this);
jq.post("http://music.52jianpu.com/tanqin/codeindex.php?d=api&c=getSetting&m=common",function(res){
var resData = JSON.parse(res);
if(resData.data.code == '1000'){
if(resData.data.result.pcMutedSwitch.value == 1){
layer.confirm(resData.data.result.pcMutedMessage.value, {
title: '温馨提示',
skin: 'layer-post-popup',
area: ['400px'],
btn: ['知道了']
}, function(){
layer.closeAll();
});
} else {
window.location.href = that.attr("href");
}
}
})
})
}
function viewData(){
var e = 0, l = 0, i = 0, g = 0, f = 0, m = 0;
var j = window, h = document, k = h.documentElement;
e = k.clientWidth || h.body.clientWidth || 0;
l = j.innerHeight || k.clientHeight || h.body.clientHeight || 0;
g = h.body.scrollTop || k.scrollTop || j.pageYOffset || 0;
i = h.body.scrollLeft || k.scrollLeft || j.pageXOffset || 0;
f = Math.max(h.body.scrollWidth, k.scrollWidth || 0);
m = Math.max(h.body.scrollHeight, k.scrollHeight || 0, l);
return {
scrollTop: g,scrollLeft: i,documentWidth: f,documentHeight: m,viewWidth: e,viewHeight: l};
};
// 获取URL链接参数
function getQueryString(name) {
var reg = new RegExp( "(^|&)" + name + "=([^&]*)(&|$)" , "i" );
var r = window.location.search.substr(1).match(reg);
if ( r != null ){
return decodeURIComponent(r[2]);
} else {
return null ;
}
}