main.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. 
  2. $(function () {
  3. // IOS 微信浏览器开启点击事件
  4. $("body>*").bind("click",function(){});
  5. //修复移动端 date 不支持placeholder
  6. $('#scan-integral input[type="date"]').focus(function () {
  7. $(this).addClass('full')
  8. });
  9. /*--------------------签到弹出框初始化-------------------------------------*/
  10. $('.popup-modal').magnificPopup({
  11. type:'inline',
  12. midClick: true
  13. });
  14. })
  15. /*-------------------校验表单提示错误框------------------------------------*/
  16. function messageModal(message) {
  17. setTimeout(() => {
  18. $.magnificPopup.open({
  19. items: {
  20. src: '<div id="popup" class="white-popup"><h1></h1><div class="message--wrap"><p>' + message + '</p></div><div class="confirm-button btn">确认</div> </div>', // can be a HTML string, jQuery object, or CSS selector
  21. type: 'inline'
  22. }
  23. });
  24. }, 20);
  25. $(document).on('click', '#popup .confirm-button', function () {
  26. $.magnificPopup.close();
  27. })
  28. }
  29. function messageCheckModal(message,icon,callback,button) {
  30. var title="";
  31. if(icon=="check-success") title="有缘分"
  32. else if(icon=="check-fail") title="很遗憾"
  33. // if(icon=="check-un") title="无法识别"
  34. var nocoverUrl="";
  35. if(icon=="check-fail") nocoverUrl="<a style='color: #CBCBCB;font-size: 24px;text-decoration-line: underline;' href='nocover.html'>点击进入定制专区</a>"
  36. setTimeout(() => {
  37. $.magnificPopup.open({
  38. items: {
  39. src: '<div id="popup" class="white-popup"><h2 class="'+icon+'"></h2><h3>'+title+'</h3>'
  40. +'<div class="message--wrap"><p>' + message + '</p></div>'
  41. +'<div class="confirm-button btn">'+button+'</div><div style="text-align:center;margin-top:5px">'+nocoverUrl+'</div></div>', // can be a HTML string, jQuery object, or CSS selector
  42. type: 'inline'
  43. }
  44. });
  45. }, 20);
  46. $(document).on('click', '#popup .confirm-button', function () {
  47. $.magnificPopup.close();
  48. if(callback!=null) callback();
  49. })
  50. }
  51. function messageCheckFailModal(message,callback,address) {
  52. var nocoverUrl ="<img src='../auto/img/icon/edit.png'/><a style='color: #CBCBCB;font-size: 24px;text-decoration-line: underline;' href='nocover.html?address="+address+"'>点击进入定制专区</a>"
  53. setTimeout(() => {
  54. $.magnificPopup.open({
  55. items: {
  56. src: '<div id="popup" class="white-popup"><h2 class="check-fail"></h2><h3>很遗憾</h3>'
  57. +'<div class="message--wrap"><p>' + message + '</p></div>'
  58. +'<div class="confirm-button btn">更换地址</div><div style="text-align:center;margin-top:5px">'+nocoverUrl+'</div></div>', // can be a HTML string, jQuery object, or CSS selector
  59. type: 'inline'
  60. }
  61. });
  62. }, 20);
  63. $(document).on('click', '#popup .confirm-button', function () {
  64. $.magnificPopup.close();
  65. if(callback!=null) callback();
  66. })
  67. }
  68. function messageNoCoverModal(message,callback) {
  69. setTimeout(() => {
  70. $.magnificPopup.open({
  71. items: {
  72. src: '<div id="popup" class="white-popup"><h2 class="nocover"></h2><h3>提交成功</h3><div class="message--wrap" style="text-align: center"><p>' + message + '</p>'+
  73. '<img src="../auto/img/icon/qr.png" style="width:160px"/>'+'</div><div class="confirm-button btn">确定</div> </div>', // can be a HTML string, jQuery object, or CSS selector
  74. type: 'inline'
  75. }
  76. });
  77. }, 20);
  78. $(document).on('click', '#popup .confirm-button', function () {
  79. $.magnificPopup.close();
  80. if(callback!=null) callback();
  81. })
  82. }
  83. function confirmCancel(message, callbackOK,callbackCancel) {
  84. setTimeout(() => {
  85. $.magnificPopup.open({
  86. items: {
  87. src: '<div id="popup" class="white-popup"><h1></h1><div class="message--wrap"><p>' + message + '</p></div><div class="confirm-button-box"><div class="confirm-button btn btnOK">下一步</div> <div class="confirm-button btn btnCancel">暂不购买</div></div></div>', // can be a HTML string, jQuery object, or CSS selector
  88. type: 'inline'
  89. }
  90. });
  91. }, 20);
  92. $(document).on('click', '#popup .btnOK', function () {
  93. $.magnificPopup.close(); callbackOK();
  94. $(document).off('click', '#popup .confirm-button')
  95. });
  96. $(document).on('click', '#popup .btnCancel', function () {
  97. $.magnificPopup.close();
  98. callbackCancel();
  99. $(document).off('click', '#popup .confirm-button')
  100. })
  101. }
  102. /*----------------------获取今天日期-----------------------------------------*/
  103. function getCurrenTime() {
  104. var date = new Date();
  105. var getMonth=date.getMonth()+1
  106. if(date.getMonth()<10){
  107. getMonth='0'+getMonth
  108. }
  109. var dateString = date.getFullYear()+"-"+getMonth+"-"+date.getDate();
  110. return dateString
  111. }
  112. /*--------------------发送短信验证码--------------------------------*/
  113. var countdown=60;
  114. function sendEmail(obj) {
  115. setTime(obj)
  116. }
  117. function setTime(obj) { //发送验证码倒计时
  118. if (countdown == 0) {
  119. obj.attr('disabled',false);
  120. obj.removeClass('gray');
  121. obj.val("点击获取");
  122. countdown = 60;
  123. return;
  124. } else {
  125. obj.attr('disabled',true);
  126. obj.addClass('gray')
  127. obj.val("重新发送(" + countdown + ")");
  128. countdown--;
  129. }
  130. setTimeout(function(){setTime(obj)},1000);
  131. }