1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <template>
- <view class="container">
- <view class="form-box">
- <u-form :model="formData.form" ref="formRef" label-width="120" :label-style="{fontWeight: 'bold', fontSize: '26rpx'}">
- <u-form-item prop="phone">
- <u-input v-model="formData.form.phone" :border="true" type="text" placeholder="请输入更换绑定手机号"/>
- </u-form-item>
- <u-form-item prop="code">
- <view class="input-code">
- <view class="input">
- <u-input v-model="formData.form.code" :border="true" type="text" placeholder="请输入验证码"/>
- </view>
- <view class="btn">
- <text class="form-item-text" @click="getCode">{{tips}}</text>
- </view>
- </view>
- </u-form-item>
- </u-form>
- </view>
- <view class="bottom-box">
- <u-button type="primary" shape="circle" @click="onSubmit">立即更换并登录</u-button>
- </view>
- </view>
- </template>
- <script setup>
- import { ref, reactive } from 'vue'
- import { onLoad, onReady } from '@dcloudio/uni-app'
-
- const formRef = ref()
- const formData = reactive({
- form: {
- phone: null,
- code: null
- },
- rules: {
- phone: [
- {
- required: true,
- message: '请输入更换绑定手机号',
- // 可以单个或者同时写两个触发验证方式
- trigger: 'blur',
- }
- ],
- code: [
- {
- required: true,
- message: '请输入验证码',
- // 可以单个或者同时写两个触发验证方式
- trigger: 'blur',
- }
- ],
- }
- })
- const tips = ref('获取验证码') // 59秒重新获取
-
- function onSubmit() {
- formRef.value.validate((valid) => {
- if (valid) {
- // 提交
- }
- })
- }
-
- onReady(() => {
- formRef.value.setRules(formData.rules)
- })
- </script>
- <style lang="scss" scoped>
- .container {
- height: 100vh;
- width: 100vw;
- background-color: $uni-bg-color;
- padding: 20rpx;
-
- .form-box {
- padding: 20rpx 0;
-
- .input-code {
- display: flex;
- align-items: center;
- gap: 20rpx;
- .input {
- width: 70%;
- }
- .btn {
- width: 30%;
- text-align: center;
- }
- }
- }
- .bottom-box {
- margin-top: 50rpx;
- padding: 0 50rpx;
- }
- }
- </style>
|