bindPhone.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. var from = "{{ $from }}"
  235. // 倒计时
  236. function countDown(time, cb) {
  237. var timer = null
  238. timer = setInterval(function() {
  239. if (time === 1) clearInterval(timer);
  240. time--;
  241. if (cb) cb(time);
  242. }, 1000);
  243. }
  244. // 残忍拒绝事件
  245. $("#refuse").on("click", function() {
  246. if(!$(this).attr('disabled')){
  247. location.href = "{!! $url !!}";
  248. }
  249. });
  250. function refuse(){
  251. var timer = null
  252. time = refuseNumber
  253. timer = setInterval(function() {
  254. $.ajax({
  255. url:"/api/order/issuccess",
  256. data:{
  257. order:"{{ $order }}"
  258. },
  259. success:function(res){
  260. if(res['code'] == 0){
  261. time = 1;
  262. }
  263. }
  264. });
  265. if (time === 1) clearInterval(timer);
  266. time--;
  267. if (time === 0) {
  268. $("#refuse").text("残忍拒绝");
  269. $("#refuse").attr("disabled", false);
  270. $("#refuse").addClass("to-refuse__enable");
  271. } else $("#refuse").text("残忍拒绝(" + time + "s)");
  272. }, 1000);
  273. }
  274. if(order){
  275. refuse()
  276. }
  277. // 残忍拒绝倒计时
  278. /*countDown(refuseNumber, function(time) {
  279. if (time === 0) {
  280. $("#refuse").text("残忍拒绝");
  281. $("#refuse").attr("disabled", false);
  282. $("#refuse").addClass("to-refuse__enable");
  283. } else $("#refuse").text("残忍拒绝(" + time + "s)");
  284. });*/
  285. // 获取验证码
  286. var code_getting = false;
  287. $(".get-code").on("click", function() {
  288. var phone = $("#phone").val();
  289. if (!phone) {
  290. alert("请输入手机号!");
  291. return;
  292. } else if (!reg.test(phone)) {
  293. alert("手机号不合法!");
  294. return;
  295. }
  296. $.ajax({
  297. url:'/api/bindphone/sendcode',
  298. type:'post',
  299. data:{phone:phone},
  300. success:function () {
  301. }
  302. });
  303. if (!code_getting) {
  304. code_getting = true;
  305. countDown(getPhoneCodeNumber, function(time) {
  306. if (time === 0) {
  307. $(".get-code").text("获取验证码");
  308. code_getting = false;
  309. } else $(".get-code").text(time + "s");
  310. });
  311. }
  312. });
  313. // 立即绑定事件
  314. $("#bind").on("click", function() {
  315. var phone = $("#phone").val();
  316. var code = $("#code").val();
  317. if (!phone || !code) alert("手机号或验证码不能为空");
  318. else {
  319. // 绑定逻辑
  320. $.ajax({
  321. url:'/api/bindphone/bind',
  322. type:'post',
  323. data:{phone:phone,code:code,from:from},
  324. success:function ($res) {
  325. if($res.code == 0){
  326. $(".dialog-wrap").fadeIn();
  327. return ;
  328. }
  329. if($res.code == 10029 || $res.code == 10031){
  330. alert($res.msg);
  331. return ;
  332. }
  333. if($res.code == 10030){
  334. alert($res.msg);
  335. setTimeout(function(){
  336. location.href = "{!! $url !!}";
  337. },50);
  338. return ;
  339. }
  340. alert("系统异常");
  341. return ;
  342. }
  343. })
  344. }
  345. });
  346. // 关闭弹窗
  347. $(".dialog-content").delegate(".close", "click", function(e) {
  348. e.stopPropagation();
  349. $(".dialog-wrap").fadeOut();
  350. setTimeout(function(){
  351. location.href = "{!! $url !!}";
  352. },50);
  353. })
  354. </script>
  355. </html>