main.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var domanUrl = "//" + window.location.host;
  2. var base_path = "//test.iamberry.com/rst/wechat";
  3. window.addEventListener('pageshow', function(e) {
  4. // 通过persisted属性判断是否存在 BF Cache
  5. if(e.persisted) {
  6. location.reload();
  7. }
  8. });
  9. //ajax loading
  10. $(window).ajaxStart(function(){
  11. $(".covers").show();
  12. });
  13. $(window).ajaxStop(function(){
  14. $(".covers").hide();
  15. });
  16. function formatDateFull(now) {
  17. now = new Date(now);
  18. var year=now.getFullYear();
  19. var month=now.getMonth()+1;
  20. if(month<10){
  21. month="0"+month;
  22. }
  23. var date=now.getDate();
  24. if(date<10){
  25. date="0"+date;
  26. }
  27. return year+"-"+month+"-"+date;
  28. }
  29. function formatDateMinute(now) {
  30. now = new Date(now);
  31. var year=now.getFullYear();
  32. var month=now.getMonth()+1;
  33. if(month<10){
  34. month="0"+month;
  35. }
  36. var date=now.getDate();
  37. if(date<10){
  38. date="0"+date;
  39. }
  40. var hour=now.getHours();
  41. if(hour<10){
  42. hour="0"+hour;
  43. }
  44. var Minute=now.getMinutes();
  45. if(Minute<10){
  46. Minute="0"+Minute;
  47. }
  48. return year+"-"+month+"-"+date+" "+hour+":"+Minute;
  49. }
  50. function time_before(t){
  51. var minute=1000*60;
  52. var hour=minute*60;
  53. var day=hour*24;
  54. var halfamonth=day*15;
  55. var month=day*30;
  56. var now=new Date().getTime();
  57. var diffValue=now-new Date().setTime(t);
  58. var monthC=diffValue/month;
  59. var weekC=diffValue/(7*day);
  60. var dayC=diffValue/day;
  61. var hourC=diffValue/hour;
  62. var minC=diffValue/minute;
  63. if(dayC>=1){
  64. result="距离今日还有"+parseInt(dayC)+"天";
  65. }else if(hourC>=1){
  66. result="距离交付还有"+parseInt(hourC)+"小时";
  67. }else if(minC>=2){
  68. result="距离交付还有"+parseInt(minC)+"分钟";
  69. }else{
  70. result="已超过交付时间";
  71. }
  72. return result;
  73. };
  74. //封装document.getElementById
  75. function dc(objectid) {
  76. if(document.getElementById && document.getElementById(objectid)) {
  77. return document.getElementById(objectid);// w3c dom
  78. } else if (document.all && document.all(objectid)) {
  79. return document.all(objectid);// msie 4 dom
  80. } else if (document.layers && document.layers[objectid]) {
  81. return document.layers[objectid];// nn 4 dom.. note: this won't find nested layers
  82. } else {
  83. return false;
  84. }
  85. }
  86. function getParam(paramName) {
  87. paramValue = "", isFound = !1;
  88. if(this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
  89. arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
  90. while(i < arrSource.length && !isFound) {
  91. arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
  92. }
  93. }
  94. return paramValue == "" && (paramValue = null), paramValue
  95. };