|
@@ -3,18 +3,24 @@
|
|
|
import axios from "axios";
|
|
import axios from "axios";
|
|
|
import {router} from '../router'
|
|
import {router} from '../router'
|
|
|
|
|
|
|
|
|
|
+
|
|
|
const name = ref('')
|
|
const name = ref('')
|
|
|
|
|
+ const identity = ref('')
|
|
|
const tel = ref('')
|
|
const tel = ref('')
|
|
|
|
|
+ const address = ref('')
|
|
|
const password = ref('')
|
|
const password = ref('')
|
|
|
const confirmPassword = ref('')
|
|
const confirmPassword = ref('')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
// const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
|
const chinaMobileRegex = /^1(3[0-9]|4[579]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[189])\d{8}$/;
|
|
const chinaMobileRegex = /^1(3[0-9]|4[579]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[189])\d{8}$/;
|
|
|
|
|
|
|
|
const hasTelInput = computed(() => tel.value != '');
|
|
const hasTelInput = computed(() => tel.value != '');
|
|
|
const hasPasswordInput = computed(() => password.value != '');
|
|
const hasPasswordInput = computed(() => password.value != '');
|
|
|
const hasConfirmPasswordInput = computed(() => confirmPassword.value != '');
|
|
const hasConfirmPasswordInput = computed(() => confirmPassword.value != '');
|
|
|
|
|
+ const hasAddressInput = computed(() => address.value != '');
|
|
|
|
|
+ const hasIdentityChosen = computed(() => identity.value != '')
|
|
|
|
|
|
|
|
|
|
|
|
|
const telLegal = computed(() => chinaMobileRegex.test(tel.value));
|
|
const telLegal = computed(() => chinaMobileRegex.test(tel.value));
|
|
@@ -22,10 +28,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
const registerDisabled = computed(() => {
|
|
const registerDisabled = computed(() => {
|
|
|
-
|
|
|
|
|
- return !(telLegal.value && hasPasswordInput.value && isPasswordIdentical.value)
|
|
|
|
|
|
|
+ return !(telLegal.value && hasPasswordInput.value && isPasswordIdentical.value && hasAddressInput.value && hasIdentityChosen.value)
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// POST /api/user/register
|
|
// POST /api/user/register
|
|
|
// body
|
|
// body
|
|
|
// id
|
|
// id
|
|
@@ -39,12 +45,15 @@
|
|
|
// response
|
|
// response
|
|
|
// success: boolean
|
|
// success: boolean
|
|
|
async function handleRegister() {
|
|
async function handleRegister() {
|
|
|
|
|
+
|
|
|
try{
|
|
try{
|
|
|
const res = axios.post('/user/register', {
|
|
const res = axios.post('/user/register', {
|
|
|
|
|
+ role: identity.value,
|
|
|
name: name.value,
|
|
name: name.value,
|
|
|
phone: tel.value,
|
|
phone: tel.value,
|
|
|
password: password.value,
|
|
password: password.value,
|
|
|
- time: new Date().getTime()
|
|
|
|
|
|
|
+ address: address.value,
|
|
|
|
|
+ createTime: new Date().getTime()
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
|
'Content-Type': 'application/json'
|
|
'Content-Type': 'application/json'
|
|
@@ -56,8 +65,9 @@
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.log(e)
|
|
console.log(e)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -67,7 +77,7 @@
|
|
|
Blue Whale Shopping Online
|
|
Blue Whale Shopping Online
|
|
|
</span>
|
|
</span>
|
|
|
|
|
|
|
|
- <el-card class="w-full bg-white rounded-lg shadow-md md:mt-0 sm:max-w-md xl:p-0">
|
|
|
|
|
|
|
+ <el-card class="w-2/3 bg-white rounded-lg shadow-md md:mt-0 xl:p-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
|
|
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
|
|
@@ -76,36 +86,80 @@
|
|
|
创建一个新的账户
|
|
创建一个新的账户
|
|
|
</h1>
|
|
</h1>
|
|
|
|
|
|
|
|
- <el-form class="space-y-4 md:space-y-6">
|
|
|
|
|
|
|
+ <el-form class="space-y-6">
|
|
|
|
|
+
|
|
|
|
|
+ <el-row class="flex flex-row justify-between">
|
|
|
|
|
+
|
|
|
|
|
+ <el-col :span="15">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <label for="name" class="block mb-2 text-sm font-medium text-gray-900">昵称</label>
|
|
|
|
|
+ <input id="name"
|
|
|
|
|
+ v-model="name"
|
|
|
|
|
+ class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5"
|
|
|
|
|
+ placeholder="小明">
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <el-col :span="8">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <label for="identity" class="block mb-2 text-sm font-medium text-gray-900">身份</label>
|
|
|
|
|
+ <select id="identity"
|
|
|
|
|
+ v-model="identity"
|
|
|
|
|
+ class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
|
|
|
|
|
+ <option disabled value="" selected>请选择</option>
|
|
|
|
|
+ <option value="CUSTOMER">顾客</option>
|
|
|
|
|
+ <option value="STAFF">商家</option>
|
|
|
|
|
+ </select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <el-row class="flex justify-between">
|
|
|
|
|
+ <el-col :span="8">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <!-- <label for="tel" class="block mb-2 text-sm font-medium text-gray-900">手机号</label>-->
|
|
|
|
|
+
|
|
|
|
|
+ <label v-if="!hasTelInput" for="tel" class="inline-block mb-2 text-sm font-medium text-gray-900">
|
|
|
|
|
+ 注册手机号
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <label v-else-if="!telLegal" for="tel"
|
|
|
|
|
+ class="inline-block mb-2 font-medium text-red-500 text-sm">
|
|
|
|
|
+ 手机号不合法
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <label v-else for="tel" class="inline-block mb-2 text-sm font-medium text-gray-900">
|
|
|
|
|
+ 注册手机号
|
|
|
|
|
+ </label>
|
|
|
|
|
+
|
|
|
|
|
+ <input type="tel" id="tel"
|
|
|
|
|
+ v-model="tel"
|
|
|
|
|
+ class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5"
|
|
|
|
|
+ :class="{'focus:outline-red-600':hasTelInput && !telLegal}"
|
|
|
|
|
+ placeholder="请输入中国大陆手机号">
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+
|
|
|
|
|
+ <el-col :span="15">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <!-- <label for="tel" class="block mb-2 text-sm font-medium text-gray-900">手机号</label>-->
|
|
|
|
|
+
|
|
|
|
|
+ <label for="address" class="inline-block mb-2 text-sm font-medium text-gray-900">
|
|
|
|
|
+ 地址
|
|
|
|
|
+ </label>
|
|
|
|
|
+
|
|
|
|
|
+ <input id="address"
|
|
|
|
|
+ v-model="address"
|
|
|
|
|
+ class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5"
|
|
|
|
|
+ placeholder="请输入地址">
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- <el-form-item>
|
|
|
|
|
- <label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">昵称</label>
|
|
|
|
|
- <input id="name"
|
|
|
|
|
- v-model="name"
|
|
|
|
|
- class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5"
|
|
|
|
|
- placeholder="小明">
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
|
|
|
|
|
- <el-form-item>
|
|
|
|
|
-<!-- <label for="tel" class="block mb-2 text-sm font-medium text-gray-900">手机号</label>-->
|
|
|
|
|
-
|
|
|
|
|
- <label v-if="!hasTelInput" for="tel" class="inline-block mb-2 text-sm font-medium text-gray-900">
|
|
|
|
|
- 注册手机号
|
|
|
|
|
- </label>
|
|
|
|
|
- <label v-else-if="!telLegal" for="tel"
|
|
|
|
|
- class="inline-block mb-2 font-medium text-red-500 text-sm">
|
|
|
|
|
- 手机号不合法
|
|
|
|
|
- </label>
|
|
|
|
|
- <label v-else for="tel" class="inline-block mb-2 text-sm font-medium text-gray-900">
|
|
|
|
|
- 注册手机号
|
|
|
|
|
- </label>
|
|
|
|
|
-
|
|
|
|
|
- <input type="tel" id="tel"
|
|
|
|
|
- v-model="tel"
|
|
|
|
|
- class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5"
|
|
|
|
|
- :class="{'focus:outline-red-600':hasTelInput && !telLegal}"
|
|
|
|
|
- placeholder="请输入中国大陆手机号">
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item>
|
|
<el-form-item>
|
|
|
<label for="password" class="block mb-2 text-sm font-medium text-gray-900">密码</label>
|
|
<label for="password" class="block mb-2 text-sm font-medium text-gray-900">密码</label>
|