|
|
@@ -10,7 +10,9 @@ const tel = ref('')
|
|
|
const address = ref('')
|
|
|
const password = ref('')
|
|
|
const confirmPassword = ref('')
|
|
|
-const storeId = ref(null)
|
|
|
+
|
|
|
+//对于商家用户,还需要在注册时选择所属商店,从而传入storeId。但由于Lab2才会开发商店模块,所以这里暂且设置一个Id为1的商店,待Lab2完善
|
|
|
+const storeId = ref<number>()
|
|
|
|
|
|
// 电话号码是否为空
|
|
|
const hasTelInput = computed(() => tel.value != '')
|
|
|
@@ -23,7 +25,7 @@ const hasAddressInput = computed(() => address.value != '')
|
|
|
// 身份是否为空
|
|
|
const hasIdentityChosen = computed(() => identity.value != '')
|
|
|
// 对于商家用户,商店Id是否为空
|
|
|
-const hasStoreId = computed(() => storeId.value != '')
|
|
|
+const hasStoreName = computed(() => storeId.value != undefined)
|
|
|
// 电话号码的规则
|
|
|
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 telLegal = computed(() => chinaMobileRegex.test(tel.value))
|
|
|
@@ -33,25 +35,15 @@ const isPasswordIdentical = computed(() => password.value == confirmPassword.val
|
|
|
const registerDisabled = computed(() => {
|
|
|
if (!hasIdentityChosen.value) {
|
|
|
return true
|
|
|
- } else if (identity.value === 'CUSTOMER') {
|
|
|
+ } else if (identity.value == 'CUSTOMER') {
|
|
|
return !(hasTelInput.value && hasPasswordInput.value && hasConfirmPasswordInput && hasAddressInput.value &&
|
|
|
telLegal.value && isPasswordIdentical.value)
|
|
|
- } else if (identity.value === 'STAFF') {
|
|
|
+ } else if (identity.value == 'STAFF') {
|
|
|
return !(hasTelInput.value && hasPasswordInput.value && hasConfirmPasswordInput && hasAddressInput.value &&
|
|
|
- hasStoreId.value && telLegal.value && isPasswordIdentical.value)
|
|
|
+ hasStoreName.value && telLegal.value && isPasswordIdentical.value)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-function identityChange() {
|
|
|
- if (identity.value === 'STAFF') {
|
|
|
- storeId.value = 1 //对于商家用户,可以暂且将所属商店Id硬编码为1,这会待Lab2开发商店模块时进行完善
|
|
|
- } else if (identity.value === 'CUSTOMER') {
|
|
|
- storeId.value = null
|
|
|
- }
|
|
|
- console.log(storeId.value)
|
|
|
- console.log(typeof storeId.value)
|
|
|
-}
|
|
|
-
|
|
|
// 注册按钮触发
|
|
|
function handleRegister() {
|
|
|
userRegister({
|
|
|
@@ -68,7 +60,7 @@ function handleRegister() {
|
|
|
type: 'success',
|
|
|
center: true,
|
|
|
})
|
|
|
- storeId.value = null
|
|
|
+ storeId.value = undefined
|
|
|
router.push({path: "/login"})
|
|
|
} else if (res.data.code === '400') {
|
|
|
ElMessage({
|
|
|
@@ -106,7 +98,6 @@ function handleRegister() {
|
|
|
<label for="identity">身份</label>
|
|
|
<el-select id="identity"
|
|
|
v-model="identity"
|
|
|
- @change="identityChange()"
|
|
|
placeholder="请选择"
|
|
|
style="width: 100%;"
|
|
|
>
|
|
|
@@ -168,13 +159,16 @@ function handleRegister() {
|
|
|
<label for="address">
|
|
|
所属商店(需待Lab2中完善)
|
|
|
</label>
|
|
|
- <el-input id="storeId"
|
|
|
- v-model="storeId"
|
|
|
- placeholder="请填入商店Id"/>
|
|
|
+ <el-select id="storeName"
|
|
|
+ v-model="storeId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%;"
|
|
|
+ >
|
|
|
+ <el-option value="1" label="商店"/>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
-
|
|
|
</el-row>
|
|
|
|
|
|
<el-form-item>
|