|
|
@@ -10,7 +10,7 @@ const tel = ref('')
|
|
|
const address = ref('')
|
|
|
const password = ref('')
|
|
|
const confirmPassword = ref('')
|
|
|
-const storeId = ref()
|
|
|
+const storeId = ref(null)
|
|
|
|
|
|
// 电话号码是否为空
|
|
|
const hasTelInput = computed(() => tel.value != '')
|
|
|
@@ -22,6 +22,8 @@ const hasConfirmPasswordInput = computed(() => confirmPassword.value != '')
|
|
|
const hasAddressInput = computed(() => address.value != '')
|
|
|
// 身份是否为空
|
|
|
const hasIdentityChosen = computed(() => identity.value != '')
|
|
|
+// 对于商家用户,商店Id是否为空
|
|
|
+const hasStoreId = computed(() => storeId.value != '')
|
|
|
// 电话号码的规则
|
|
|
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))
|
|
|
@@ -29,10 +31,27 @@ const telLegal = computed(() => chinaMobileRegex.test(tel.value))
|
|
|
const isPasswordIdentical = computed(() => password.value == confirmPassword.value)
|
|
|
// 注册按钮可用性
|
|
|
const registerDisabled = computed(() => {
|
|
|
- return !(hasTelInput.value && hasPasswordInput.value && hasConfirmPasswordInput && hasAddressInput.value &&
|
|
|
- hasIdentityChosen.value && telLegal.value && isPasswordIdentical.value)
|
|
|
+ if (!hasIdentityChosen.value) {
|
|
|
+ return true
|
|
|
+ } else if (identity.value === 'CUSTOMER') {
|
|
|
+ return !(hasTelInput.value && hasPasswordInput.value && hasConfirmPasswordInput && hasAddressInput.value &&
|
|
|
+ telLegal.value && isPasswordIdentical.value)
|
|
|
+ } else if (identity.value === 'STAFF') {
|
|
|
+ return !(hasTelInput.value && hasPasswordInput.value && hasConfirmPasswordInput && hasAddressInput.value &&
|
|
|
+ hasStoreId.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({
|
|
|
@@ -49,6 +68,7 @@ function handleRegister() {
|
|
|
type: 'success',
|
|
|
center: true,
|
|
|
})
|
|
|
+ storeId.value = null
|
|
|
router.push({path: "/login"})
|
|
|
} else if (res.data.code === '400') {
|
|
|
ElMessage({
|
|
|
@@ -59,10 +79,6 @@ function handleRegister() {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
-// const storeList = await getAllStore().then(res => res.data.result)
|
|
|
-
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
|
|
|
@@ -90,6 +106,7 @@ function handleRegister() {
|
|
|
<label for="identity">身份</label>
|
|
|
<el-select id="identity"
|
|
|
v-model="identity"
|
|
|
+ @change="identityChange()"
|
|
|
placeholder="请选择"
|
|
|
style="width: 100%;"
|
|
|
>
|
|
|
@@ -149,11 +166,11 @@ function handleRegister() {
|
|
|
<el-col :span="7" v-if="identity==='STAFF'">
|
|
|
<el-form-item>
|
|
|
<label for="address">
|
|
|
- 所属商店
|
|
|
+ 所属商店(需待Lab2中完善)
|
|
|
</label>
|
|
|
<el-input id="storeId"
|
|
|
v-model="storeId"
|
|
|
- placeholder="请输入商店编号"/>
|
|
|
+ placeholder="请填入商店Id"/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|