save_phone.html 4.5 KB

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