editMobile.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <!-- 标题和说明 -->
  5. <view class="title">原手机号验证</view>
  6. <view class="subtitle">该账号绑定的原手机号 139****5599,完成手机验证</view>
  7. <!-- 手机号输入 -->
  8. <view class="phone_input">
  9. <text class="area_code">+86</text>
  10. <input type="text" class="input" placeholder="请输入手机号" v-model="mobile" maxlength="11" />
  11. </view>
  12. <!-- 验证码输入 -->
  13. <view class="code_input">
  14. <input type="text" class="input" placeholder="请输入验证码" v-model="code" maxlength="6" />
  15. <view class="btn" v-if="captchaTime === 0" @click="getCode">获取验证码</view>
  16. <view class="btn disabled" v-else>{{captchaTime}}秒后重试</view>
  17. </view>
  18. <view class="blankHeight"></view>
  19. </view>
  20. <view class="btn_submit">确定</view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. components: {},
  26. data() {
  27. return {
  28. title: '',
  29. mobile: '',
  30. code: '',
  31. captchaTime: 0,
  32. }
  33. },
  34. onLoad() {},
  35. onShow() {
  36. // this.loadData();
  37. },
  38. methods: {
  39. onBack() {},
  40. chkSel() {
  41. if (this.sel == 1) {
  42. this.sel = 0;
  43. } else {
  44. this.sel = 1;
  45. }
  46. },
  47. getCodeTime() {
  48. this.captchaTime = 60;
  49. let timer = setInterval(() => {
  50. this.captchaTime--;
  51. // console.log(this.captchaTime)
  52. if (this.captchaTime < 1) {
  53. clearInterval(timer);
  54. this.captchaTime = 0
  55. }
  56. }, 1000)
  57. },
  58. getCode() {
  59. if (this.mobile.length != 11) {
  60. uni.showToast({
  61. title: '请输入手机号',
  62. icon: 'none'
  63. });
  64. return;
  65. }
  66. if (this.captchaTime > 0) {
  67. uni.showToast({
  68. title: '不能重复获取',
  69. icon: 'none'
  70. });
  71. return;
  72. }
  73. this.captchaTime = 60;
  74. uni.request({
  75. url: this.$apiHost + '/Web/getcode',
  76. data: {
  77. skey: this.skey,
  78. mobile: this.mobile,
  79. },
  80. header: {
  81. 'content-type': 'application/json'
  82. },
  83. success: (res) => {
  84. console.log("----", res.data)
  85. uni.showToast({
  86. title: res.data.str,
  87. icon: 'none'
  88. })
  89. if (res.data.success == 'yes') {
  90. this.getCodeTime();
  91. } else {
  92. this.captchaTime = 0;
  93. }
  94. }
  95. });
  96. },
  97. submitData() {
  98. if (this.mobile == "") {
  99. uni.showToast({
  100. title: "请输入手机号",
  101. icon: 'none'
  102. });
  103. return;
  104. }
  105. if (this.code == "") {
  106. uni.showToast({
  107. title: "请输入验证码",
  108. icon: 'none'
  109. });
  110. return;
  111. }
  112. uni.request({
  113. url: this.$apiHost + '/Member/editMobile',
  114. data: {
  115. uuid: getApp().globalData.uuid,
  116. mobile: this.mobile,
  117. code: this.code,
  118. },
  119. header: {
  120. 'content-type': 'application/json'
  121. },
  122. success: (res) => {
  123. console.log("----", res.data);
  124. uni.showToast({
  125. title: res.data.str,
  126. icon: 'none'
  127. });
  128. if (res.data.success == "yes") {
  129. }
  130. }
  131. });
  132. },
  133. }
  134. }
  135. </script>
  136. <style scoped lang="scss">
  137. @import 'normal.scss';
  138. </style>