free_collection.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>免费送滤芯</title>
  6. <meta http-equiv="pragma" content="no-cache">
  7. <meta http-equiv="cache-control" content="no-cache">
  8. <meta http-equiv="expires" content="0">
  9. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  12. <meta name="format-detection" content="telphone=no, email=no" />
  13. <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
  14. <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
  15. <link rel="stylesheet" type="text/css" href="css/style.css" />
  16. <style>
  17. .register-group{margin: 0 auto;width: 300px;}
  18. .register-group:before,.register-group:after,.register-group .mui-input-row:before,.register-group .mui-input-row:after{display: none}
  19. .register-group .mui-input-row label{padding: 11px 5px;width: 20%;}
  20. .register-group .mui-input-row label~input{width: 80%;border-bottom:1px solid #ccc;font-size: 16px;}
  21. .register-group .mui-input-row label~input::-webkit-input-placeholder{font-size: 15px;color: #ccc;}
  22. .pull-code {border: 0;color: #666;padding:8px 0;position: absolute;right:0;}
  23. .pull-code.active{color: #6dd4e5;}
  24. .pull-code:active{background-color: #fff !important;color: #666 !important;}
  25. .my-btn-confirm{background-color: #fff;border:1px solid #59c0d9;border-radius: 0;width: 200px;margin: 0 auto;color: #666;padding: 7px 0;color: #59c0d9;}
  26. .my-btn-confirm:active{background-color: #59c0d9 !important;border:1px solid #59c0d9;color: #fff;}
  27. .my-btn-confirm.active{background-color: #59c0d9 !important;border:1px solid #59c0d9;color: #fff;}
  28. </style>
  29. </head>
  30. <body style="background: #fff;">
  31. <!--内容开始-->
  32. <div class="mui-content" style="background: #fff;">
  33. <div>
  34. <img width="100%" src="images/banner-11.jpg" />
  35. </div>
  36. <div class="mui-text-center" style="color:#59c0d9;font-size: 16px;padding: 15px 0;">
  37. 验证手机信息
  38. </div>
  39. <form class="mui-input-group register-group">
  40. <div class="mui-input-row">
  41. <label>手机号</label>
  42. <input type="tel" placeholder="输入您购买时的手机号(11位)" id="ipt-phone" maxlength="11">
  43. </div>
  44. <div class="mui-input-row">
  45. <label>验证码</label>
  46. <input type="tel" placeholder="输入验证码" maxlength="4" id="code"><button type="button" class="pull-code" id="pull-code">获取验证码</button>
  47. </div>
  48. </form>
  49. <br />
  50. <div class="mui-content-padded">
  51. <button type="button" data-loading-icon="mui-spinner mui-spinner-custom" data-loading-text="提交中" class="mui-btn mui-btn-block my-btn-confirm" id="btn-confirm" disabled="disabled">领取滤芯</button>
  52. </div>
  53. <div class="mui-content-padded">
  54. <div style="border-top: 1px solid rgba(0,0,0,.1);margin: 20px 0;"></div>
  55. <ul>
  56. <li style="color:#59c0d9;padding-bottom: 10px;">活动说明:</li>
  57. <li class="mui-h6">1,此福利仅针对购买过WaterO产品的老顾客</li>
  58. <li class="mui-h6">2,如您现在使用的手机号码与购买下单的手机号码不同,请联系官方客服</li>
  59. <li class="mui-h6">3,每个手机号码仅限领取一次</li>
  60. <li class="mui-h6">4,领取成功之后,即可在会员中心查看您的兑换券及优惠权益。</li>
  61. <li style="color:#59c0d9;padding:10px 0;">尊享福利:</li>
  62. <li class="mui-h6">1.免费赠送WaterO T1/T2滤芯</li>
  63. <li class="mui-h6">2.尊享滤芯套装立减100元/套优惠</li>
  64. <li class="mui-h6">3.尊享WaterO品牌一对一售后服务</li>
  65. </ul>
  66. </div>
  67. </div>
  68. <!--内容结束-->
  69. <script src="js/mui.min.js"></script>
  70. <script src="js/jquery-2.1.1.min.js"></script>
  71. <script src="js/main.js"></script>
  72. <script src="js/page/wechat-utils-1.0.js"></script>
  73. <script>
  74. var countdown = 60;
  75. var check = false,
  76. alert_msg = '';
  77. var reg_Ch_En_Num = /^[A-Za-z0-9_ \-\u4e00-\u9fa5]{1,15}$/; //简体中文英文数字,横线下划线空格(1-15位)
  78. var mobile = /^(13|14|15|16|17|18|19)[0-9]{9}$/; //手机号码
  79. var code = /^[0-9]{4}$/; //数字
  80. var validate_flag = false,
  81. show_msg = '',phone='';
  82. //ready事件
  83. mui.ready(function() {
  84. if(!window.localStorage) {
  85. mui.alert("浏览器不支持localStorage");
  86. } else {
  87. var codedata = JSON.parse(localStorage.getItem('pull-code-data'));
  88. if(codedata != null) {
  89. var dates = new Date();
  90. $("#ipt-phone").val(codedata.phone);
  91. if(codedata.codeTime > 0) {
  92. if(((dates.getTime() / 1000) - codedata.updateTime) < codedata.codeTime) {
  93. countdown = (codedata.codeTime - (parseInt(dates.getTime() / 1000) - codedata.updateTime)) + 1;
  94. settime("pull-code");
  95. } else {
  96. $(".pull-code").removeAttr("disabled");
  97. }
  98. $('#btn-confirm').removeAttr("disabled").addClass("active");
  99. } else {
  100. $(".pull-code").removeAttr("disabled").addClass("active");
  101. }
  102. }
  103. }
  104. });
  105. //实时监听文本框字数
  106. document.getElementById("ipt-phone").addEventListener("input", function() {
  107. var phone = this.value;
  108. if(phone.length == 11) {
  109. if(mobile.test(phone) && countdown == 60) {
  110. $(".pull-code").removeAttr("disabled").addClass("active");
  111. } else {
  112. $(".pull-code,#btn-confirm").attr("disabled", "disabled").removeClass("active");
  113. }
  114. } else {
  115. $(".pull-code,#btn-confirm").attr("disabled", "disabled").removeClass("active");
  116. }
  117. });
  118. //发送验证码
  119. $(document).on('tap', '.pull-code', function() {
  120. if($("#ipt-phone").val().trim() == "" && (!$(".pull-code").hasClass("active"))) {
  121. mui.alert("请填写手机号码", function() {
  122. $("#ipt-phone").select();
  123. });
  124. return;
  125. } else {
  126. if(!mobile.test($("#ipt-phone").val().trim())) {
  127. mui.alert("手机号码不正确,请重新填写", function() {
  128. $("#ipt-phone").select();
  129. });
  130. return;
  131. } else {
  132. if($(this).hasClass("active")) {
  133. phone=$("#ipt-phone").val().trim();
  134. $.ajax(base_path + '/tanksgiv/send_veri?dates=' + new Date().getTime(), {
  135. data: {
  136. "phone": $("#ipt-phone").val().trim()
  137. },
  138. dataType: 'json',
  139. xhrFields: {
  140. withCredentials: true
  141. },
  142. crossDomain: true,
  143. type: 'get',
  144. timeout: 15000,
  145. success: function(dt) {
  146. if(dt.isRedirect) {
  147. location.href = dt.redirectURL;
  148. } else {
  149. if(dt.status) {
  150. settime("pull-code");
  151. $("#code").select();
  152. if(!window.localStorage) {
  153. alert("浏览器不支持localStorage");
  154. } else {
  155. var dates = new Date();
  156. //自定义json数据
  157. var obj = {
  158. "phone": $("#ipt-phone").val().trim(),
  159. "codeTime": countdown,
  160. "updateTime": parseInt(dates.getTime() / 1000)
  161. };
  162. //json格式化插入
  163. localStorage.setItem('pull-code-data', JSON.stringify(obj));
  164. }
  165. $('#btn-confirm').removeAttr("disabled").addClass("active");
  166. } else {
  167. mui.alert(dt.message);
  168. }
  169. }
  170. },
  171. error: function(xhr, type, errorThrown) {
  172. console.log(xhr);
  173. mui.alert("发送短信失败!网络错误");
  174. }
  175. });
  176. }
  177. }
  178. }
  179. });
  180. function settime(val) {
  181. pullid = dc(val);
  182. if(countdown == 0) {
  183. pullid.removeAttribute("disabled");
  184. pullid.className = 'pull-code active';
  185. pullid.innerText = "获取验证码";
  186. countdown = 60;
  187. return false;
  188. } else {
  189. countdown--;
  190. pullid.setAttribute("disabled", "disabled");
  191. pullid.className = 'pull-code';
  192. pullid.innerText = "重新发送(" + countdown + ")";
  193. }
  194. setTimeout(function() {
  195. settime(val)
  196. }, 1000);
  197. if(!window.localStorage) {
  198. alert("浏览器不支持localStorage");
  199. } else {
  200. //检查值是否存在
  201. if(localStorage.getItem("pull-code-data") != null) {
  202. var dates = new Date();
  203. var codedata = JSON.parse(localStorage.getItem('pull-code-data'));
  204. var edit = JSON.stringify({
  205. "phone": codedata.phone,
  206. "codeTime": countdown,
  207. "updateTime": parseInt(dates.getTime() / 1000)
  208. });
  209. //改,即重新给变量赋值
  210. localStorage.setItem("pull-code-data", edit);
  211. }
  212. }
  213. }
  214. //提交
  215. mui('body').on('tap', '#btn-confirm', function() {
  216. var val = $("#code").val().trim(),
  217. th = this;
  218. if(code.test(val)) {
  219. mui(th).button('loading');
  220. $.ajax(base_path + '/tanksgiv/receive_coupon?dates=' + new Date().getTime(), {
  221. data: {
  222. "phone": phone,
  223. "code": val
  224. },
  225. dataType: 'json',
  226. xhrFields: {
  227. withCredentials: true
  228. },
  229. crossDomain: true,
  230. type: 'post',
  231. timeout: 15000,
  232. success: function(dt) {
  233. if(dt.isRedirect) {
  234. location.href = dt.redirectURL;
  235. } else {
  236. if(dt.status) {
  237. mui.alert(dt.message,function(){
  238. location.href = "/watero/view/coupon_.html";
  239. });
  240. } else {
  241. mui.alert(dt.message, function() {
  242. mui(th).button('reset');
  243. });
  244. }
  245. }
  246. },
  247. error: function(xhr, type, errorThrown) {
  248. console.log(xhr);
  249. mui.alert("领取失败!网络出小差了", function() {
  250. mui(th).button('reset');
  251. });
  252. }
  253. });
  254. } else {
  255. if(val != "") {
  256. mui.alert("验证码错误!", function() {
  257. $("#code").select();
  258. });
  259. } else {
  260. mui.alert("请填写验证码!", function() {
  261. $("#code").select();
  262. });
  263. }
  264. }
  265. });
  266. </script>
  267. </body>
  268. </html>