UNPKG

meetyou-gulp

Version:

This is a gulp task collection for MeetYou.

90 lines (79 loc) 3.05 kB
;(function() { "use strict"; $(function () { var review = function() { this.init(); }; review.prototype.init = function() { this.lazy(); this.down(); }; review.prototype.lazy = function() { $("img.lazy").lazyload({ threshold : 200, failure_limit : 0, event : "scroll", effect : "fadeIn", container : window, data_attribute : "url", skip_invisible : true, appear : null, load : null, placeholder : "/static/img/empty.png" }); }; review.prototype.down = function() { function getUrlParam(name) { var reg = new RegExp ("(^|&)" + name + "=([^&]*)(&|#|$)" ); // 构造一个含有目标参数的正则表达式对象 var r = window .location. search.substr (1). match(reg ); //匹配目标参数 if (r != null ) { if (name == 'v') {//版本 r[ 2] = parseFloat (r[ 2].substr (0, 3)); return r[2 ]; } return unescape(r [2]); } else { return null ; } } /** * 验证是否为智能手机 */ $.checkMobile = function(){ var flag = false; var agent = navigator.userAgent.toLowerCase(); var keywords = [ "android", "iphone", "ipod", "ipad", "windows phone", "mqqbrowser" ]; //排除 Windows 桌面系统 if (!(agent.indexOf("windows nt") > -1) || (agent.indexOf("windows nt") > -1 && agent.indexOf("compatible; msie 9.0;") > -1)) { //排除苹果桌面系统 if (!(agent.indexOf("windows nt") > -1) && !agent.indexOf("macintosh") > -1 ) { for (var item in keywords) { if (agent.indexOf(item) > -1 ) { flag = true; break; } } } } return flag; } var u = navigator.userAgent, app = navigator.appVersion; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 var num = getUrlParam('num'); var jButton = $("#J_button"); if (isiOS==true) { jButton.attr('href','http://a.app.qq.com/o/simple.jsp?pkgname=com.lingan.seeyou&ckey=CK1297943913585'); } else if (isAndroid==true) { if (num != null && num != '') { jButton.attr('href','http://file.seeyouyima.com/android/download/'+ num +'.apk'); } else { jButton.attr('href','http://file.seeyouyima.com/android/download/350.apk?2014/11/26'); } } else if (!$.checkMobile()) { jButton.attr('href','http://www.xixiaoyou.com/'); } }; return new review(); }); })();