user-changephone.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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">
  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" v-cloak>
  36. <van-button type="primary" block color="#FF502A" :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/klm-axios-config.js"></script>
  42. <script>
  43. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  44. // 可以通过下面的方式手动注册
  45. Vue.use(vant.Lazyload);
  46. // 在 #app 标签下渲染一个按钮组件
  47. let app = new Vue({
  48. el: '#app',
  49. data() {
  50. return {
  51. toptitleisshow:false,
  52. oldphone: '',
  53. changephone:{
  54. Id:'',
  55. Mobile:'',
  56. MobileCode:''
  57. },
  58. canSubmit: false,
  59. codeisclick:true,
  60. countdown:60,
  61. };
  62. },
  63. async created() {
  64. this.toptitleisshow = toptitleisshow;
  65. this.changephone.Id = PublicLib.getCookieInfo('userId');
  66. const res = await getRequest('/api/v1/users/personalinfo',JSON.stringify({Id:this.changephone.Id}));
  67. this.oldphone = res.data.Mobile;
  68. },
  69. methods: {
  70. checkValue(){
  71. this.canSubmit = (this.oldphone !== '' && this.changephone.Mobile !== '' && this.changephone.MobileCode !== '') ? true : false;
  72. },
  73. //- 获取验证码
  74. async getmobilecode(){
  75. if(this.oldphone === this.changephone.Mobile) return tips('修改手机号码相同,请重新输入');
  76. if(verification(this.changephone.Mobile)) return ;
  77. this.codeisclick = false;
  78. setTimeout(()=>{
  79. this.codeisclick = true;
  80. },60000);
  81. const timer = setInterval(()=>{
  82. this.countdown--;
  83. if(this.countdown === 0) {
  84. this.countdown = 60;
  85. clearInterval(timer)
  86. }
  87. },1000);
  88. const res = await postRequest('/api/v1/mobilecodecheck/sendsms',JSON.stringify({Mobile:this.changephone.Mobile}));
  89. if(res.status !== '1') return tips(res.info);
  90. tips('验证码发送成功,请注意查收!');
  91. },
  92. //- 修改手机号码
  93. changephonefn:undebounce(async function(){
  94. if(this.oldphone === this.changephone.Mobile) return tips('修改手机号码相同,请重新输入');
  95. if(verification(this.changephone.Mobile)) return ;
  96. const res = await postRequest('/api/v1/users/modifymobile',JSON.stringify(this.changephone));
  97. if(res.status !== '1') return tips(res.info);
  98. tips('手机号码修改成功')
  99. setTimeout(()=>{
  100. this.goback();
  101. },2000);
  102. }),
  103. goback(){
  104. PublicLib.GoBack({Level:2});
  105. }
  106. }
  107. });
  108. </script>
  109. </body>
  110. </html>