//关闭弹框 function closePop() { $(".mask").hide(); $(".pop").hide(); } //下载 var download_lock = 1, download_lock1 = 1; $(".download_btn[data-name='download']").on("click", function () { var _num = $(this).data('price'); var aid = $(this).data('aid'); if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } if (download_lock == 1) { $.ajax({ type: "post", url: "/index/consume/download_link", data: { "aid": aid }, beforeSend: function () { download_lock = 0; }, success: function (data) { var status = data.status; var msg = data.msg; var list = data.list; var price = data.price; var remain = data.remain; //未购买 if (status == 0) { if (remain < price) { layer.open({ title: "下载提示", content: '您账户的像素不足,点击确认前往充值。', btn: ["确认", "取消"], btnAlign: "c", closeBtn: true, yes: function () { location.href="/joefy/sfdibshf/joefy"; }, }); } else { layer.open({ title: "下载提示", content: '

使用专线下载需要 ' + _num + ' 像素,请确认。

', btn: ["确认", "取消"], btnAlign: "c", yes: function () { determineDown(aid) }, }); } } else { layer.open({ title: "下载提示", content: '您购买过此资源,本次下载无需再次消费。', btn: ["确认", "取消"], btnAlign: "c", yes: function () { show_vip_download_links(aid, list) return true; }, }); } download_lock = 1; }, error: function () { download_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } }); /** * 音频点击 */ let audio_down_lock = 1; $(".download_btn[data-name='download2']").on("click", function () { switch ($(this).data('state')) { case 1: // 下载音频 if (audio_down_lock !== 1) return false; if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } let _num = $(this).data('price'); $.ajax({ type: "post", url: "/index/consume/download_link", data: { aid: aid, type: 1, }, beforeSend: function () { audio_down_lock = 0; }, success: function (data) { var status = data.status; var msg = data.msg; var list = data.list; var price = data.price; var remain = data.remain; //未购买 if (status == 0) { if (remain < price) { layer.open({ title: "下载提示", content: '您账户的像素不足,点击确认前往充值。', btn: ["确认", "取消"], btnAlign: "c", closeBtn: true, yes: function () { location.href="/joefy/sfdibshf/joefy"; }, }); } else { layer.open({ title: "下载提示", content: '

下载去水印版音频需要 ' + _num + ' 像素,请确认。

', btn: ["确认", "取消"], btnAlign: "c", yes: function () { determineDown(aid, 1) }, }); } } else { layer.open({ title: "下载提示", content: '您购买过此资源,本次下载无需再次消费。', btn: ["确认", "取消"], btnAlign: "c", yes: function () { show_vip_download_links(aid, list, 1) return true; }, }); } audio_down_lock = 1; }, error: function () { audio_down_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); break; case 2: case 4: // 申请音频去水印 window.open('/peiyue/', '_blank') // let _html = '

提示关闭

你确定要申请音频去水印吗?

取消确定

'; // $(".mask").show(); // $("body").append(_html); break; } }); let audio_askfor_lock = 0; /** * 申请音频去水印 * * @param aid */ function askfor(aid) { if (audio_askfor_lock === 1) return; audio_askfor_lock = 1; $.ajax({ type: "post", url: "/index/ajax/audio_askfor", data: { "aid": aid }, success: function (data) { audio_askfor_lock = 0; if (data.status == 0) { msgBox.show(data.msg, msgBox.warn); } else { msgBox.show(data.msg, msgBox.success, 2000); setTimeout("closePop()", 2000); } }, error: function () { audio_askfor_lock = 0; msgBox.show("网络错误请重试", msgBox.warn); } }); } //展示下载链接 function show_vip_download_links(aid, links, type) { let cont = ""; type = type || 0; let title = '专线'; let key = 'vip'; if (type == 1) { title = '音频'; key = 'audio'; } console.log('links', links) if(links.length == 1){ stat_vip_download(aid,`${links[0]}`, type) return; } var content_html = ''; links.map((item, index) => { content_html += ` ${title}下载通道${index+1} `; }) layer.open({ title: "下载提示", content: ``, }); } //点击下载链接进行统计 var stat_vip_down_lock = 1; function stat_vip_download(aid, href, type) { type = type || 0; if (stat_vip_down_lock) { //打开一个不被拦截的新窗口 var newWindow = window.open(); $.ajax({ type: "post", url: "/index/consume/download_stat", data: { aid: aid, type: type }, beforeSend: function () { stat_vip_down_lock = 0; }, success: function (data) { window.event.returnValue = false; newWindow.location.href="isfg;" setTimeout(function () { newWindow.close(); }, 6000); stat_vip_down_lock = 1; }, error: function () { newWindow.location.href="isfg;" setTimeout(function () { newWindow.close(); }, 6000); stat_vip_down_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } //使用像素购买支链下载服务 function determineDown(aid, type) { if (download_lock1 == 1) { type = type || 0; $.ajax({ type: "post", url: "/index/consume/download_consume", data: { aid: aid, type: type }, beforeSend: function () { download_lock1 = 0; }, success: function (data) { var status = data.status, list = data.list, msg = data.msg; if (status == 1) { show_vip_download_links(aid, list, type); } else { $(".mask").hide(); $(".vip_download_pop").hide(); msgBox.show(msg, msgBox.warn); } download_lock1 = 1; }, error: function () { download_lock1 = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } //图片懒加载 $(window).ready(function () { var lazyload = { init: function (opt) { var that = this, op = { extend_height: 300, selectorName: "img", realSrcAtr: "dataimg" }; $.extend(op, opt); that.img.init(op); }, img: { init: function (n) { var that = this, selectorName = n.selectorName, realSrcAtr = n.realSrcAtr, anim = n.anim; function inViewport(el) { var top = $(window).scrollTop(), // var top = document.documentElement.scrollTop || document.body.scrollTop; btm = top + $(window).height(), elTop = $(el).offset().top; return elTop >= top && elTop - n.extend_height <= btm; } $(window).on("scroll", function () { $(selectorName).each(function (index, node) { var $this = $(this); if (!$this.attr(realSrcAtr) || !inViewport(this)) { return; } act($this); }); }); function act(_self) { if (_self.attr('lazyImgLoaded')) return; var img = new Image(), original = _self.attr('dataimg'); img.onload = function () { _self.attr('src', original); }; original && (img.src = original); _self.attr('lazyImgLoaded', true); } } } }; lazyload.init({ anim: false, extend_height: 300, selectorName: ".samLazyImg" }); });