editMobile.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <view class="name">旧手机号码:</view>
  5. <view class="item">
  6. <input type="text" class="input" placeholder="请输入旧手机号码" v-model="mobile1" maxlength="11" />
  7. </view>
  8. <view class="name">新手机号码:</view>
  9. <view class="item">
  10. <input type="text" class="input" placeholder="请输入新手机号码" v-model="mobile2" maxlength="11" />
  11. </view>
  12. <view class="name">验证码:</view>
  13. <view class="item">
  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" v-if="captchaTime > 0">{{captchaTime}}秒后重试</view>
  17. </view>
  18. <view class="blankHeight"></view>
  19. </view>
  20. <view class="btn_submit" @click="submitData">提交修改</view>
  21. <DialogBox ref="DialogBox"></DialogBox>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. components: {},
  27. data() {
  28. return {
  29. title: '',
  30. mobile1: '',
  31. mobile2: '',
  32. code: '',
  33. captchaTime: 0,
  34. }
  35. },
  36. onLoad() {},
  37. onShow() {
  38. // this.loadData();
  39. },
  40. methods: {
  41. onBack() {},
  42. chkSel() {
  43. if (this.sel == 1) {
  44. this.sel = 0;
  45. } else {
  46. this.sel = 1;
  47. }
  48. },
  49. getCodeTime() {
  50. this.captchaTime = 60;
  51. let timer = setInterval(() => {
  52. this.captchaTime--;
  53. // console.log(this.captchaTime)
  54. if (this.captchaTime < 1) {
  55. clearInterval(timer);
  56. this.captchaTime = 0
  57. }
  58. }, 1000)
  59. },
  60. getCode() {
  61. if (this.mobile2.length != 11) {
  62. uni.showToast({
  63. title: '请输入新手机号',
  64. icon: 'none'
  65. });
  66. return;
  67. }
  68. if (this.captchaTime > 0) {
  69. uni.showToast({
  70. title: '不能重复获取',
  71. icon: 'none'
  72. });
  73. return;
  74. }
  75. this.captchaTime = 60;
  76. uni.request({
  77. url: this.$apiHost + '/Web/getcode', //仅为示例,并非真实接口地址。
  78. data: {
  79. skey: this.skey,
  80. mobile: this.mobile2,
  81. },
  82. header: {
  83. 'content-type': 'application/json' //自定义请求头信息
  84. },
  85. success: (res) => {
  86. console.log("----", res.data)
  87. uni.showToast({
  88. title: res.data.str,
  89. icon: 'none'
  90. })
  91. if (res.data.success == 'yes') {
  92. this.getCodeTime();
  93. } else {
  94. this.captchaTime = 0;
  95. }
  96. }
  97. });
  98. },
  99. submitData() {
  100. if (this.mobile1 == "") {
  101. uni.showToast({
  102. title: "请输入旧手机号码",
  103. icon: 'none'
  104. });
  105. return;
  106. }
  107. if (this.mobile2 == "") {
  108. uni.showToast({
  109. title: "请输入新手机号码",
  110. icon: 'none'
  111. });
  112. return;
  113. }
  114. if (this.code == "") {
  115. uni.showToast({
  116. title: "请输入验证码",
  117. icon: 'none'
  118. });
  119. return;
  120. }
  121. uni.request({
  122. url: this.$apiHost + '/Member/editMobile',
  123. data: {
  124. uuid: getApp().globalData.uuid,
  125. mobile1: this.mobile1,
  126. mobile2: this.mobile2,
  127. code: this.code,
  128. },
  129. header: {
  130. 'content-type': 'application/json'
  131. },
  132. success: (res) => {
  133. console.log("----", res.data);
  134. uni.showToast({
  135. title: res.data.str,
  136. icon: 'none'
  137. });
  138. if (res.data.success == "yes") {
  139. }
  140. }
  141. });
  142. },
  143. }
  144. }
  145. </script>
  146. <style scoped lang="scss">
  147. @import 'normal.scss';
  148. </style>