refactor login page and add user avatar to header
This commit is contained in:
@@ -33,7 +33,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isOpenForm: false,
|
isOpenForm: false,
|
||||||
updatedClients: false,
|
updatedClients: false,
|
||||||
url: "https://astra-dev.dopcore.com",
|
url: "https://astra-dev.dopcore.com/api/store/",
|
||||||
createdClientId: "",
|
createdClientId: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,9 +34,9 @@
|
|||||||
padding="0",
|
padding="0",
|
||||||
style="color: var(--font-grey-color)"
|
style="color: var(--font-grey-color)"
|
||||||
)
|
)
|
||||||
base-avatar(:size="36", :color="userData?.color", v-if="!userData?.photo") {{changeName}}
|
base-avatar(:size="36", :color="userData?.color", v-if="!userData?.avatar") {{changeName}}
|
||||||
base-avatar(:size="32", v-else)
|
base-avatar(:size="32", v-else)
|
||||||
img.h-full.object-cover(:src="url + userData?.photo", alt="Avatar")
|
img.h-full.object-cover(:src="url + userData?.avatar", alt="Avatar")
|
||||||
.h-6.w-6.flex.items-center.justify-center.ml-1.pt-1
|
.h-6.w-6.flex.items-center.justify-center.ml-1.pt-1
|
||||||
q-icon.arrow(name="app:down-arrow", size="24px")
|
q-icon.arrow(name="app:down-arrow", size="24px")
|
||||||
q-menu(
|
q-menu(
|
||||||
@@ -104,8 +104,8 @@ export default {
|
|||||||
redirectHomePage() {
|
redirectHomePage() {
|
||||||
this.$router.push("/calendar");
|
this.$router.push("/calendar");
|
||||||
},
|
},
|
||||||
logout() {
|
async logout() {
|
||||||
localStorage.removeItem("tokenAccess");
|
await fetchWrapper.post("auth/logout");
|
||||||
this.$router.go("/login");
|
this.$router.go("/login");
|
||||||
},
|
},
|
||||||
openPopup() {
|
openPopup() {
|
||||||
|
|||||||
@@ -24,11 +24,14 @@
|
|||||||
:shadow-text="shadowText",
|
:shadow-text="shadowText",
|
||||||
:autofocus="autofocus",
|
:autofocus="autofocus",
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
|
:error="error"
|
||||||
)
|
)
|
||||||
template(v-slot:prepend, v-if="iconLeft")
|
template(v-slot:prepend, v-if="iconLeft")
|
||||||
slot(name="iconLeft")
|
slot(name="iconLeft")
|
||||||
template(v-slot:append, v-if="iconRight")
|
template(v-slot:append, v-if="iconRight")
|
||||||
slot(name="iconRight")
|
slot(name="iconRight")
|
||||||
|
template(#error v-if="error")
|
||||||
|
slot(name="error")
|
||||||
slot(v-if="!iconLeft && !iconRight")
|
slot(v-if="!iconLeft && !iconRight")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -80,6 +83,7 @@ export default {
|
|||||||
size: String,
|
size: String,
|
||||||
circle: Boolean,
|
circle: Boolean,
|
||||||
height: String,
|
height: String,
|
||||||
|
error: Boolean,
|
||||||
},
|
},
|
||||||
emits: ["update:modelValue"],
|
emits: ["update:modelValue"],
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -12,28 +12,33 @@
|
|||||||
.flex.flex-col.gap-y-5
|
.flex.flex-col.gap-y-5
|
||||||
.flex.flex-col.gap-y-px
|
.flex.flex-col.gap-y-px
|
||||||
base-input.blue-color(
|
base-input.blue-color(
|
||||||
:rule="[wrongData => !!wrongData || 'Этого телефона нет в системе']",
|
:error="authError"
|
||||||
v-model="user.username",
|
v-model="user.username",
|
||||||
placeholder="+7 (915) 224–21–31",
|
placeholder="+7 (915) 224–21–31",
|
||||||
label="Номер телефона",
|
label="Номер телефона",
|
||||||
size="L"
|
size="L"
|
||||||
|
@keypress.enter="login"
|
||||||
)
|
)
|
||||||
|
template(#error) Этого телефона нет в системе
|
||||||
.flex.flex-col.gap-y-px
|
.flex.flex-col.gap-y-px
|
||||||
base-input.blue-color(
|
base-input.blue-color(
|
||||||
:rule="[wrongData => !!wrongData || 'Неверный пароль']",
|
:error="authError"
|
||||||
v-model="user.password",
|
v-model="user.password",
|
||||||
:type="changeType",
|
:type="passwordInputType",
|
||||||
placeholder="Введите ваш пароль",
|
placeholder="Введите ваш пароль",
|
||||||
label="Пароль",
|
label="Пароль",
|
||||||
size="L"
|
size="L"
|
||||||
|
@keypress.enter="login"
|
||||||
)
|
)
|
||||||
.flex.items-center.cursor-pointer(@click="changeView", v-if="!wrongData && user.password")
|
.flex.items-center.cursor-pointer(@click="changePasswordInputType", v-if="user.password")
|
||||||
img(:src="!isView ? eye_close : eye_open")
|
q-icon(name="app:eye" v-if="showPassword")
|
||||||
.flex.items-center.gap-x-8px.-ml-2
|
q-icon(name="app:eye-open" v-else)
|
||||||
q-checkbox(v-model="person", type="checkbox")
|
template(#error) Неверный логин или пароль
|
||||||
.flex.non-italic.font-medium.base Запомнить меня
|
.flex.items-center.-ml-2
|
||||||
|
q-checkbox(v-model="rememberMe", type="checkbox")
|
||||||
|
.font-medium.base Запомнить меня
|
||||||
base-button(
|
base-button(
|
||||||
:disable="disabledButton",
|
:disable="canPressLoginButton",
|
||||||
label="Войти в аккаунт",
|
label="Войти в аккаунт",
|
||||||
size="L",
|
size="L",
|
||||||
@click="login",
|
@click="login",
|
||||||
@@ -46,8 +51,6 @@
|
|||||||
import { fetchWrapper } from "@/shared/fetchWrapper";
|
import { fetchWrapper } from "@/shared/fetchWrapper";
|
||||||
import logoMark from "@/assets/images/logoMark.svg";
|
import logoMark from "@/assets/images/logoMark.svg";
|
||||||
import BaseButton from "@/components/base/BaseButton.vue";
|
import BaseButton from "@/components/base/BaseButton.vue";
|
||||||
import eye_open from "@/assets/icons/eye_open.svg";
|
|
||||||
import eye_close from "@/assets/icons/eye_close.svg";
|
|
||||||
import BaseInput from "@/components/base/BaseInput.vue";
|
import BaseInput from "@/components/base/BaseInput.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -55,36 +58,26 @@ export default {
|
|||||||
components: { BaseInput, BaseButton },
|
components: { BaseInput, BaseButton },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isView: false,
|
showPassword: false,
|
||||||
logoMark,
|
logoMark,
|
||||||
eye_close,
|
|
||||||
eye_open,
|
|
||||||
authorized: true,
|
authorized: true,
|
||||||
user: {},
|
user: {},
|
||||||
userData: {},
|
userData: {},
|
||||||
person: false,
|
rememberMe: false,
|
||||||
|
authError: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
wrongData() {
|
passwordInputType() {
|
||||||
return !this.authorized;
|
return !this.showPassword ? "password" : "text";
|
||||||
},
|
},
|
||||||
changeType() {
|
canPressLoginButton() {
|
||||||
return !this.isView ? "password" : "text";
|
|
||||||
},
|
|
||||||
disabledButton() {
|
|
||||||
return !(this.user.username && this.user.password);
|
return !(this.user.username && this.user.password);
|
||||||
},
|
},
|
||||||
showBorder() {
|
|
||||||
return !this.authorized && !this.user.username && !this.user.password;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeView() {
|
changePasswordInputType() {
|
||||||
this.isView = !this.isView;
|
this.showPassword = !this.showPassword;
|
||||||
},
|
|
||||||
async auth() {
|
|
||||||
this.userData = await fetchWrapper.get("users/me");
|
|
||||||
},
|
},
|
||||||
login() {
|
login() {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
@@ -92,14 +85,9 @@ export default {
|
|||||||
user_name: this.user.username,
|
user_name: this.user.username,
|
||||||
password: this.user.password,
|
password: this.user.password,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then((data) => {
|
||||||
this.auth().then(() => this.$router.push("/"));
|
if (!data) this.authError = true;
|
||||||
})
|
else this.$router.push("/");
|
||||||
.catch(() => {
|
|
||||||
this.authorized = false;
|
|
||||||
this.user.username = "";
|
|
||||||
this.user.password = "";
|
|
||||||
this.$router.push("/login");
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user