set-user-phone.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="flex-common-css bgc-f">
  3. <Nav title=" " titleColor="#333" bgckgroundBox='#fff'></Nav>
  4. <scroll-view :scroll-y="true" class="scroll-view-css">
  5. <view class="content-box box-border-box">
  6. <view class="fw-600 fs-48 fc-3 mb-16">
  7. 更换手机号
  8. </view>
  9. <view class="fs-28 fc-6 mb-32">
  10. 一个手机号只能绑定一个账号,绑定的手机账号禁止修改。
  11. </view>
  12. <view class="phone-box mb-22">
  13. <image class="icons" src="@/static/img/my/yzm-icons.png" mode=""></image>
  14. <input v-model="formData.phone" type="number" class="uni-input b-rad-200" focus placeholder="请输入手机号" />
  15. </view>
  16. <view class="flex-justify-space mb-80">
  17. <view class="phone-box mr-24 common-view-css">
  18. <image class="icons" src="@/static/img/my/yzm-icons.png" mode=""></image>
  19. <input v-model="formData.code" type="number" class="uni-input b-rad-200" focus placeholder="请输入验证码" />
  20. </view>
  21. <view class="get-code-box" @click="getCode()">
  22. <view class="get-but fc-57CAFF fs-32 text-align-center b-rad-200">
  23. {{codeText}}
  24. </view>
  25. </view>
  26. </view>
  27. <view class="but fs-32 fc-f fw-600 b-rad-200 text-align-center bgc-41ABF5" @click="save()">
  28. 确认
  29. </view>
  30. </view>
  31. </scroll-view>
  32. </view>
  33. </template>
  34. <script>
  35. import {userPhone} from '@/api/member.js';
  36. import {getCode} from '@/api/common.js';
  37. import tools from '@/service/tools';
  38. export default {
  39. components: {},
  40. data() {
  41. return {
  42. formData: {
  43. phone: '',
  44. code: ''
  45. },
  46. isAJAX:false,
  47. isCode:false,
  48. codeText:'获取验证码',
  49. };
  50. },
  51. methods:{
  52. getCode(){
  53. if(!this.formData.phone){
  54. return tools.error('请输入手机号')
  55. }
  56. if (this.isCode) {
  57. return
  58. }
  59. this.isCode = true;
  60. getCode({phone:this.formData.phone,send_type:'update_phone'}).then((res)=>{
  61. if(res.code === 1){
  62. this.codeText = 60;
  63. let timer = setInterval(() => {
  64. this.codeText -= 1;
  65. if (this.codeText <= 0) {
  66. clearInterval(timer);
  67. this.isCode = false;
  68. this.codeText = '获取验证码'
  69. }
  70. }, 1000);
  71. }else{
  72. this.isCode = false;
  73. tools.error('获取验证码失败,请稍后重试')
  74. }
  75. })
  76. },
  77. save(){
  78. if(this.isAJAX){
  79. return
  80. }
  81. this.isAJAX = true;
  82. userPhone(this.formData).then((res)=>{
  83. if(res.code === 1){
  84. this.isAJAX = false;
  85. tools.success('修改成功');
  86. setTimeout(()=>{
  87. uni.reLaunch({
  88. url:'/pages-my/user-info'
  89. })
  90. },1500)
  91. }else{
  92. this.isAJAX = false;
  93. tools.error(res.msg);
  94. }
  95. })
  96. },
  97. },
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .content-box {
  102. padding: 32rpx 40rpx 0;
  103. }
  104. .phone-box {
  105. position: relative;
  106. }
  107. .uni-input {
  108. // width: 100%;
  109. background: #F6F6F6;
  110. height: 92rpx;
  111. line-height: 92rpx;
  112. padding: 0 0 0 68rpx;
  113. }
  114. .icons {
  115. position: absolute;
  116. top: 30rpx;
  117. left: 24rpx;
  118. width: 32rpx;
  119. height: 32rpx;
  120. }
  121. .get-code-box{
  122. width: 208rpx;
  123. }
  124. .get-but{
  125. width: 100%;
  126. height: 92rpx;
  127. line-height: 92rpx;
  128. border: 2rpx solid #57CAFF;
  129. }
  130. .but{
  131. width: 100%;
  132. height: 92rpx;
  133. line-height: 92rpx;
  134. }
  135. </style>