bindPhone.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  8. />
  9. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  10. <title>绑定手机</title>
  11. <style>
  12. html,
  13. body,
  14. p {
  15. padding: 0;
  16. margin: 0;
  17. }
  18. html {
  19. background: #f7f7f7;
  20. }
  21. img {
  22. width: 100%;
  23. }
  24. i {
  25. font-style: normal;
  26. }
  27. .page-banner {
  28. position: absolute;
  29. top: 0;
  30. left: 0;
  31. width: 100%;
  32. z-index: 9;
  33. }
  34. .bind-phone__wrap {
  35. position: relative;
  36. z-index: 99;
  37. border-radius: 6px;
  38. background: #fff;
  39. padding: 20px;
  40. margin: 125px 13px 0;
  41. text-align: center;
  42. font-size: 0;
  43. }
  44. .bind-phone__wrap .wrap-banner {
  45. width: 90%;
  46. }
  47. .bind-form {
  48. margin-top: 35px;
  49. }
  50. .bind-form .form-item {
  51. display: -webkit-box;
  52. display: -ms-flexbox;
  53. display: flex;
  54. -webkit-box-pack: start;
  55. -ms-flex-pack: start;
  56. justify-content: flex-start;
  57. -webkit-box-align: center;
  58. -ms-flex-align: center;
  59. align-items: center;
  60. margin: 0 12px;
  61. border-bottom: 1px solid #f7f7f7;
  62. }
  63. .bind-form .form-item input {
  64. -webkit-box-flex: 1;
  65. -ms-flex: 1;
  66. flex: 1;
  67. padding: 10px 0;
  68. font-size: 14px;
  69. color: #333;
  70. outline: none;
  71. border: none;
  72. }
  73. .bind-form .form-item input::-webkit-input-placeholder {
  74. color: #999;
  75. font-size: 14px;
  76. }
  77. .bind-form .form-item .get-code {
  78. font-size: 13px;
  79. color: #ff7130;
  80. }
  81. .bind-form .form-item:not(:last-child) {
  82. margin-bottom: 17px;
  83. }
  84. .bind-form .submit-wrap {
  85. margin-top: 69px;
  86. margin-bottom: 18px;
  87. display: -webkit-box;
  88. display: -ms-flexbox;
  89. display: flex;
  90. -webkit-box-pack: justify;
  91. -ms-flex-pack: justify;
  92. justify-content: space-between;
  93. -webkit-box-align: center;
  94. -ms-flex-align: center;
  95. align-items: center;
  96. }
  97. .bind-form .submit-wrap button {
  98. -webkit-box-flex: 1;
  99. -ms-flex: 1;
  100. flex: 1;
  101. outline: none;
  102. border-radius: 6px;
  103. font-size: 15px;
  104. color: #fff;
  105. text-align: center;
  106. border: 1px solid transparent;
  107. line-height: 45px;
  108. background: #ff7130;
  109. display: inline-block;
  110. }
  111. .bind-form .submit-wrap button.to-refuse {
  112. color: #b3b3b3;
  113. background: #ecf2f7;
  114. }
  115. .bind-form .submit-wrap button.to-refuse__enable {
  116. border-color: #ff7130;
  117. color: #ff7130;
  118. background: #fff;
  119. }
  120. .bind-form .submit-wrap button:not(:last-child) {
  121. margin-right: 11px;
  122. }
  123. .dialog-wrap {
  124. position: fixed;
  125. top: 0;
  126. bottom: 0;
  127. left: 0;
  128. right: 0;
  129. background: rgba(0, 0, 0, 0.2);
  130. z-index: 999;
  131. }
  132. .dialog-wrap .dialog-content {
  133. position: absolute;
  134. width: 90%;
  135. top: 50%;
  136. left: 50%;
  137. -webkit-transform: translate(-50%, -50%);
  138. transform: translate(-50%, -50%);
  139. background: #fff;
  140. border-radius: 2px;
  141. font-size: 0;
  142. text-align: center;
  143. }
  144. .dialog-wrap .dialog-content .dialog-img {
  145. position: relative;
  146. width: 80px;
  147. top: 50%;
  148. -webkit-transform: translate(0%, -50%);
  149. transform: translate(0%, -50%);
  150. }
  151. .dialog-wrap .dialog-content .content-info {
  152. text-align: center;
  153. font-size: 16px;
  154. color: #666;
  155. line-height: 1;
  156. margin-bottom: 40px;
  157. }
  158. .dialog-wrap .dialog-content .content-info .bind-title {
  159. font-size: 30px;
  160. font-weight: bold;
  161. margin-bottom: 15px;
  162. }
  163. .dialog-wrap .dialog-content .content-info i {
  164. color: #ff7130;
  165. font-weight: bold;
  166. font-size: 20px;
  167. }
  168. .dialog-wrap .dialog-content .close {
  169. outline: none;
  170. border: none;
  171. width: 175px;
  172. line-height: 40px;
  173. font-size: 15px;
  174. color: #fff;
  175. background: #ff7130;
  176. border-radius: 6px;
  177. margin: 0 auto 26px;
  178. text-align: center;
  179. }
  180. </style>
  181. </head>
  182. <body>
  183. <main>
  184. <img src="https://cdn-novel.iycdm.com/h5/bind-phone/doing.jpg" alt="" class="page-banner" />
  185. <div class="bind-phone__wrap">
  186. <img src="https://cdn-novel.iycdm.com/h5/bind-phone/title.jpg" alt="" class="wrap-banner" />
  187. <div class="bind-form">
  188. <form action="">
  189. <div class="form-item">
  190. <input
  191. type="phone"
  192. name="phone"
  193. id="phone"
  194. placeholder="请输入手机号"
  195. />
  196. </div>
  197. <div class="form-item">
  198. <input
  199. type="text"
  200. name="code"
  201. id="code"
  202. placeholder="请输入手机验证码"
  203. />
  204. <span class="get-code">获取验证码</span>
  205. </div>
  206. </form>
  207. <div class="submit-wrap">
  208. <button class="to-bind" id="bind">立即绑定</button>
  209. <!-- 可以点击的时候 多加一个class->to-refuse__enable -->
  210. @if($from == 'pay')
  211. <button class="to-refuse" id="refuse" disabled>残忍拒绝</button>
  212. @endif
  213. </div>
  214. </div>
  215. </div>
  216. </main>
  217. <div class="dialog-wrap" style="display: none">
  218. <div class="dialog-content">
  219. <img src="https://cdn-novel.iycdm.com/h5/bind-phone/success.png" alt="" class="dialog-img" />
  220. <div class="content-info">
  221. <p class="bind-title">绑定成功</p>
  222. <p class="bind-text">手机号绑定成功,赠送您<i>100</i>书币</p>
  223. </div>
  224. <button class="close" id="close">知道了</button>
  225. </div>
  226. </div>
  227. </body>
  228. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
  229. <script>
  230. var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57]|19[0-9])[0-9]{8}$/;
  231. var refuseNumber = 10;
  232. var getPhoneCodeNumber = 60;
  233. var order = "{{ $order }}"
  234. // 倒计时
  235. function countDown(time, cb) {
  236. var timer = null
  237. timer = setInterval(function() {
  238. if(order){
  239. $.ajax({
  240. url:"/api/order/issuccess",
  241. data:{
  242. order:"{{ $order }}"
  243. },
  244. success:function(res){
  245. if(res['code'] == 0){
  246. time = 1;
  247. }
  248. }
  249. });
  250. }
  251. if (time === 1) clearInterval(timer);
  252. time--;
  253. if (cb) cb(time);
  254. }, 1000);
  255. }
  256. // 残忍拒绝事件
  257. $("#refuse").on("click", function() {
  258. if(!$(this).attr('disabled')){
  259. location.href = "{!! $url !!}";
  260. }
  261. });
  262. // 残忍拒绝倒计时
  263. countDown(refuseNumber, function(time) {
  264. if (time === 0) {
  265. $("#refuse").text("残忍拒绝");
  266. $("#refuse").attr("disabled", false);
  267. $("#refuse").addClass("to-refuse__enable");
  268. } else $("#refuse").text("残忍拒绝(" + time + "s)");
  269. });
  270. // 获取验证码
  271. var code_getting = false;
  272. $(".get-code").on("click", function() {
  273. var phone = $("#phone").val();
  274. if (!phone) {
  275. alert("请输入手机号!");
  276. return;
  277. } else if (!reg.test(phone)) {
  278. alert("手机号不合法!");
  279. return;
  280. }
  281. $.ajax({
  282. url:'/api/bindphone/sendcode',
  283. type:'post',
  284. data:{phone:phone},
  285. success:function () {
  286. }
  287. });
  288. if (!code_getting) {
  289. code_getting = true;
  290. countDown(getPhoneCodeNumber, function(time) {
  291. if (time === 0) {
  292. $(".get-code").text("获取验证码");
  293. code_getting = false;
  294. } else $(".get-code").text(time + "s");
  295. });
  296. }
  297. });
  298. // 立即绑定事件
  299. $("#bind").on("click", function() {
  300. var phone = $("#phone").val();
  301. var code = $("#code").val();
  302. if (!phone || !code) alert("手机号或验证码不能为空");
  303. else {
  304. // 绑定逻辑
  305. $.ajax({
  306. url:'/api/bindphone/bind',
  307. type:'post',
  308. data:{phone:phone,code:code},
  309. success:function ($res) {
  310. if($res.code == 0){
  311. $(".dialog-wrap").fadeIn();
  312. return ;
  313. }
  314. if($res.code == 10029 || $res.code == 10031){
  315. alert($res.msg);
  316. return ;
  317. }
  318. if($res.code == 10030){
  319. alert($res.msg);
  320. setTimeout(function(){
  321. location.href = "{!! $url !!}";
  322. },50);
  323. return ;
  324. }
  325. alert("系统异常");
  326. return ;
  327. }
  328. })
  329. }
  330. });
  331. // 关闭弹窗
  332. $(".dialog-content").delegate(".close", "click", function(e) {
  333. e.stopPropagation();
  334. $(".dialog-wrap").fadeOut();
  335. setTimeout(function(){
  336. location.href = "{!! $url !!}";
  337. },50);
  338. })
  339. </script>
  340. </html>