save_phone.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!-- +---------------------------------------------------------------------- -->
  2. <!-- | CRMEB [ CRMEB赋能开发者,助力企业发展 ] -->
  3. <!-- +---------------------------------------------------------------------- -->
  4. <!-- | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. -->
  5. <!-- +---------------------------------------------------------------------- -->
  6. <!-- | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 -->
  7. <!-- +---------------------------------------------------------------------- -->
  8. <!-- | Author: CRMEB Team <admin@crmeb.com> -->
  9. <!-- +---------------------------------------------------------------------- -->
  10. {extend name="public/container"}
  11. {block name="title"}{if $user_phone}更换手机号码{else}绑定手机号码{/if}{/block}
  12. {block name='head_top'}
  13. <style>
  14. body{background-color: #f2f2f2}
  15. </style>
  16. {/block}
  17. {block name="content"}
  18. <div class="replace-phone" id="app" v-cloak>
  19. <ul class="list">
  20. <li class="item"><input type="text" :placeholder="place_msg" v-model="phone"></li>
  21. <li class="item itemCode acea-row row-between-wrapper">
  22. <input type="tel" v-model="code_num" maxlength="11" placeholder="请输入验证码">
  23. <button class="code" :disabled="active" :class="active == true?'on':''" @click="code">{{timetext}}</button>
  24. </li>
  25. </ul>
  26. <div class="bnt" v-text="but_name" @click="goNext">下一步</div>
  27. <!--完成-->
  28. <quick-menu></quick-menu>
  29. </div>
  30. {/block}
  31. {block name='foot'}
  32. <script>
  33. var phone='{$user_phone}';
  34. require(['vue','helper','store','reg-verify', '{__WAP_PATH}zsff/js/quick.js'],function(Vue,$h,app,$reg) {
  35. new Vue({
  36. el: '#app',
  37. data: {
  38. phone:phone || '',
  39. code_num:'',
  40. place_msg:phone ? '请输入原的手机号' : '请输入手机号码',
  41. active:false,
  42. timetext:'获取验证码',
  43. but_name:phone ? '下一步':'确认绑定',
  44. run:null,
  45. type:0,
  46. },
  47. methods:{
  48. goNext:function(){
  49. var that=this;
  50. if(phone){
  51. app.baseGet($h.U({c:'my',a:'validate_code',q:{phone:this.phone,code:this.code_num}}),function (res) {
  52. $h.pushMsgOnce(res.data.msg,function () {
  53. that.phone='';
  54. that.code_num='';
  55. that.but_name='确认绑定';
  56. that.place_msg='请输入新手机号码';
  57. that.active=false;
  58. that.type=1;
  59. phone='';
  60. if(that.run) clearInterval(that.run);
  61. that.timetext='获取验证码';
  62. document.title='绑定手机号码';
  63. });
  64. });
  65. }else{
  66. app.baseGet($h.U({
  67. c:'my',
  68. a:'save_phone',
  69. q:{
  70. phone:this.phone,
  71. code:this.code_num,
  72. type:this.type
  73. }
  74. }),function (res) {
  75. $h.pushMsgOnce(res.data.msg,function () {
  76. window.location.href=$h.U({c:'my',a:'index'});
  77. })
  78. });
  79. }
  80. },
  81. code:function () {
  82. var that = this;
  83. if(!that.phone) return $h.pushMsgOnce('请输入手机号码');
  84. if(!$reg.isPhone(that.phone)) return $h.pushMsgOnce('请输入正确的手机号码');
  85. this.SendOutCode();
  86. },
  87. SendOutCode:function () {
  88. var that = this;
  89. that.active = true;
  90. var n = 60;
  91. app.baseGet($h.U({c:'auth_api',a:'code',q:{phone:that.phone}}),function (res){
  92. var data=res.data.data;
  93. if(data.Message=='OK' || data.Code=='OK'){
  94. that.run=setInterval(function(){
  95. n--;
  96. if(n<0){
  97. clearInterval(that.run);
  98. that.run=null
  99. }
  100. that.timetext = "剩余 "+n+"s";
  101. if(that.timetext<"剩余 "+0+"s"){
  102. that.active = false;
  103. that.timetext = "重发";
  104. }
  105. },1000);
  106. }else{
  107. $h.pushMsgOnce(data.Message);
  108. that.active =false;
  109. }
  110. },function (res) {
  111. that.active =false;
  112. });
  113. }
  114. }
  115. });
  116. })
  117. </script>
  118. {/block}