user-changephone.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>修改登录手机号-创业帮</title>
  6. <meta name="keywords" content="修改登录手机号-创业帮">
  7. <meta name="description" content="修改登录手机号-创业帮">
  8. <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  11. <meta content="telephone=no" name="format-detection">
  12. <meta content="email=no" name="format-detection">
  13. <meta name="apple-mobile-web-app-title" content="修改登录手机号-创业帮">
  14. <meta http-equiv="Cache-Control" content="no-siteapp">
  15. <link rel="stylesheet" href="./static/css/main.css">
  16. </head>
  17. <body class="nopb bgcf7f7f7" style="padding-top:0;">
  18. <div id="app">
  19. <van-nav-bar class="bgcf7f7f7 user_rank_explan_title user_title_normal" left-arrow @click-left="goback" v-if="toptitleisshow">
  20. <template #left> <img src="./static/images/left.png" alt=""></template>
  21. </van-nav-bar>
  22. <div class="regist-box-input pt8 pb32 pl32 pr32">
  23. <div class="f24 c333 b pb32">修改登录手机号</div>
  24. <div class="f12 c666 mb6">原手机号</div>
  25. <van-field class="mb12" v-model="oldphone" disabled @input="checkValue"></van-field>
  26. <div class="f12 c666 mb6">新手机号</div>
  27. <van-field class="mb12" v-model="changephone.Mobile" @input="checkValue" placeholder="请输入新手机号"></van-field>
  28. <div class="f12 c666 mb6">验证码</div>
  29. <van-field class="user-phone mb12" center clearable placeholder="请输入验证码" v-model="changephone.MobileCode" @input="checkValue">
  30. <template #button>
  31. <van-button class="fl" plain color="#FF502A" @click="getmobilecode" v-if="codeisclick">获取验证码</van-button>
  32. <van-button class="fl" plain color="#FF502A" disabled v-else>{{countdown}}s</van-button>
  33. </template>
  34. </van-field>
  35. <div class="pt16 bc333" v-cloak>
  36. <van-button type="primary" block color="#FFD500" :disabled="canSubmit ? false : true" @click="changephonefn">完成</van-button>
  37. </div>
  38. </div>
  39. </div>
  40. <script src="./static/js/klm-vv.min.js"></script>
  41. <script src="./static/js/appfunc.min.js"></script>
  42. <script src="./static/js/klm-axios-config.js"></script>
  43. <script src="./static/js/publicfn.js"></script>
  44. <script>
  45. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  46. // 可以通过下面的方式手动注册
  47. Vue.use(vant.Lazyload);
  48. // 在 #app 标签下渲染一个按钮组件
  49. let app = new Vue({
  50. el: '#app',
  51. data() {
  52. return {
  53. toptitleisshow:false,
  54. oldphone: '',
  55. changephone:{
  56. Id:'',
  57. Mobile:'',
  58. MobileCode:''
  59. },
  60. canSubmit: false,
  61. codeisclick:true,
  62. countdown:60,
  63. };
  64. },
  65. async created() {
  66. this.toptitleisshow = toptitleisshow;
  67. this.changephone.Id = PublicLib.getCookieInfo('userId');
  68. const res = await getRequest('api/v1/users/personalinfo?t='+Math.random(6),JSON.stringify({Id:this.changephone.Id}));
  69. this.oldphone = res.data.Mobile;
  70. },
  71. methods: {
  72. checkValue(){
  73. this.canSubmit = (this.oldphone !== '' && this.changephone.Mobile !== '' && this.changephone.MobileCode !== '') ? true : false;
  74. },
  75. //- 获取验证码
  76. async getmobilecode(){
  77. if(this.oldphone === this.changephone.Mobile) return tips('修改手机号码相同,请重新输入');
  78. if(verification(this.changephone.Mobile)) return ;
  79. this.codeisclick = false;
  80. setTimeout(()=>{
  81. this.codeisclick = true;
  82. },60000);
  83. const timer = setInterval(()=>{
  84. this.countdown--;
  85. if(this.countdown === 0) {
  86. this.countdown = 60;
  87. clearInterval(timer);
  88. }
  89. },1000);
  90. const res = await postRequest('api/v1/mobilecodecheck/sendsms',JSON.stringify({Mobile:this.changephone.Mobile}));
  91. if(res.status !== '1') return tips(res.info);
  92. tips('验证码发送成功,请注意查收!');
  93. },
  94. //- 修改手机号码
  95. changephonefn:undebounce(async function(){
  96. if(this.oldphone === this.changephone.Mobile) return tips('修改手机号码相同,请重新输入');
  97. if(verification(this.changephone.Mobile)) return ;
  98. const res = await postRequest('api/v1/users/modifymobile?t='+Math.random(6),JSON.stringify(this.changephone));
  99. if(res.status !== '1') return tips(res.info);
  100. tips('手机号码修改成功')
  101. setTimeout(()=>{
  102. this.changefinish();
  103. },2000);
  104. }),
  105. goback(){
  106. PublicLib.GoBack({Level:2});
  107. },
  108. changefinish(){
  109. const id = PublicLib.getCookieInfo('userId');
  110. postRequest('api/v1/users/logout',JSON.stringify({UserId:id}));
  111. PublicLib.GoBack({Level:-1});
  112. PublicLib.putCookieInfo('passwordxx', '');
  113. PublicLib.putCookieInfo('chooseType', '');
  114. PublicLib.putCookieInfo('step', 'close');
  115. PublicLib.putCookieInfo('isloginout','');
  116. }
  117. }
  118. });
  119. </script>
  120. </body>
  121. </html>