// 通用数据 let globaldata = { // 滚动高度 scrollheight: 50, // body body: document.documentElement || document.body } // 大屏 下拉菜单 $( function () { let navitems = $("#nav>.nav-item"); const move = (that, show) => { let lis = $(that).find("li"), i = $(that).find("i"); ul = $(that).find("ul"); if (lis.length != 0 && show) { ul.addClass("show"); i.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"); return false; } if (lis.length != 0 && !show) { ul.removeClass("show") i.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"); return false; } return false; } for (let i = 0; i < navitems.length; i++) { $(navitems[i]).mouseenter(function () { let that = this; move(that, true) }).mouseleave(function () { let that = this; move(that, false) }) } } ) // 监听滚动轴 $(function () { // face显示锁 let lock = true; // top显示锁 let locktop = false; // 滚动高度 let height = globaldata.scrollheight; $("body")[0].onscroll = function () { let stop = globaldata.body.scrollTop; // console.log(stop) // 可是区域宽度; if (stop > height && !locktop) { $("#top").removeClass("noshow"); locktop = true; } if (stop < height && locktop) { $("#top").addClass("noshow"); locktop = false; } if ($("body")[0].clientWidth < 768) { return false; } if (stop > height && lock) { $("#face").addClass("noshow"); lock = false return false; } if (stop <= height && !lock) { $("#face").removeClass("noshow"); lock = true; return false; } } }) // 小屏幕 下拉菜单 $(function () { // 按钮开关 let lock = false; const open = () => { if (!lock) { $("#nav-sm").addClass("nav-sm-show").removeClass("nav-sm-noshow"); globaldata.body.addEventListener('touchmove', e => e.preventDefault() , { passive: false }) lock = true return false; } if (lock) { $("#nav-sm").addClass("nav-sm-noshow").removeClass("nav-sm-show"); globaldata.body.removeEventListener('touchmove', e => e.preventDefault() = true, { passive: false }) lock = false; return false; } } $('#listbutton').click(function () { open() }) // 可视区域变化 window.onresize = () => { let appwidth = $("body")[0].clientWidth; if (appwidth > 768) { $("#nav-sm").removeClass("nav-sm-show"); lock = false; return false; } else { // face 移动端显示 try { $("#face").removeClass("noshow"); } catch (err) { } } // if (lock) { // $("#nav-sm").addClass("nav-sm-show"); // return false; // } } }) // 分享设置 var shareModel = { // /** // * 分享QQ好友 // * @param {[type]} title [分享标题] // * @param {[type]} url [分享url链接,默认当前页面链接] // * @param {[type]} pic [分享图片] // * @return {[type]} [description] // */ shareQQ: function (url, title, pic) { var param = { url: url || window.location.href, desc: '', /*分享理由*/ title: title || '', /*分享标题(可选)*/ summary: '',/*分享描述(可选)*/ pics: pic || '',/*分享图片(可选)*/ flash: '', /*视频地址(可选)*/ site: '' /*分享来源 (可选) */ }; var s = []; for (var i in param) { s.push(i + '=' + encodeURIComponent(param[i] || '')); } var targetUrl = "https://connect.qq.com/widget/shareqq/iframe_index.html?" + s.join('&'); window.open(targetUrl, 'qq'); }, // /** // * 微信分享 // * @return {[type]} [description] // */ weixin: function () { var url = window.location.href, encodePath = encodeURIComponent(url), targetUrl = 'https://api.gaokaozhitongche.com/v1/direct?text=' + encodePath; window.open(targetUrl, 'weixin'); }, // /** // * 分享新浪微博 // * @param {[type]} title [分享标题] // * @param {[type]} url [分享url链接,默认当前页面] // * @param {[type]} pic [分享图片] // * @return {[type]} [description] // */ sinaWeiBo: function (title, url, pic) { var param = { url: url || window.location.href, type: '3', count: '1', /** 是否显示分享数,1显示(可选)*/ appkey: '', /** 您申请的应用appkey,显示分享来源(可选)*/ title: '', /** 分享的文字内容(可选,默认为所在页面的title)*/ pic: pic || '', /**分享图片的路径(可选)*/ ralateUid: '', /**关联用户的UID,分享微博会@该用户(可选)*/ rnd: new Date().valueOf() } var temp = []; for (var p in param) { temp.push(p + '=' + encodeURIComponent(param[p] || '')) } var targetUrl = 'https://service.weibo.com/share/share.php?' + temp.join('&'); window.open(targetUrl, 'sinaweibo'); } }; $(function () { $("#share").mouseenter(function () { $(this).children("ul").css("width", 'auto') }).mouseleave(function () { $(this).children("ul").css("width", '0px') }) let lis = $("#share>ul>li"); for (let i = 0; i < lis.length; i++) { if (i == 1) { $(lis[i]).click(function () { shareModel.shareQQ(); }) } // if (i == 2) { // $(lis[i]).click(function () { // shareModel.weixin(url = "https://app.gaokaozhitongche.com/"); // }) // } if (i == 2) { $(lis[i]).click(function () { console.log(1) shareModel.sinaWeiBo(); }) } } }) // 按钮锁 $(function () { $("#top").click(function () { let dom = globaldata.body; // let top = document.documentElement.scrollTop || document.body.scrollTop; $(dom).animate({ scrollTop: 0 }, 500); }) }) // toast 背景事件 $(function () { $("#toast").click(function (e) { if (e.target.id != 'toast') return false $(this).removeClass("show"); Array.prototype.slice.call($(this).find(".show")).forEach(e => { $(e).removeClass("show") }) }) }) // 下载app $(function () { $("#download button").click( function () { window.location.href = "http://down.gaokaoapp.net"; } ) }) // 评论区 点赞 $(function () { const globaldata = { // 用户是否登录 user: false, // 登录弹框 sgin () { $("#toast").addClass("show").find(".msg").addClass("show").unbind("click").click(function () { window.location.href = "http://down.gaokaoapp.net" }); } } // 显示区高度 let ch = document.documentElement.clientHeight || document.body.clientHeight; // 实现评论区加载 let lock = false; $(window).scroll(function () { if (lock) return false; // 滑动区高度 let sh = document.documentElement.scrollHeight || document.body.scrollHeight; // 滑动位置 let st = document.documentElement.scrollTop || document.body.scrollTop; let c = sh * 1 - ch * 1 - st * 1; if (c == 0) { lock = true; $(".comment>.loading").addClass("show") setTimeout(function ( ) { $(".comment>.loading").removeClass("show"); data().then(res => { if (res) { $(".comment>.nodata").addClass("show"); } lock = res; }); }, 2000) } }) // 阅读量问题 // 评论区 function data () { // 请求 根据请求改变内容 唯一标识 data-userid="1" data-good="false" let com = `
QQ官方
0
对此,广东警官学院表示,其普通高等教育(全日制)招生工作严格执行教育部的“阳光高考”规定和工作程序,不以任何形式承诺录取,不因任何理由降低标准录取。学校从未委托任何个人、中介组织或招生机构开展提前招生、高职扩招等宣
2020-12-15
举报
`; return new Promise(resolve => { $("#detail").append(com); //评论点赞 登录状态 请求 let lists = $("#detail>.user"); // 模拟无信息加载情况 if (lists.length == 10) { resolve(true) } for (let i = 0; i < lists.length; i++) { $(lists[i]).unbind("click"); $(lists[i]).click(function (e) { if (!globaldata.user) { globaldata.sgin(); return false } let userid = $(this).data("userid"); let lock = $(this).data("good"); let gods = e.target.dataset.gods; if (gods == 1) { let $i = $(this).find("i"); let $span = $(this).find("span"); let num = $span.text(); if (!lock) { $i.addClass("color"); $(this).data("good", true); $span.text(num * 1 + 1); } else { $i.removeClass("color"); $(this).data("good", false); $span.text(num * 1 - 1); } return false; } if (gods == 2) { $("#toast").addClass("show").find("#report").addClass("show").data("userid", userid); } }) } resolve(false); }) } // 阅读点赞 登录状态 请求 $("#read>.good").click(function () { if (!globaldata.user) { globaldata.sgin(); return false } let $i = $(this).find("i"); let $span = $(this).find("span"); let num = $span.text(); let lock = $i.data("good"); if (!lock) { $i.addClass("color"); $i.data("good", true); $span.text(num * 1 + 1); } else { $i.removeClass("color"); $i.data("good", false); $span.text(num * 1 - 1); } }) })