editphone.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="main bg-white margin-top padding-tb-sm">
  3. <view class="flex justify-between align-center padding-lr-sm">
  4. <view class="flex-sub margin-right-sm">
  5. <u-input v-model="value" :type="type" placeholder="请输入原绑定电话验证码" :border="border" />
  6. </view>
  7. <u-verification-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-verification-code>
  8. <u-button @click="getCode">{{tips}}</u-button>
  9. </view>
  10. <view class="flex justify-between align-center margin-top-sm padding-lr-sm">
  11. <view class="flex-sub margin-right-sm">
  12. <u-input v-model="newphone" :type="type" placeholder="请输入新号码" :border="border" />
  13. </view>
  14. </view>
  15. <view class="flex justify-between align-center margin-top-sm padding-lr-sm">
  16. <view class="flex-sub margin-right-sm">
  17. <u-input v-model="newcode" :type="type" placeholder="请输入新号码验证码" :border="border" />
  18. </view>
  19. <u-verification-code :seconds="newseconds" @end="newend" @start="newstart" ref="newuCode" @change="codeChange1"></u-verification-code>
  20. <u-button @click="getnewCode">{{newtips}}</u-button>
  21. </view>
  22. <view class="cu-bar bg-white tabbar" style="position: fixed;bottom: 0;width: 100%;">
  23. <view class="submit" style="background-color: #0B73B9;color: white;" @click="savephone">
  24. 立即保存
  25. </view>
  26. </view>
  27. <view class="cu-tabbar-height"></view>
  28. <view class="cu-tabbar-height"></view>
  29. <u-no-network></u-no-network>
  30. </view>
  31. </template>
  32. <script>
  33. import store from '@/store'
  34. export default {
  35. onLoad(options) {
  36. },
  37. mounted() {
  38. this.info = store.getters['getusers']
  39. },
  40. data() {
  41. return {
  42. value: '',
  43. newphone: "",
  44. newcode: "",
  45. type: 'number',
  46. border: true,
  47. tips: '',
  48. newtips: "",
  49. seconds: 60,
  50. newseconds: 60,
  51. info: {}
  52. }
  53. },
  54. methods: {
  55. codeChange(text) {
  56. this.tips = text;
  57. },
  58. codeChange1(text) {
  59. this.newtips = text;
  60. },
  61. getCode() {
  62. if (this.$refs.uCode.canGetCode) {
  63. this.$refs.uCode.start();
  64. } else {
  65. uni.showToast({
  66. title: "结束后再发送",
  67. icon: "none"
  68. })
  69. }
  70. },
  71. getnewCode() {
  72. if (this.$refs.newuCode.canGetCode) {
  73. this.$refs.newuCode.start();
  74. } else {
  75. uni.showToast({
  76. title: "结束后再发送",
  77. icon: "none"
  78. })
  79. }
  80. },
  81. end() {
  82. },
  83. start: async function() {
  84. let res = await this.$request.post("/api/v1/common/sendVerifyCode", {
  85. phone: this.info.phone,
  86. type: 4
  87. })
  88. },
  89. newend() {
  90. },
  91. newstart: async function() {
  92. let res = await this.$request.post("/api/v1/common/sendVerifyCode", {
  93. phone: this.newphone,
  94. type: 5
  95. })
  96. },
  97. savephone: async function() {
  98. let res = await this.$request.post("/api/v1/user/changeUserPhone", {
  99. old_verify_code: this.value,
  100. new_verify_code: this.newcode,
  101. new_phone: this.newphone
  102. })
  103. console.log(res)
  104. if (res.status == 0) {
  105. uni.showToast({
  106. title: "保存成功",
  107. duration: 1000
  108. })
  109. setTimeout(() => {
  110. uni.navigateBack({
  111. delta: 1
  112. })
  113. }, 1000)
  114. } else {
  115. uni.showToast({
  116. title: res.message,
  117. icon: "none",
  118. duration: 1500
  119. })
  120. }
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss">
  126. page {
  127. background-color: #fff;
  128. }
  129. .main {}
  130. </style>