set-user-phone.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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" 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. {{codeNUm == 0?codeText:codeNUm + 's'}}
  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. codeNUm: 0
  50. };
  51. },
  52. methods:{
  53. getCode(){
  54. if(!this.formData.phone){
  55. return tools.error('请输入手机号')
  56. }
  57. if (this.isCode) {
  58. return
  59. }
  60. this.isCode = true;
  61. getCode({phone:this.formData.phone,send_type:'update_phone'}).then((res)=>{
  62. if(res.code === 1){
  63. this.codeNUm = 60;
  64. let timer = setInterval(() => {
  65. this.codeNUm -= 1;
  66. if (this.codeNUm <= 0) {
  67. clearInterval(timer);
  68. this.isCode = false;
  69. this.codeText = '获取验证码'
  70. }
  71. }, 1000);
  72. }else{
  73. this.isCode = false;
  74. tools.error('获取验证码失败,请稍后重试')
  75. }
  76. })
  77. },
  78. save(){
  79. if(this.isAJAX){
  80. return
  81. }
  82. this.isAJAX = true;
  83. userPhone(this.formData).then((res)=>{
  84. if(res.code === 1){
  85. this.isAJAX = false;
  86. tools.success('修改成功');
  87. setTimeout(()=>{
  88. uni.reLaunch({
  89. url:'/pages-my/user-info'
  90. })
  91. },1500)
  92. }else{
  93. this.isAJAX = false;
  94. tools.error(res.msg);
  95. }
  96. })
  97. },
  98. },
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .content-box {
  103. padding: 32rpx 40rpx 0;
  104. }
  105. .phone-box {
  106. position: relative;
  107. }
  108. .uni-input {
  109. // width: 100%;
  110. background: #F6F6F6;
  111. height: 92rpx;
  112. line-height: 92rpx;
  113. padding: 0 0 0 68rpx;
  114. }
  115. .icons {
  116. position: absolute;
  117. top: 30rpx;
  118. left: 24rpx;
  119. width: 32rpx;
  120. height: 32rpx;
  121. }
  122. .get-code-box{
  123. width: 208rpx;
  124. }
  125. .get-but{
  126. width: 100%;
  127. height: 92rpx;
  128. line-height: 92rpx;
  129. border: 2rpx solid #57CAFF;
  130. }
  131. .but{
  132. width: 100%;
  133. height: 92rpx;
  134. line-height: 92rpx;
  135. }
  136. </style>