editphone.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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="">
  24. 立即保存
  25. </view>
  26. </view>
  27. <view class="cu-tabbar-height"></view>
  28. <view class="cu-tabbar-height"></view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. onLoad(options) {
  34. },
  35. mounted() {
  36. },
  37. data() {
  38. return {
  39. value: '',
  40. newphone: "",
  41. newcode: "",
  42. type: 'number',
  43. border: true,
  44. tips: '',
  45. newtips: "",
  46. seconds: 60,
  47. newseconds: 60
  48. }
  49. },
  50. methods: {
  51. codeChange(text) {
  52. this.tips = text;
  53. },
  54. codeChange1(text) {
  55. this.newtips = text;
  56. },
  57. getCode() {
  58. if (this.$refs.uCode.canGetCode) {
  59. // 模拟向后端请求验证码
  60. uni.showLoading({
  61. title: '正在获取验证码'
  62. })
  63. setTimeout(() => {
  64. uni.hideLoading();
  65. // 这里此提示会被this.start()方法中的提示覆盖
  66. uni.showToast({
  67. title: "验证码已发送",
  68. icon: "none"
  69. })
  70. // 通知验证码组件内部开始倒计时
  71. this.$refs.uCode.start();
  72. }, 2000);
  73. } else {
  74. uni.showToast({
  75. title: "结束后再发送",
  76. icon: "none"
  77. })
  78. }
  79. },
  80. getnewCode() {
  81. if (this.$refs.newuCode.canGetCode) {
  82. // 模拟向后端请求验证码
  83. uni.showLoading({
  84. title: '正在获取验证码'
  85. })
  86. setTimeout(() => {
  87. uni.hideLoading();
  88. // 这里此提示会被this.start()方法中的提示覆盖
  89. uni.showToast({
  90. title: "验证码已发送",
  91. icon: "none"
  92. })
  93. // 通知验证码组件内部开始倒计时
  94. this.$refs.newuCode.start();
  95. }, 2000);
  96. } else {
  97. uni.showToast({
  98. title: "结束后再发送",
  99. icon: "none"
  100. })
  101. }
  102. },
  103. end() {
  104. uni.showToast({
  105. title: "倒计时结束",
  106. icon: "none"
  107. })
  108. },
  109. start() {
  110. uni.showToast({
  111. title: "倒计时开始",
  112. icon: "none"
  113. })
  114. },
  115. newend() {
  116. uni.showToast({
  117. title: "倒计时结束",
  118. icon: "none"
  119. })
  120. },
  121. newstart() {
  122. uni.showToast({
  123. title: "倒计时开始",
  124. icon: "none"
  125. })
  126. }
  127. }
  128. };
  129. </script>
  130. <style scoped lang="scss">
  131. .main {}
  132. </style>