WXL
20 小时以前 888f941ae16c850c0f1a844ec9436058840920bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
    <view class="container">
        <view class="form-box">
            <view class="form-title">用户注册</view>
            <input v-model="form.username" placeholder="请输入用户名" class="input" />
            <input v-model="form.password" type="password" placeholder="请输入密码" class="input" />
            <input v-model="form.confirm" type="password" placeholder="确认密码" class="input" />
            <button class="register-btn" @click="register">注 册</button>
        </view>
    </view>
</template>
 
 
<script setup>
    import {
        ref
    } from 'vue'
 
    const form = ref({
        username: '',
        password: '',
        confirm: ''
    })
 
    const register = async () => {
        if (form.value.password !== form.value.confirm) {
            return uni.showToast({
                title: '两次密码不一致',
                icon: 'none'
            })
        }
        const res = await uni.request({
            url: 'https://api.xxx.com/register',
            method: 'POST',
            data: form.value
        })
        if (res.data.code === 200) {
            uni.showToast({
                title: '注册成功',
                icon: 'success'
            })
            setTimeout(() => uni.redirectTo({
                url: '/pages/login'
            }), 1000)
        } else {
            uni.showToast({
                title: res.data.message,
                icon: 'none'
            })
        }
    }
</script>
 
 
<style scoped>
    .container {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        background: linear-gradient(to bottom right, #e6f7ff, #ffffff);
        padding: 40rpx;
        box-sizing: border-box;
    }
 
    .form-box {
        width: 100%;
        max-width: 600rpx;
        background-color: #fff;
        padding: 60rpx 40rpx;
        border-radius: 24rpx;
        box-shadow: 0 12rpx 32rpx rgba(0, 0, 0, 0.1);
    }
 
    .form-title {
        text-align: center;
        font-size: 40rpx;
        font-weight: bold;
        margin-bottom: 40rpx;
        color: #333;
    }
 
    .input {
        width: 100%;
        padding: 40rpx;
        margin-bottom: 32rpx;
        border: 1rpx solid #ccc;
        border-radius: 16rpx;
        font-size: 30rpx;
        background-color: #f9f9f9;
        box-sizing: border-box;
        transition: all 0.3s ease;
    }
 
    .input:focus {
        border-color: #1890ff;
        background-color: #fff;
        outline: none;
    }
 
    .register-btn {
        width: 100%;
        padding: 20rpx 0;
        font-size: 32rpx;
        color: #fff;
        background: linear-gradient(to right, #36d1dc, #5b86e5);
        border: none;
        border-radius: 50rpx;
        box-shadow: 0 8rpx 20rpx rgba(91, 134, 229, 0.3);
        transition: all 0.2s ease-in-out;
    }
 
    .register-btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }
</style>