From c047a3336ff1efc7d21edee6f0c8811264eebae7 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期六, 22 一月 2022 15:25:32 +0800 Subject: [PATCH] update: TODO#134222/134105 通知小鈴鐺/取得待評分的滿意度清單, 串接api --- PAMapp/components/NavBar.vue | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 46 insertions(+), 2 deletions(-) diff --git a/PAMapp/components/NavBar.vue b/PAMapp/components/NavBar.vue index 3754bfb..13c53a4 100644 --- a/PAMapp/components/NavBar.vue +++ b/PAMapp/components/NavBar.vue @@ -8,7 +8,7 @@ </div> <div class="pam-header__action-bar"> <i - v-if="currentRole" + v-if="isShowNotification" class="icon-bell text--dark-blue cursor--pointer fix-chrome-click--issue" @click="$router.push('/notification')" ></i> @@ -49,9 +49,11 @@ <script lang="ts"> import { Vue, Component } from 'vue-property-decorator'; - import { namespace } from 'nuxt-property-decorator'; + import { Action, namespace, State, Watch } from 'nuxt-property-decorator'; import { Role } from '~/shared/models/enum/Role'; import * as _ from 'lodash'; + import { NotificationList } from '~/shared/models/reviews.model'; + import { AppointmentLog } from '~/shared/models/appointment.model'; const roleStorage = namespace('localStorage'); @Component @@ -71,6 +73,21 @@ @roleStorage.Getter isAdminLogin!: boolean; + + @roleStorage.Getter + isUserLogin!: boolean; + + @Action + storeMyPersonalNotification!: () => void; + + @State + notificationList!: NotificationList[]; + + @Action + storeMyAppointmentReviewLog!: () => void; + + @State + unReviewLogList!: AppointmentLog[]; isOpenDropdown = false; @@ -123,6 +140,24 @@ ////////////////////////////////////////////////////////////////////// + @Watch('$route', {immediate: true}) + onRouterChange() { + this.getNotificationAndReviewLog(); + } + + private getNotificationAndReviewLog() { + if (this.isUserLogin) { + this.storeMyPersonalNotification(); + this.storeMyAppointmentReviewLog(); + } + + if (this.isAdminLogin) { + this.storeMyPersonalNotification(); + } + } + + ////////////////////////////////////////////////////////////////////// + routerNavigateTo(url: string): void { (this.$refs.dropdown as any).hide(); _.isEqual(url,'') @@ -144,6 +179,15 @@ return this.idToken && this.currentRole ? (this.currentRole as Role): Role.NOT_LOGIN; } + get isShowNotification() { + if (this.isUserLogin) { + return this.notificationList.length || this.unReviewLogList.length; + } + if (this.isAdminLogin) { + return this.notificationList.length + } + } + } </script> -- Gitblit v1.8.0