/** * 返回上一页 */ function returnGo(){ history.go(-1); } /** * 返回id */ function id(name){ return document.getElementById(name); } /** * 自制resize函数,解决性能损耗问题 */ function throttle(fn,interval){ var __self = fn, //保存需要被延迟执行的函数引用 timer, //定时器 firstTime = true; //是否是第一次调用 return function(){ var args = arguments, _me = this; //如果是第一次调用,不需要延迟执行 if(firstTime){ __self.apply(_me,args); return firstTime = false; } //如果定时器还在,说明前一次延迟执行还没完成 if(timer){ return false; } //延迟一段时间执行 timer = setTimeout(function(){ clearTimeout(timer); timer = null; __self.apply(_me,args); },interval || 500); } } /** * 弹出框 */ function dialog(content){ var $dialog1=$('#dialog1'); var animate='tinUpIn'; $dialog1.show(); $dialog1.find('.weui_dialog').addClass(animate); $dialog1.find('.weui_dialog_bd').text(content); hideDialog(animate); } /** * 确定隐藏弹出框 */ function hideDialog(animate){ var $dialog1=$('#dialog1'); $dialog1.on('tap','.weui_dialog_ft',function(event){ event.preventDefault(); $dialog1.hide(); $dialog1.find('.weui_dialog').removeClass(animate); }); } /** * load加载 */ function load(content,time,href){ var $weui_loading_toast=$('.weui_loading_toast'); $weui_loading_toast.show(); $weui_loading_toast.find('.weui_toast_content').text(content); setTimeout(function(){ $weui_loading_toast.hide(); if(href){ location.href=href; } },time); } /** * 获取验证码 */ function getCode(iphone,code,s){ if(checkMobilePhone(iphone)){ code.off('tap'); var ss=s; var setVal=""; setVal=setInterval(function(){ s--; if(s < 0){ clearInterval(setVal); code.text('重新获取').on('tap',function(event){ event.preventDefault(); getCode(iphone,$(this),ss); }); return false; } code.text(s+'s'); },1000); }else{ dialog('请输入正确的手机号!'); } } /** * 信息 */ function vaePormpt(content){ var $p=$('.info'); $p.text(content); $p.css({ 'display':'block', 'opacity':'1' }); setTimeout(function(){ $p.css({ 'display':'none', 'opacity':'0' }); },2000); } /** * 获取验证码 */ function getCode(iphone,code,s){ if(checkMobilePhone(iphone)){ code.off('tap'); var ss=s; var setVal=""; setVal=setInterval(function(){ s--; if(s < 0){ clearInterval(setVal); code.text('重新获取').on('tap',function(){ getCode(iphone,$(this),ss); return false; }); return false; } code.text(s+'s'); },1000); }else{ vaePormpt('请输入正确的手机号'); } }