function isMobile() { if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { return true; } else { return false; } } function getAd(mark, isWriteElement = true) { if (isWriteElement) document.write(''); $.ajax({ type: "GET", cache: false, dataType: "jsonp", data: {mark: mark}, url: 'https://api.piaofei.cn/ad/get-view/aab810d85502a82135a85b7ceb281a52?' + new Date().toString(), crossDomain: true, xhrFields: {withCredentials: true}, beforeSend: function () {}, success: function (result) { if (result.code == 0) { $('.js-show-ad-' + mark).html(result.data); } }, complete: function () {}, }); if (isWriteElement) document.close(); } $('.js-ad-jump').on('click', function () { var that = $(this); var linkType = that.data('link-type'); var link = that.data('link'); if (linkType=='link') { location.replace(link); } else { wx.miniProgram.getEnv(function (res) { if (res.miniprogram==true) { if (linkType=='weApp') wx.miniProgram.navigateTo({url: '/pages/jump/index?type=weApp&appId=' + link}); if (linkType=='weVideo') wx.miniProgram.navigateTo({url: '/pages/jump/index?type=link&linkType=weVideo&link=' + link}); if (linkType=='navigateTo') wx.miniProgram.navigateTo({url: link}); if (linkType=='redirectTo') wx.miniProgram.redirectTo({url: link}); if (linkType=='switchTab') wx.miniProgram.switchTab({url: link}); if (linkType=='reLaunch') wx.miniProgram.reLaunch({url: link}); } }); } }); function randomString(len = 16) { var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; var maxPos = $chars.length; var pwd = ''; for (i = 0; i < len; i++) { pwd += $chars.charAt(Math.floor(Math.random() * maxPos)); } return pwd; } $(function () { $('[data-toggle="show-ad"]').each(function () { var that = $(this); var mark = that.data('mark'); $.ajax({ type: "GET", cache: false, dataType: "jsonp", data: {mark: mark}, url: 'https://api.piaofei.cn/ad/get-view/aab810d85502a82135a85b7ceb281a52?' + new Date().toString(), crossDomain: true, xhrFields: {withCredentials: true}, beforeSend: function () {}, success: function (result) { if (result.code == 0) { that.html(result.data); } }, complete: function () {}, }); }); $('[data-toggle="show-video"]').each(function () { var that = $(this); var type = that.data('type'); var parameter = that.data('parameter'); var width = that.data('width'); var height = that.data('height'); var isLive = that.data('is-live'); var poster = that.data('poster'); $.ajax({ type: "GET", cache: false, dataType: "jsonp", data: {type: type, parameter: parameter, width: width, height: height, isLive: isLive, poster: poster}, url: 'https://api.piaofei.cn/video/get-player/aab810d85502a82135a85b7ceb281a52?' + new Date().toString(), crossDomain: true, xhrFields: {withCredentials: true}, beforeSend: function () {}, success: function (result) { if (result.code == 0) { that.html(result.data); } }, complete: function () {}, }); }); $('.js-change-video').on('click', function () { var that = $(this); var parameter = that.data('parameter'); $.ajax({ type: "GET", cache: false, dataType: "jsonp", data: {parameter: parameter}, url: "https://api.piaofei.cn/video/resolve", crossDomain: true, xhrFields: {withCredentials: true}, headers: {'X-Requested-With': 'XMLHttpRequest'}, beforeSend: function () { }, success: function (result) { if (result.code == 0) { if (typeof videojs != 'undefined') { myPlayer = videojs('js-h5-player'); myPlayer.src(result.data.video); myPlayer.ready(function () { myPlayer.play(); }); } } }, complete: function () { } }); }); $.extend({ "backgroundAudio": function (options) { var defaults = { id: 'background-audio', src: '', autoplay: true, loop: true, preload: 'auto' } var settings = $.extend({}, defaults, options); var container = $('body'); var audio = $(''); container.prepend(audio); var backgroundAudio = {}; backgroundAudio.play = function (src = '', loop = true) { if (src) audio.attr('src', src); audio.attr('loop', loop); backgroundAudio.status = 'play'; audio.get(0).play(); } backgroundAudio.pause = function () { backgroundAudio.status = 'play'; audio.get(0).play(); } backgroundAudio.pause = function () { backgroundAudio.status = 'pause'; audio.get(0).pause(); } backgroundAudio.volume = function (number) { audio.get(0).volume = number; } return backgroundAudio; } }); if (typeof ClipboardJS != 'undefined') { var clipboard = new ClipboardJS('.js-clipboard'); clipboard.on('success', function (e) { mobile.toast({ type: 'success', content: '复制成功', duration: 2000, callback: function () { } }); e.clearSelection(); }); clipboard.on('error', function (e) { mobile.toast({ type: 'error', content: '复制失败', duration: 2000, callback: function () { } }); }); } if (typeof $.fn.lazyload != 'undefined') { $("img.lazyload").lazyload({ threshold: 200 }); } if (typeof wx != 'undefined') { wx.miniProgram.getEnv(function (res) { if (res.miniprogram == true) { $('.js-jump-weapp').on('click', function () { var that = $(this); var appId = that.data('app-id'); var pagePath = that.data('page-path'); var shortLink = that.data('short-link'); var theme = that.data('theme'); if (!theme) theme = $('body').data('theme'); wx.miniProgram.navigateTo({url: '/pages/jump/index?type=weApp&appId=' + appId + '&pagePath=' + pagePath + '&shortLink=' + shortLink + '&theme=' + theme + ''}); }); $('.js-jump-link').on('click', function () { var that = $(this); var linkType = that.data('link-type'); var link = that.data('link'); var linkIsCheckLogin = that.data('link-is-check-login'); var theme = that.data('theme'); if (!theme) theme = $('body').data('theme'); if (linkType=='link') { location.replace(link); } else { wx.miniProgram.navigateTo({url: '/pages/jump/index?type=link&linkType=' + linkType + '&link=' + link + '&linkIsCheckLogin=' + linkIsCheckLogin + '&theme=' + theme + ''}); } }); $('.js-jump-page').on('click', function () { var that = $(this); var pagePath = that.data('page-path'); wx.miniProgram.navigateTo({url: '' + pagePath + ''}); }); $('.js-jump-open-location').on('click', function () { var that = $(this); var longitude = that.data('longitude'); var latitude = that.data('latitude'); var scale = that.data('scale'); var name = that.data('name'); var address = that.data('address'); var theme = that.data('theme'); if (!theme) theme = $('body').data('theme'); wx.miniProgram.navigateTo({url: '/pages/jump/index?type=openLocation&longitude=' + longitude + '&latitude=' + latitude + '&scale=' + scale + '&name=' + name + '&address=' + address + '&theme=' + theme + ''}); }); $('.js-jump-open-file').on('click', function () { var that = $(this); var fileType = that.data('file-type'); var filePath = that.data('file-path'); var theme = that.data('theme'); if (!theme) theme = $('body').data('theme'); wx.miniProgram.navigateTo({url: '/pages/jump/index?type=openFile&fileType=' + fileType + '&filePath=' + filePath + '&theme=' + theme + ''}); }); } }); $('.js-show-image').on('click', function () { var that = $(this); var image = that.data('image'); if (!image) image = that.attr("src"); wx.previewImage({ current: image, urls: [image] }); }); $('.js-show-map').on('click', function () { var that = $(this); var longitude = that.data('longitude'); var latitude = that.data('latitude'); var scale = that.data('scale'); var name = that.data('name'); var address = that.data('address'); wx.openLocation({ longitude: longitude, latitude: latitude, scale: scale, name: name, address: address }); }); } }); function randomString(len = 16) { var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; var maxPos = $chars.length; var pwd = ''; for (i = 0; i < len; i++) { pwd += $chars.charAt(Math.floor(Math.random() * maxPos)); } return pwd; } function isWeiXin() { var ua = window.navigator.userAgent.toLowerCase(); if (ua.match(/MicroMessenger/i) == 'micromessenger') { return true; } else { return false; } }