script.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. $(document).ready(function(){
  2. init_ui_button();
  3. init_ui_textbox();
  4. init_ui_select();
  5. init_ui_radiobox();
  6. init_ui_checkbox();
  7. init_ui_starbar();
  8. init_ui_lazy();
  9. // init_gotop();
  10. $(".option-qrcode").hover(
  11. function(){
  12. $(this).addClass("curr");
  13. },
  14. function(){
  15. $(this).removeClass("curr");
  16. }
  17. );
  18. });
  19. //以下是处理UI的公共函数
  20. function init_ui_lazy()
  21. {
  22. // $.refresh_image = function(){
  23. // $("img[lazy='true'][isload!='true']").ui_lazy({placeholder:LOADER_IMG});
  24. // };
  25. // $.refresh_image();
  26. // $(window).bind("scroll", function(e){
  27. // $.refresh_image();
  28. // });
  29. }
  30. //以下是处理UI的公共函数
  31. function init_ui_checkbox()
  32. {
  33. $("label.ui-checkbox[init!='init']").each(function(i,ImgCbo){
  34. $(ImgCbo).attr("init","init"); //为了防止重复初始化
  35. $(ImgCbo).ui_checkbox();
  36. });
  37. }
  38. function init_ui_starbar()
  39. {
  40. $("input.ui-starbar[init!='init']").each(function(i,ipt){
  41. $(ipt).attr("init","init"); //为了防止重复初始化
  42. $(ipt).ui_starbar();
  43. });
  44. }
  45. function init_ui_radiobox()
  46. {
  47. $("label.ui-radiobox[init!='init']").each(function(i,ImgCbo){
  48. $(ImgCbo).attr("init","init"); //为了防止重复初始化
  49. $(ImgCbo).ui_radiobox();
  50. });
  51. }
  52. var droped_select = null; //已经下拉的对象
  53. var uiselect_idx = 0;
  54. function init_ui_select()
  55. {
  56. $("select.ui-select[init!='init']").each(function(i,o){
  57. uiselect_idx++;
  58. var id = "uiselect_"+Math.round(Math.random()*10000000)+""+uiselect_idx;
  59. var op = {id:id};
  60. $(o).attr("init","init"); //为了防止重复初始化
  61. $(o).ui_select(op);
  62. });
  63. $(document.body).click(function(e) {
  64. if($(e.target).attr("class")!='ui-select-selected'&&$(e.target).parent().attr("class")!='ui-select-selected')
  65. {
  66. $(".ui-select-drop").fadeOut("fast");
  67. $(".ui-select").removeClass("dropdown");
  68. droped_select = null;
  69. }
  70. else
  71. {
  72. if(droped_select!=null&&droped_select.attr("id")!=$(e.target).parent().attr("id"))
  73. {
  74. $(droped_select).find(".ui-select-drop").fadeOut("fast");
  75. $(droped_select).removeClass("dropdown");
  76. }
  77. droped_select = $(e.target).parent();
  78. }
  79. });
  80. }
  81. function init_ui_button()
  82. {
  83. $("button.ui-button[init!='init']").each(function(i,o){
  84. $(o).attr("init","init"); //为了防止重复初始化
  85. $(o).ui_button();
  86. });
  87. }
  88. function init_ui_textbox()
  89. {
  90. $(".ui-textbox[init!='init'],.ui-textarea[init!='init']").each(function(i,o){
  91. $(o).attr("init","init"); //为了防止重复初始化
  92. $(o).ui_textbox();
  93. });
  94. }
  95. //ui初始化结束
  96. /*function init_gotop()
  97. {
  98. $("#go_top").css("top",$(document).scrollTop()+$(window).height()-80);
  99. $(window).scroll(function(){
  100. $("#go_top").css("top",$(document).scrollTop()+$(window).height()-80);
  101. if($(document).scrollTop()>0)
  102. $("#go_top").fadeIn();
  103. else
  104. $("#go_top").fadeOut();
  105. });
  106. $("#go_top").bind("click",function(){
  107. $("html,body").animate({scrollTop:0},"fast","swing",function(){
  108. });
  109. });
  110. }*/
  111. function init_sms_btn()
  112. {
  113. $(".login-panel").find("button.ph_verify_btn[init_sms!='init_sms']").each(function(i,o){
  114. $(o).attr("init_sms","init_sms");
  115. var lesstime = $(o).attr("lesstime");
  116. var divbtn = $(o).next();
  117. divbtn.attr("form_prefix",$(o).attr("form_prefix"));
  118. divbtn.attr("lesstime",lesstime);
  119. if(parseInt(lesstime)>0)
  120. init_sms_code_btn($(divbtn),lesstime);
  121. });
  122. }
  123. //关于短信验证码倒计时
  124. function init_sms_code_btn(btn,lesstime)
  125. {
  126. $(btn).stopTime();
  127. $(btn).removeClass($(btn).attr("rel"));
  128. $(btn).removeClass($(btn).attr("rel")+"_hover");
  129. $(btn).removeClass($(btn).attr("rel")+"_active");
  130. $(btn).attr("rel","disabled");
  131. $(btn).addClass("disabled");
  132. $(btn).find("span").html("重新获取("+lesstime+")");
  133. $(btn).attr("lesstime",lesstime);
  134. $(btn).everyTime(1000,function(){
  135. var lt = parseInt($(btn).attr("lesstime"));
  136. lt--;
  137. $(btn).find("span").html("重新获取("+lt+")");
  138. $(btn).attr("lesstime",lt);
  139. if(lt==0)
  140. {
  141. $(btn).stopTime();
  142. $(btn).removeClass($(btn).attr("rel"));
  143. $(btn).removeClass($(btn).attr("rel")+"_hover");
  144. $(btn).removeClass($(btn).attr("rel")+"_active");
  145. $(btn).attr("rel","light");
  146. $(btn).addClass("light");
  147. $(btn).find("span").html("发送验证码");
  148. }
  149. });
  150. }
  151. /*验证*/
  152. $.minLength = function(value, length , isByte) {
  153. var strLength = $.trim(value).length;
  154. if(isByte)
  155. strLength = $.getStringLength(value);
  156. return strLength >= length;
  157. };
  158. $.maxLength = function(value, length , isByte) {
  159. var strLength = $.trim(value).length;
  160. if(isByte)
  161. strLength = $.getStringLength(value);
  162. return strLength <= length;
  163. };
  164. $.getStringLength=function(str)
  165. {
  166. str = $.trim(str);
  167. if(str=="")
  168. return 0;
  169. var length=0;
  170. for(var i=0;i <str.length;i++)
  171. {
  172. if(str.charCodeAt(i)>255)
  173. length+=2;
  174. else
  175. length++;
  176. }
  177. return length;
  178. };
  179. $.checkMobilePhone = function(value){
  180. if($.trim(value)!='')
  181. return /^\d{6,}$/i.test($.trim(value));
  182. else
  183. return true;
  184. };
  185. $.checkEmail = function(val){
  186. var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  187. return reg.test(val);
  188. };
  189. /**
  190. * 检测密码的复杂度
  191. * @param pwd
  192. * 分数 1-2:弱 3-4:中 5-6:强
  193. * 返回 0:弱 1:中 2:强 -1:无
  194. */
  195. function checkPwdFormat(pwd)
  196. {
  197. var regex0 = /[a-z]+/;
  198. var regex1 = /[A-Z]+/;
  199. var regex2 = /[0-9]+/;
  200. var regex3 = /\W+/; //符号
  201. var regex4 = /\S{6,8}/;
  202. var regex5 = /\S{9,}/;
  203. var result = 0;
  204. if(regex0.test(pwd))result++;
  205. if(regex1.test(pwd))result++;
  206. if(regex2.test(pwd))result++;
  207. if(regex3.test(pwd))result++;
  208. if(regex4.test(pwd))result++;
  209. if(regex5.test(pwd))result++;
  210. if(result>=1&&result<=2)
  211. result=0;
  212. else if(result>=3&&result<=4)
  213. result=1;
  214. else if(result>=5&&result<=6)
  215. result=2;
  216. else
  217. result=-1;
  218. return result;
  219. }
  220. /**
  221. * 顶部错误提示
  222. */
  223. $(function(){
  224. $(".msg_tip .close").bind("click",function(){
  225. $(".msg_tip").slideUp("slow");
  226. $(".msg_tip .msg_content").html("");
  227. });
  228. $.Close_top_tip = function(){
  229. $(".msg_tip").slideUp("slow");
  230. $(".msg_tip .msg_content").html("");
  231. };
  232. $.Show_top_tip = function(type,msg){
  233. position_scroll();
  234. if(type == 'error'){
  235. $(".msg_tip").addClass("sysmsg_error");
  236. $(".msg_tip .status").addClass("s_error");
  237. }else if(type == 'sucess'){
  238. $(".msg_tip").addClass("sysmsg_success");
  239. $(".msg_tip .status").addClass("s_success");
  240. }
  241. $(".msg_tip .msg_content").html(msg);
  242. $(".msg_tip").fadeIn();
  243. return false;
  244. };
  245. $.Show_error_tip = function(msg){
  246. $.Show_top_tip('error',msg);
  247. };
  248. $.Show_success_tip = function(msg){
  249. $.Show_top_tip('sucess',msg);
  250. };
  251. /**
  252. * 显示错误列
  253. */
  254. $.Show_field_error = function(obj) {
  255. $.Show_field_tip_status(obj, 'error');
  256. };
  257. $.Show_field_success = function(obj) {
  258. $.Show_field_tip_status(obj, 'success');
  259. };
  260. $.Show_field_tip_status=function(obj, type) {
  261. var show_item = $(obj).parent().find(".status_icon");
  262. if(type == "error"){
  263. $(show_item).children("i").removeClass("s_success");
  264. $(show_item).children("i").addClass("s_error");
  265. }else{
  266. $(show_item).children("i").removeClass("s_error");
  267. $(show_item).children("i").addClass("s_success");
  268. }
  269. $(show_item).show();
  270. }
  271. });
  272. //定位滚动
  273. function position_scroll(){
  274. var window_scroll = $(window).scrollTop();
  275. if(window_scroll>100){
  276. var scroll_height = window_scroll-75;
  277. $(".msg_tip_box").css("top",scroll_height+"px");
  278. }else{
  279. $(".msg_tip_box").css("top",0);
  280. }
  281. $('.msg_tip_box').stopTime();
  282. $('.msg_tip_box').oneTime(3000,function(){
  283. $(".msg_tip_box").css("top",0);
  284. });
  285. }
  286. function load_ofc(id,dataurl,w,h)
  287. {
  288. swfobject.embedSWF(
  289. OFC_SWF, id,
  290. w, h, "9.0.0", "expressInstall.swf",
  291. {"data-file":dataurl} );
  292. }
  293. function jump_to(url)
  294. {
  295. location.href = url;
  296. }