common.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. function GetQueryString(name){
  2. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  3. var r = window.location.search.substr(1).match(reg);
  4. if (r!=null) return unescape(r[2]); return null;
  5. }
  6. function addcookie(name,value,expireHours){
  7. var cookieString=name+"="+escape(value)+"; path=/";
  8. //判断是否设置过期时间
  9. if(expireHours>0){
  10. var date=new Date();
  11. date.setTime(date.getTime+expireHours*3600*1000);
  12. cookieString=cookieString+"; expire="+date.toGMTString();
  13. }
  14. document.cookie=cookieString;
  15. }
  16. function getcookie(name){
  17. var strcookie=document.cookie;
  18. var arrcookie=strcookie.split("; ");
  19. for(var i=0;i<arrcookie.length;i++){
  20. var arr=arrcookie[i].split("=");
  21. if(arr[0]==name)return arr[1];
  22. }
  23. return "";
  24. }
  25. function delCookie(name){//删除cookie
  26. var exp = new Date();
  27. exp.setTime(exp.getTime() - 1);
  28. var cval=getcookie(name);
  29. if(cval!=null) document.cookie= name + "="+cval+"; path=/;expires="+exp.toGMTString();
  30. }
  31. function checklogin(state){
  32. if(state == 0){
  33. location.href = WapSiteUrl+'/tmpl/member/login.html';
  34. return false;
  35. }else {
  36. return true;
  37. }
  38. }
  39. function contains(arr, str) {
  40. var i = arr.length;
  41. while (i--) {
  42. if (arr[i] === str) {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. function buildUrl(type, data) {
  49. switch (type) {
  50. case 'keyword':
  51. return WapSiteUrl + '/tmpl/product_list.html?keyword=' + encodeURIComponent(data);
  52. case 'special':
  53. return WapSiteUrl + '/special.html?special_id=' + data;
  54. case 'goods':
  55. return WapSiteUrl + '/tmpl/product_detail.html?goods_id=' + data;
  56. case 'url':
  57. return data;
  58. }
  59. return WapSiteUrl;
  60. }
  61. //bottom nav 33 hao-v3 by 33h ao.com Qq 1244 986 40
  62. $(function(){
  63. setTimeout(function(){
  64. if($("#content .container").height()<$(window).height())
  65. {
  66. $("#content .container").css("min-height",$(window).height());
  67. }
  68. },300);
  69. $("#bottom .nav .get_down").click(function(){
  70. $("#bottom .nav").animate({"bottom":"-50px"});
  71. $("#nav-tab").animate({"bottom":"0px"});
  72. });
  73. $("#nav-tab-btn").click(function(){
  74. $("#bottom .nav").animate({"bottom":"0px"});
  75. $("#nav-tab").animate({"bottom":"-40px"});
  76. });
  77. setTimeout(function(){$("#bottom .nav .get_down").click();},500);
  78. $("#scrollUp").click(function(t) {
  79. $("html, body").scrollTop(300);
  80. $("html, body").animate( {
  81. scrollTop : 0
  82. }, 300);
  83. t.preventDefault()
  84. });
  85. });