editUserPhone.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="pages">
  3. <div class="input-back">
  4. <u--input placeholder="手机号码" :customStyle="{height: '40px'}" border="surround" v-model="value" @change="change"></u--input>
  5. <u-input placeholder="后置插槽" :customStyle="{height: '40px'}">
  6. <template slot="suffix">
  7. <u-code ref="uCode" @change="codeChange" seconds="20" changeText="X秒重新获取"></u-code>
  8. <u-button @tap="getCode" :text="tips" type="primary" size=""></u-button>
  9. </template>
  10. </u-input>
  11. </div>
  12. <div class="save-btn">
  13. <u-button type="primary">保存</u-button>
  14. </div>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. value: '',
  22. tips: '获取验证码'
  23. };
  24. },
  25. methods: {
  26. change() {
  27. console.log(this.value);
  28. },
  29. codeChange(text) {
  30. console.log('codeChange');
  31. this.tips = text
  32. },
  33. getCode() {
  34. if (this.$refs.uCode.canGetCode) {
  35. // 模拟向后端请求验证码
  36. uni.showLoading({
  37. title: '正在获取验证码'
  38. })
  39. setTimeout(() => {
  40. uni.hideLoading();
  41. // 这里此提示会被this.start()方法中的提示覆盖
  42. uni.$u.toast('验证码已发送');
  43. // 通知验证码组件内部开始倒计时
  44. this.$refs.uCode.start();
  45. }, 2000);
  46. } else {
  47. uni.$u.toast('倒计时结束后再发送');
  48. }
  49. },
  50. }
  51. }
  52. </script>
  53. <style lang="scss">
  54. .pages {
  55. background: #f5f5f5;
  56. width: 100vw;
  57. height: 100vh;
  58. }
  59. .input-back {
  60. width: 100%;
  61. // height: 100px;
  62. background: #fff;
  63. }
  64. .save-btn {
  65. text-align: center;
  66. // margin-top:20px;
  67. position: fixed;
  68. bottom: 0;
  69. width: 100%;
  70. padding: 30px;
  71. box-sizing: border-box;
  72. }
  73. </style>