You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

phone_verify.tmpl 19 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <style>
  2. .__phone-verify-code {
  3. max-width: 519px;
  4. }
  5. .__phone-verify-code ._label-c {
  6. display: flex;
  7. justify-content: fixed-start;
  8. align-items: center;
  9. width: 100px;
  10. display: none;
  11. }
  12. .__phone-verify-code ._label-c ._label {
  13. font-size: 13px;
  14. font-weight: 700;
  15. color: rgba(0,0,0,.87);
  16. }
  17. .__phone-verify-code ._label-c.required ._label:after {
  18. margin: -0.2em 0 0 0.2em;
  19. content: '*';
  20. color: #db2828;
  21. display: inline-block;
  22. vertical-align: top;
  23. }
  24. .__phone-verify-code .phone-c {
  25. display: flex;
  26. margin: 0 0 1em;
  27. }
  28. .__phone-verify-code .phone-c .phone-area-c {
  29. height: 38px;
  30. width: 80px;
  31. margin-right: 10px;
  32. border-radius: 2px;
  33. display: flex;
  34. justify-content: center;
  35. align-items: center;
  36. box-sizing: border-box;
  37. }
  38. .__phone-verify-code .phone-c .phone-area-c select {
  39. outline: none;
  40. }
  41. .__phone-verify-code .phone-c .phone-num-c {
  42. height: 38px;
  43. flex: 1;
  44. display: flex;
  45. justify-content: center;
  46. align-items: center;
  47. box-sizing: border-box;
  48. position: relative;
  49. }
  50. .__phone-verify-code .phone-c .phone-num-c input {
  51. height: 100%;
  52. width: 100% !important;
  53. padding: 9.5px 14px;
  54. box-sizing: border-box;
  55. outline: none;
  56. }
  57. .__phone-verify-code .phone-c .modify-phone-number {
  58. position: absolute;
  59. left: 100%;
  60. width: 200px;
  61. height: 100%;
  62. margin-left: 10px;
  63. display: none;
  64. }
  65. .__phone-verify-code .phone-c .modify-phone-number a {
  66. font-weight: 400;
  67. font-size: 14px;
  68. color: rgba(0, 102, 255, 1);
  69. }
  70. .__phone-verify-code .slide-bar-wrap {
  71. display: flex;
  72. height: 38px;
  73. margin: 0 0 1em;
  74. justify-content: center;
  75. align-items: center;
  76. position: relative;
  77. }
  78. .__phone-verify-code .slide-bar-c {
  79. flex: 1;
  80. display: flex;
  81. height: 38px;
  82. justify-content: center;
  83. align-items: center;
  84. position: relative;
  85. }
  86. .__phone-verify-code .slide-bar-c .slide-bar-bg {
  87. height: 34px;
  88. flex: 1;
  89. background-color: rgb(245, 245, 246);
  90. border: 1px solid rgb(225, 227, 230);
  91. border-radius: 2px;
  92. position: relative;
  93. }
  94. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-txt {
  95. position: absolute;
  96. width: 100%;
  97. height: 100%;
  98. display: flex;
  99. user-select: none;
  100. justify-content: center;
  101. align-items: center;
  102. color: #cdcacb;
  103. font-size: 14px;
  104. }
  105. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-bar {
  106. position: absolute;
  107. width: 38px;
  108. height: 34px;
  109. background-color: #d1e9fe;
  110. border: 1px solid #1991fa;
  111. border-radius: 2px;
  112. box-sizing: border-box;
  113. top: -1px;
  114. }
  115. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-bar.sucess {
  116. background-color: #d2f4ef;
  117. border: 1px solid #52ccba;
  118. }
  119. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-bar.error {
  120. border-color: #f57a7a;
  121. background-color: #fce1e1;
  122. }
  123. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-trigger {
  124. position: absolute;
  125. width: 38px;
  126. height: 34px;
  127. background-color: #1991fa;
  128. border-radius: 2px;
  129. cursor: pointer;
  130. top: -1px;
  131. display: flex;
  132. justify-content: center;
  133. align-items: center;
  134. }
  135. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-trigger .icon {
  136. font-size: 16px;
  137. color: white;
  138. margin: 0;
  139. height: 16px;
  140. width: 16px;
  141. margin-top: -5px;
  142. }
  143. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-trigger.sucess {
  144. background-color: #52ccba;
  145. }
  146. .__phone-verify-code .slide-bar-c .slide-bar-bg .slide-trigger.error {
  147. background-color: #f57a7a;
  148. }
  149. .__phone-verify-code .slide-bar-c .slide-image-big {
  150. position: absolute;
  151. width: 391px;
  152. height: 196px;
  153. top: 36px;
  154. left: 0;
  155. border-radius: 2px;
  156. z-index: 100;
  157. display: none;
  158. }
  159. .__phone-verify-code .slide-bar-c .slide-image-small {
  160. position: absolute;
  161. left: 0;
  162. width: 51px;
  163. height: 51px;
  164. box-shadow: 0 0 4px rgb(35 173 255);
  165. }
  166. .__phone-verify-code .slide-bar-c .verify-code-c {
  167. display: flex;
  168. height: 38px;
  169. }
  170. .__phone-verify-code .verify-code-c {
  171. display: flex;
  172. height: 38px;
  173. margin: 0 0 1em;
  174. justify-content: center;
  175. align-items: center;
  176. }
  177. .__phone-verify-code .verify-code-c .verify-code-num-c {
  178. flex: 1;
  179. height: 38px;
  180. box-sizing: border-box;
  181. justify-content: center;
  182. align-items: center;
  183. display: flex;
  184. }
  185. .__phone-verify-code .verify-code-c .verify-code-num-c input {
  186. height: 100%;
  187. width: 100% !important;
  188. padding: 9.5px 14px;
  189. box-sizing: border-box;
  190. outline: none;
  191. }
  192. .__phone-verify-code .verify-code-c .verify-code-send {
  193. display: flex;
  194. width: 120px;
  195. height: 38px;
  196. justify-content: center;
  197. align-items: center;
  198. }
  199. .__phone-verify-code .verify-code-c .verify-code-send .verify-code-send-btn {
  200. height: 100%;
  201. width: 100%;
  202. margin-left: 10px;
  203. border: 1px solid #398dee;
  204. background-color: #398dee;
  205. color: white;
  206. border-radius: 2px;
  207. box-sizing: border-box;
  208. cursor: pointer;
  209. display: flex;
  210. justify-content: center;
  211. align-items: center;
  212. }
  213. .__phone-verify-code .verify-code-c .verify-code-send .verify-code-send-btn.__disabled {
  214. border: 1px solid #ddd;
  215. background-color: #ddd;
  216. cursor: not-allowed;
  217. }
  218. .__phone-verify-code .new-pass-word-wrap {
  219. display: flex;
  220. height: 38px;
  221. margin: 0 0 1em;
  222. justify-content: center;
  223. align-items: center;
  224. display: none;
  225. }
  226. .__phone-verify-code .new-pass-word-wrap .new-pass-word-c {
  227. flex: 1;
  228. height: 38px;
  229. box-sizing: border-box;
  230. justify-content: center;
  231. align-items: center;
  232. display: flex;
  233. }
  234. .__phone-verify-code .new-pass-word-wrap .new-pass-word-c input {
  235. height: 100%;
  236. width: 100% !important;
  237. padding: 9.5px 14px;
  238. box-sizing: border-box;
  239. outline: none;
  240. }
  241. </style>
  242. <div class="__phone-verify-code">
  243. <div class="phone-c">
  244. <div class="phone-label _label-c required">
  245. <span class="_label">{{.i18n.Tr "phone.phone_number"}}</span>
  246. </div>
  247. <div class="phone-area-c">
  248. <select value="+86">
  249. <option value="+86">+86</option>
  250. </select>
  251. </div>
  252. <div class="field phone-num-c">
  253. <input class="phoneNumber" style="width:100% !important" name="phone_number" value="{{.phone_number}}" placeholder="{{.i18n.Tr "phone.phone_number"}}" required autocomplete="off" />
  254. <div class="modify-phone-number"><div style="display:flex;align-items:center;height:100%;"><a>{{.i18n.Tr "phone.modify_phone_number"}}</a></div></div>
  255. </div>
  256. </div>
  257. <div class="slide-bar-wrap">
  258. <div class="slide-bar-label _label-c required" style=""></div>
  259. <div class="slide-bar-c" style="flex:1;">
  260. <div class="slide-bar-bg">
  261. <div class="slide-txt">{{.i18n.Tr "phone.drag_the_slider_to_fill_the_puzzle"}}</div>
  262. <div class="slide-bar"></div>
  263. <div class="slide-trigger">
  264. <i class="arrow right icon"></i>
  265. <i class="check icon" style="display:none;"></i>
  266. <i class="close icon" style="display:none;"></i>
  267. </div>
  268. </div>
  269. <div class="slide-image-big">
  270. <div class="slide-image-small" style="top:{{.SlideImageInfo.ImageY}}px"></div>
  271. </div>
  272. </div>
  273. </div>
  274. <div class="verify-code-c">
  275. <div class="verify-code-label _label-c required">
  276. <span class="_label">{{.i18n.Tr "phone.mobile_phone_verification_code"}}</span>
  277. </div>
  278. <div class="verify-code-num-c">
  279. <input class="verifyCode" style="width:100% !important" name="verify_code" value="{{.verify_code}}" placeholder="{{.i18n.Tr "phone.please_enter_SMS_verification_code"}}" required autocomplete="off" />
  280. </div>
  281. <div class="verify-code-send">
  282. <div class="verify-code-send-btn __disabled">{{.i18n.Tr "phone.get_verification_code"}}</div>
  283. </div>
  284. </div>
  285. <div class="new-pass-word-wrap">
  286. <div class="new-pass-word-label _label-c required">
  287. <span class="_label">{{.i18n.Tr "phone.new_login_password"}}</span>
  288. </div>
  289. <div class="new-pass-word-c">
  290. <input class="newPassword" style="width:100% !important" name="password" type="password" placeholder="{{.i18n.Tr "phone.please_enter_new_password"}}" required autocomplete="off" />
  291. </div>
  292. </div>
  293. <div class="new-pass-word-wrap">
  294. <div class="new-pass-word-label _label-c required"></div>
  295. <div class="field" style="flex:1;">
  296. <div class="ui checkbox">
  297. <label>{{.i18n.Tr "auth.remember_me"}}</label>
  298. <input name="remember" type="checkbox">
  299. </div>
  300. </div>
  301. </div>
  302. </div>
  303. <script>
  304. (function() {
  305. window.addEventListener('load', function () {
  306. function PhoneVerifyCode(dom) {
  307. if (!dom) return;
  308. this.countDownNumber = 120;
  309. this.init(dom);
  310. }
  311. PhoneVerifyCode.prototype.init = function (dom) {
  312. if (!dom) return;
  313. this.dom = $(dom);
  314. this.isMoving = false;
  315. this.verifySucess = false;
  316. this.canSendCode = false;
  317. this.countDownEnd = false;
  318. this.imgID = '';
  319. this.eventInit();
  320. this.refreshImages();
  321. var wrap = this.dom.closest('div.use-type');
  322. var readonly = wrap.attr('readonly');
  323. if (readonly) {
  324. this.dom.find('.phone-area-c select').attr('disabled', true);
  325. this.dom.find('.phone-num-c input').attr('disabled', true);
  326. this.dom.find('.slide-bar-wrap').hide();
  327. this.dom.find('.verify-code-c').hide();
  328. this.dom.find('.modify-phone-number').show();
  329. }
  330. var oldPhoneNum = wrap.attr('ophonenumber');
  331. if (oldPhoneNum) {
  332. this.dom.find('input.phoneNumber').val(oldPhoneNum);
  333. }
  334. var showlabel = wrap.attr('showlabel');
  335. if (showlabel) {
  336. this.dom.find('._label-c ').show();
  337. } else {
  338. this.dom.find('._label-c ').hide();
  339. }
  340. var showNewpwd = wrap.attr('shownewpwd');
  341. if (showNewpwd) {
  342. this.dom.find('.new-pass-word-wrap').show();
  343. } else {
  344. this.dom.find('.new-pass-word-wrap').remove();
  345. }
  346. var autofocus = wrap.attr('autofocus');
  347. if (autofocus) {
  348. this.dom.find('input.phoneNumber').focus();
  349. }
  350. var verifyCodeNoRequired = wrap.attr('verifycodenorequired');
  351. if (verifyCodeNoRequired) {
  352. this.dom.find('input.verifyCode').removeAttr('required');
  353. }
  354. };
  355. PhoneVerifyCode.prototype.eventInit = function () {
  356. if (!this.dom) return;
  357. var self = this;
  358. var clientX = 0, oLeft = 0, imgHideTimer = null;
  359. this.dom.find('.slide-bar-bg').on('mouseenter', function (e) {
  360. if (self.verifySucess) return;
  361. imgHideTimer && clearTimeout(imgHideTimer);
  362. self.dom.find('.slide-image-big').slideDown();
  363. });
  364. this.dom.find('.slide-bar-bg').on('mouseleave', function (e) {
  365. imgHideTimer && clearTimeout(imgHideTimer);
  366. imgHideTimer = setTimeout(function () {
  367. self.dom.find('.slide-image-big').slideUp();
  368. }, 200);
  369. });
  370. this.dom.find('.slide-image-big').on('mouseenter', function (e) {
  371. imgHideTimer && clearTimeout(imgHideTimer);
  372. });
  373. this.dom.find('.slide-image-big').on('mouseleave', function (e) {
  374. imgHideTimer && clearTimeout(imgHideTimer);
  375. imgHideTimer = setTimeout(function () {
  376. self.dom.find('.slide-image-big').slideUp();
  377. }, 200);
  378. });
  379. function mouseMove(e) {
  380. var _clientX = e.clientX;
  381. var offset = _clientX - clientX;
  382. var triggerEl = self.dom.find('.slide-trigger');
  383. var triggerWidth = triggerEl.width();
  384. var parentWidth = triggerEl.parent().width();
  385. var maxLeft = parentWidth - triggerWidth;
  386. var left = oLeft + offset;
  387. if (oLeft + offset < 0) left = 0;
  388. if (oLeft + offset > maxLeft) left = maxLeft;
  389. triggerEl.css('left', left + 'px');
  390. self.dom.find('.slide-bar').css('width', left + triggerWidth);
  391. var imageBigWidth = self.dom.find('.slide-image-big').width();
  392. var imageSmallWidth = self.dom.find('.slide-image-small').width();
  393. self.dom.find('.slide-image-small').css('left', left / maxLeft * (imageBigWidth - imageSmallWidth) + 'px');
  394. self.isMoving = true;
  395. self.dom.find('.slide-txt').hide();
  396. imgHideTimer && clearTimeout(imgHideTimer);
  397. }
  398. function mouseUp(e) {
  399. $(document).off('mousemove', mouseMove);
  400. $(document).off('mouseup', mouseUp);
  401. self.isMoving = false;
  402. $.ajax({
  403. url: '/verifySlideImage',
  404. type: 'post',
  405. dataType: 'json',
  406. data: {
  407. slide_id: self.imgID,
  408. x: parseInt(self.dom.find('.slide-image-small').position().left)
  409. },
  410. success: function(res) {
  411. if (res && res.Code === 0) {
  412. self.verifySucess = true;
  413. self.canSendCode = true;
  414. self.dom.find('.slide-bar').addClass('sucess');
  415. self.dom.find('.slide-trigger').addClass('sucess');
  416. self.dom.find('.slide-trigger .icon').hide();
  417. self.dom.find('.slide-trigger .icon.check').show();
  418. self.dom.find('.slide-image-big').slideUp();
  419. self.dom.find('.verify-code-send-btn').removeClass('__disabled');
  420. } else {
  421. self.dom.find('.slide-bar').addClass('error');
  422. self.dom.find('.slide-trigger').addClass('error');
  423. self.dom.find('.slide-trigger .icon').hide();
  424. self.dom.find('.slide-trigger .icon.close').show();
  425. setTimeout(function () {
  426. self.refreshImages();
  427. }, 300);
  428. }
  429. },
  430. error: function(err) {
  431. self.dom.find('.slide-bar').addClass('error');
  432. self.dom.find('.slide-trigger').addClass('error');
  433. setTimeout(function () {
  434. self.refreshImages();
  435. }, 300);
  436. }
  437. });
  438. }
  439. this.dom.find('.slide-trigger').on('mousedown', function (e) {
  440. if (self.verifySucess) return;
  441. clientX = e.clientX;
  442. oLeft = $(this).position().left;
  443. $(document).on('mousemove', mouseMove);
  444. $(document).on('mouseup', mouseUp);
  445. });
  446. this.dom.find('.verify-code-send-btn').on('click', function () {
  447. if (!self.canSendCode) return;
  448. if (self.countDownEnd) {
  449. self.refreshImages();
  450. return;
  451. }
  452. var phoneArea = self.dom.find('.phone-area-c select').val();
  453. var phoneNumber = self.dom.find('.phone-num-c input').val();
  454. if (!/^1[3578]\d{9}$/.test(phoneNumber)) {
  455. self.dom.find('.phone-num-c').addClass('error');
  456. return;
  457. } else {
  458. self.dom.find('.phone-num-c').removeClass('error');
  459. var useType = self.dom.closest('div.use-type').attr('usetype') || 0;
  460. $.ajax({
  461. url: '/sendVerifyCode',
  462. type: 'post',
  463. dataType: 'json',
  464. data: {
  465. phone_number: phoneNumber,
  466. mode: useType, // 0注册,1登录 ,2修改手机号,3找回密码
  467. slide_id: self.imgID,
  468. },
  469. success: function(res) {
  470. if (res && res.Code === 0) {
  471. self.countDown();
  472. } else {
  473. if ($('.ui.negative.message').length) {
  474. $('.ui.negative.message').eq(0).show().find('p').text(res.Message);
  475. } else {
  476. $('body').toast({
  477. message: res.Message,
  478. showProgress: 'bottom',
  479. showIcon:'warning circle',
  480. class: 'warning',
  481. position: 'top right',
  482. });
  483. }
  484. self.refreshImages();
  485. }
  486. },
  487. error: function(err) {
  488. console.log(err);
  489. }
  490. });
  491. }
  492. });
  493. this.dom.find('.modify-phone-number a').on('click', function() {
  494. self.dom.find('.phone-area-c select').attr('disabled', false);
  495. self.dom.find('.phone-num-c input').attr('disabled', false);
  496. self.dom.find('.slide-bar-wrap').css('display', 'flex');
  497. self.dom.find('.verify-code-c').css('display', 'flex');
  498. self.dom.find('.modify-phone-number').hide();
  499. });
  500. };
  501. PhoneVerifyCode.prototype.refreshImages = function () {
  502. this.isMoving = false;
  503. this.verifySucess = false;
  504. this.canSendCode = false;
  505. this.countDownEnd = false;
  506. this.imgID = '';
  507. this.dom.find('.slide-bar').removeClass('sucess error').css('width', '30px');
  508. this.dom.find('.slide-trigger').removeClass('sucess error').css('left', '0px');
  509. this.dom.find('.slide-trigger .icon').hide();
  510. this.dom.find('.slide-trigger .icon.arrow').show();
  511. this.dom.find('.slide-txt').show();
  512. this.dom.find('.slide-image-small').css('left', '0');
  513. this.dom.find('.verify-code-send-btn').addClass('__disabled');
  514. var self = this;
  515. $.ajax({
  516. url: '/slideImage',
  517. type: 'get',
  518. success: function(res) {
  519. if (res && res.Code === 0) {
  520. self.imgID = res.Message;
  521. self.dom.find('.slide-image-big').css('background', `url("/slideimage/${res.Message}.png")`);
  522. self.dom.find('.slide-image-small').css('background', `url("/slideimage/${res.Message}screenshot.png")`);
  523. }
  524. },
  525. error: function(err) {
  526. console.log(err);
  527. }
  528. });
  529. };
  530. PhoneVerifyCode.prototype.countDown = function () {
  531. var self = this;
  532. var sendBtnEl = this.dom.find('.verify-code-send-btn');
  533. var count = this.countDownNumber;
  534. sendBtnEl.addClass('__disabled').text(count + {{.i18n.Tr "phone.second_resend"}});
  535. this.canSendCode = false;
  536. this.countDownEnd = false;
  537. var timer = setInterval(function () {
  538. count--;
  539. sendBtnEl.addClass('__disabled').text(count + {{.i18n.Tr "phone.second_resend"}});
  540. if (count <= 0) {
  541. sendBtnEl.removeClass('__disabled').text({{.i18n.Tr "phone.get_verification_code"}});
  542. clearInterval(timer);
  543. self.canSendCode = true;
  544. self.countDownEnd = true;
  545. }
  546. }, 1000);
  547. };
  548. const phoneVerifyCode = new PhoneVerifyCode($('.__phone-verify-code'));
  549. });
  550. })();
  551. </script>