|
|
@@ -1,7 +1,8 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ref, computed } from 'vue';
|
|
|
- import axios from "axios";
|
|
|
import {router} from '../router'
|
|
|
+ import {userRegister} from "../api/user.ts";
|
|
|
+
|
|
|
|
|
|
|
|
|
const name = ref('')
|
|
|
@@ -32,42 +33,49 @@
|
|
|
});
|
|
|
|
|
|
|
|
|
- // POST /api/user/register
|
|
|
- // body
|
|
|
- // id
|
|
|
- // role
|
|
|
- // name
|
|
|
- // phone
|
|
|
- // password
|
|
|
- // storeid
|
|
|
- // address
|
|
|
- // time
|
|
|
- // response
|
|
|
- // success: boolean
|
|
|
async function handleRegister() {
|
|
|
-
|
|
|
- try{
|
|
|
- const res = axios.post('/user/register', {
|
|
|
- role: identity.value,
|
|
|
- name: name.value,
|
|
|
- phone: tel.value,
|
|
|
- password: password.value,
|
|
|
- address: address.value,
|
|
|
- createTime: new Date().getTime()
|
|
|
- }, {
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- //todo: 弹窗提示一下成功
|
|
|
- // 路由跳转
|
|
|
- router.push({ path: "/login" })
|
|
|
-
|
|
|
- } catch (e) {
|
|
|
- //todo: 弹窗提示一下错误
|
|
|
- console.log(e)
|
|
|
+ const payload = {
|
|
|
+ role: identity.value,
|
|
|
+ name: name.value,
|
|
|
+ phone: tel.value,
|
|
|
+ password: password.value,
|
|
|
+ address: address.value,
|
|
|
+ createTime: new Date().getTime()
|
|
|
}
|
|
|
+
|
|
|
+ userRegister(payload)
|
|
|
+ .then(res => {
|
|
|
+ ElMessageBox.alert(
|
|
|
+ `${name.value},感谢您的注册!`,
|
|
|
+ '注册成功',
|
|
|
+ {
|
|
|
+ customClass: "customDialog",
|
|
|
+ confirmButtonText: '跳转到登录',
|
|
|
+ type: "success",
|
|
|
+ showClose: false,
|
|
|
+ roundButton: true,
|
|
|
+ center: true
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ // 跳转去登录
|
|
|
+ router.push({ path: "/login" })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ console.log(e)
|
|
|
+ ElMessageBox.alert(
|
|
|
+ e.message,
|
|
|
+ '错误提示',
|
|
|
+ {
|
|
|
+ customClass: "customDialog",
|
|
|
+ confirmButtonText: '好的',
|
|
|
+ type: "error",
|
|
|
+ showClose: false,
|
|
|
+ roundButton: true,
|
|
|
+ center: true
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -227,6 +235,15 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
+<style>
|
|
|
+
|
|
|
+.customDialog {
|
|
|
+ @apply w-1/4 space-y-5 text-4xl font-semibold rounded-2xl pb-5 pt-2
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|
|
|
+
|
|
|
+
|
|
|
<style scoped>
|
|
|
|
|
|
</style>
|