updateTel.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="container">
  3. <view class="form-box">
  4. <u-form :model="formData.form" ref="formRef" label-width="120" :label-style="{fontWeight: 'bold', fontSize: '26rpx'}">
  5. <u-form-item prop="phone">
  6. <u-input v-model="formData.form.phone" :border="true" type="text" placeholder="请输入更换绑定手机号"/>
  7. </u-form-item>
  8. <u-form-item prop="code">
  9. <view class="input-code">
  10. <view class="input">
  11. <u-input v-model="formData.form.code" :border="true" type="text" placeholder="请输入验证码"/>
  12. </view>
  13. <view class="btn">
  14. <text class="form-item-text" @click="getCode">{{tips}}</text>
  15. </view>
  16. </view>
  17. </u-form-item>
  18. </u-form>
  19. </view>
  20. <view class="bottom-box">
  21. <u-button type="primary" shape="circle" @click="onSubmit">立即更换并登录</u-button>
  22. </view>
  23. </view>
  24. </template>
  25. <script setup>
  26. import { ref, reactive } from 'vue'
  27. import { onLoad, onReady } from '@dcloudio/uni-app'
  28. const formRef = ref()
  29. const formData = reactive({
  30. form: {
  31. phone: null,
  32. code: null
  33. },
  34. rules: {
  35. phone: [
  36. {
  37. required: true,
  38. message: '请输入更换绑定手机号',
  39. // 可以单个或者同时写两个触发验证方式
  40. trigger: 'blur',
  41. }
  42. ],
  43. code: [
  44. {
  45. required: true,
  46. message: '请输入验证码',
  47. // 可以单个或者同时写两个触发验证方式
  48. trigger: 'blur',
  49. }
  50. ],
  51. }
  52. })
  53. const tips = ref('获取验证码') // 59秒重新获取
  54. function onSubmit() {
  55. formRef.value.validate((valid) => {
  56. if (valid) {
  57. // 提交
  58. }
  59. })
  60. }
  61. onReady(() => {
  62. formRef.value.setRules(formData.rules)
  63. })
  64. </script>
  65. <style lang="scss" scoped>
  66. .container {
  67. height: 100vh;
  68. width: 100vw;
  69. background-color: $uni-bg-color;
  70. padding: 20rpx;
  71. .form-box {
  72. padding: 20rpx 0;
  73. .input-code {
  74. display: flex;
  75. align-items: center;
  76. gap: 20rpx;
  77. .input {
  78. width: 70%;
  79. }
  80. .btn {
  81. width: 30%;
  82. text-align: center;
  83. }
  84. }
  85. }
  86. .bottom-box {
  87. margin-top: 50rpx;
  88. padding: 0 50rpx;
  89. }
  90. }
  91. </style>