From 1d6d2d14200ed9432347ef8013e3fc117fa2161b Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期四, 20 一月 2022 14:57:27 +0800 Subject: [PATCH] Merge branch 'master' into Phase3 --- PAMapp/pages/index.vue | 433 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 336 insertions(+), 97 deletions(-) diff --git a/PAMapp/pages/index.vue b/PAMapp/pages/index.vue index a85fe90..e4b2ea8 100644 --- a/PAMapp/pages/index.vue +++ b/PAMapp/pages/index.vue @@ -1,125 +1,364 @@ <template> - <div> - <Ui-Carousel></Ui-Carousel> - <div class="page-container"> - <h5 class="mdTxt mb-30">����憿批��</h5> - <el-button - class="reserveBtn" - @click="routerPush('/recommendConsultant')" - >������</el-button> - <el-button - class="reserveBtn" - @click="routerPush('/quickFilter')" - >敹恍�祟�</el-button> - <el-row class="mb-30 rowStyle"> - <el-col :span="16"> - <span class="mdTxt">���“���</span> - <span class="smTxt_bold amount">� {{consultantList.length}} 蝑�</span> - </el-col> - <el-col :span="8" class="mdTxt readMore" - @click.native="routerPush('/myConsultantList/consultantList')">���憭�</el-col> - </el-row> - <ConsultantList - :agents="consultantList.slice(0, 3)" - @removeAgent="removeAgent" - ></ConsultantList> - <h5 class="mdTxt mb-30 mt-30">��靽憿批��</h5> - <ConsultantSwiper :agents="agents"></ConsultantSwiper> + <div> + <Ui-Carousel></Ui-Carousel> + <div class="page-container"> + <div> + <h5 class="mdTxt">����憿批��</h5> + <div class="mt-10 pam-reserveBtn--block"> + <el-button class="reserveBtn recommendConsultant" + @click="navigateToRoute('/recommendConsultant')"> + <p>������</p> + </el-button> + <el-button class="reserveBtn quickFilter" + @click="navigateToRoute('/quickFilter')"> + <p>敹恍�祟�</p> + </el-button> </div> + </div> + <div class="pam-paragraph"> + <el-row class="rowStyle"> + <el-col :span="16"> + <span class="mdTxt">���“���</span> + <span class="smTxt_bold amount">� {{ consultantList.length }} 蝑�</span> + </el-col> + <el-col :span="8" + class="mdTxt readMore fix-chrome-click--issue" + v-if="consultantList.length > 3" + @click.native="navigateToRoute('/myConsultantList/consultantList')">���憭�</el-col> + </el-row> + <ConsultantList class="mt-10" + :agents="consultantList.slice(0, 3)"></ConsultantList> + </div> + <div class='pam-paragraph'> + <div class="pam-recommend"> + <h5 class="mdTxt">��靽憿批��</h5> + <img class="img" + src="~/assets/images/index_recommend.svg" + alt=""> + </div> + <ConsultantSwiper :agents="recommendList"></ConsultantSwiper> + </div> </div> + + <Ui-Dialog + :isVisible.sync="isVisibleDialog" + :width="width" + class="pam-myDemand-dialog pam-dialog-reserved" + @closeDialog="clearSatisfactionId" + > + <div v-if="appointmentDetail"> + <h5 class="subTitle text--center mb-30">������</h5> + <p class="smTxt">{{appointmentDetail.appointmentDate | formatDate}}</p> + <div class="reserved-info"> + <p>憪��{appointmentDetail.name}}</p> + <p>�閰梧�{appointmentDetail.phone}}</p> + <p>Email嚗{appointmentDetail.email}}</p> + <p>�批嚗{gender}}</p> + <p>撟湧翩嚗{appointmentDetail.age | toAgeLabel }}</p> + <p>�璆哨�{appointmentDetail.job}}</p> + <p>��瘙�{appointmentDetail.requirement.split(',').join('��')}}</p> + <p + v-for="(item, index) in hopeContactTime" + :key="index" + >��蝯⊥�挾{{index + 1 | formatNumber}}嚗{ item | formatHopeContactTime }}</p> + <div v-if="appointmentDetail.satisfactionScore"> + <div class="mdTxt mt-10 mb-10">皛踵�漲</div> + <el-rate + :value="appointmentDetail.satisfactionScore" + class="pam-myDemand-dialog__rate" + disabled> + </el-rate> + </div> + </div> + + <div v-if="!appointmentDetail.satisfactionScore" class="reserved-btn"> + <el-button type="primary" + @click.native="reviewsBtn = true">蝯虫�遛��漲閰��</el-button> + </div> + </div> + </Ui-Dialog> + + <PopUpFrame + :isOpen.sync="reviewsBtn" + @closePopUp="clearSatisfactionId" + > + <div class="mdTxt pam-dialog-review"> + 靽憿批�遛��漲 + <span class="hint">������</span> + <div class="mt-30 review-content" v-if="agentInfo"> + <UiAvatar :size="80" :agentNo="agentInfo.agentNo"></UiAvatar> + <div class="review-text">撠憿批�� + <span class="text--primary">{{agentInfo.name}}</span> + ��擃���蝯虫�嗾憿��嚗� + </div> + </div> + + <div class="review-score"> + <el-rate v-model="inputScore" class="pam-rate mt-30"></el-rate> + </div> + + <div class="review-btn"> + <el-button + type="primary" + :disabled="!inputScore" + @click="userReviewsConsultants">�</el-button> + </div> + </div> + </PopUpFrame> + </div> </template> <script lang="ts"> -import { Vue, Component } from 'nuxt-property-decorator'; -import { Agents } from '~/plugins/api/home'; -import { Context } from '@nuxt/types/app'; + import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator'; + import { Consultant } from '~/shared/models/consultant.model'; +import { UserReviewsConsultantsParams } from '~/shared/models/reviews.model'; + import appointmentService from '~/shared/services/appointment.service'; +import reviewsService from '~/shared/services/reviews.service'; + import UtilsService from '~/shared/services/utils.service'; -@Component({ + const localStorage = namespace('localStorage'); + + @Component({ layout: 'home' -}) -export default class MainComponent extends Vue { - agents: Agents[] = []; - consultantList: Agents[] = []; + }) + export default class MainComponent extends Vue { - async asyncData(context: Context) { - let agents: Agents[] = []; - let consultantList: Agents[] = []; - await context.$service.home.recommendConsultantList().then((result: Agents[]) => { - agents = result; - }) + @State('recommendList') + recommendList!: Consultant[]; - consultantList = agents.filter(item => item.contactStatus !== 'contacted'); + @State('myConsultantList') + myConsultantList!: Consultant[]; - return { - agents, - consultantList + @Action + storeRecommendList!: any; + + @Action storeConsultantList!: any; + + @localStorage.Mutation + storageClearQuickFilter!: () => void; + + @localStorage.Mutation + storageClearRecommendConsultant!: () => void; + + @localStorage.Getter + currentSatisfactionIdFromMsg!: string; + + @localStorage.Mutation + storageClearSatisfactionIdFromMsg!: () => void; + + consultantList: Consultant[] = []; + + appointmentDetail: any = { + age : '', + agentNo : '', + appointmentDate : '', + communicateStatus : '', + consultantReadTime: null, + consultantViewTime: null, + contactTime : '', + contactType : '', + customerId : 0, + email : '', + gender : '', + hopeContactTime : "", + id : 0, + job : "", + lastModifiedDate : '', + name : '', + otherRequirement : null, + phone : "", + requirement : '', + satisfactionScore : 0, + }; + isVisibleDialog = false; + width = ''; + reviewsBtn = false; + inputScore = 0; + agentInfo: Consultant = { + agentNo : '', + name : '', + img : '', + expertise : [], + avgScore : 0, + contactStatus : '', + createTime : '', + updateTime : '', + customerViewTime : '', + role : '', + seniority : '', + appointments : [] + }; + + ////////////////////////////////////////////////////////////////////// + + mounted() { + if (!this.recommendList?.length) { + this.storeRecommendList(); + } + + this.storeConsultantList(); + this.storageClearQuickFilter(); + this.storageClearRecommendConsultant(); + } + + destroyed() { + this.clearSatisfactionId(); + } + + ////////////////////////////////////////////////////////////////////// + + @Watch('myConsultantList') + onMyConsultantListChange() { + this.consultantList = (this.myConsultantList || []) + .filter(item => item.contactStatus !== 'contacted') + .map((item) => ({ ...item, formatDate: new Date(item.updateTime || item.createTime)})) + .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate); + + if (this.currentSatisfactionIdFromMsg) { + this.agentInfo = this.myConsultantList.filter(item => { + const satisfactionIdIndex = item.appointments?.findIndex(i => i.id === +this.currentSatisfactionIdFromMsg); + return satisfactionIdIndex !== undefined && satisfactionIdIndex > -1; + })[0]; + if (this.agentInfo) { + this.openAppointmentInfo(); } + + } } - routerPush(path: string) { - this.$router.push(path); + private openAppointmentInfo() { + appointmentService.getAppointmentDetail(+this.currentSatisfactionIdFromMsg).then(res => { + this.appointmentDetail = res; + this.width = UtilsService.isMobileDevice() ? '80%' : ''; + this.isVisibleDialog = true; + + if (!this.appointmentDetail.satisfactionScore) { + setTimeout(() => { + this.reviewsBtn = true; + }, 500) + } + }); } - removeAgent(agentNo: number) { - const findIndex = this.agents.findIndex((item, i) => { - return item.agentNo === agentNo; - }) - this.consultantList.splice(findIndex, 1) + ////////////////////////////////////////////////////////////////////// + + navigateToRoute(path: string): void { + this.$router.push(path); } -} + + userReviewsConsultants() { + const reviewParams: UserReviewsConsultantsParams = { + appointmentId: this.appointmentDetail.id, + score: this.inputScore, + } + this.appointmentDetail.satisfactionScore = this.inputScore; + + reviewsService.userReviewsConsultants(reviewParams).then((res) => { + this.reviewsBtn = false; + }); + } + + clearSatisfactionId() { + console.log('close'); + this.$router.push({query: {}}); + this.storageClearSatisfactionIdFromMsg(); + } + + /////////////////////////////////////////////////////////////////////////////// + + get gender() { + if (this.appointmentDetail.gender) { + return this.appointmentDetail.gender === 'male' ? '���' : '憟單��'; + } + return '' + } + + get hopeContactTime() { + const contactList = this.appointmentDetail.hopeContactTime + .split("'").map((item: any) => item.slice(0, item.length)); + return contactList.filter((item: any) => !!item && item !== ",") + } + + } </script> <style lang="scss" scoped> + .page-container { + margin: 0px 20px 30px 20px; + } + .reserveBtn.el-button--default { + width : 100%; + height : 110px; + border-radius : 10px; + margin-bottom : 15px; + font-size : 32px; + font-weight : 700; + background-position: right; + background-size : cover; + color : #68737A; + text-align : left; + background-repeat : no-repeat; + box-shadow : 0px 0px 6px #a79b9b29; + border-width : 0; + + p { + text-shadow: 1px 1px 5px $PRIMARY_WHITE; + } + } + + .el-button+.el-button { + margin-left: 0px; + } + + .quickFilter { + background-image: url('~/assets/images/quickFilter/banner_mob.svg'); + } + + .recommendConsultant { + background-image: url('~/assets/images/recommendConsultant/banner_mob.svg'); + } + .rowStyle { + .amount { + color: $PRUDENTIAL_GREY; + } + .readMore { + color: $PRIMARY_RED; + cursor: pointer; + text-align: right; + } + } + + .pam-recommend { + display: flex; + justify-content: space-between; + align-items: center; + } + + @media (min-width: 576px) and (max-width: 767px) { + .quickFilter.el-button--default { + background-image: url('~/assets/images/quickFilter/banner_web.svg'); + } + + .recommendConsultant.el-button--default { + background-image: url('~/assets/images/recommendConsultant/banner_web.svg'); + } + } + + @include desktop { .page-container { - padding: 0px 20px 30px 20px; + width: 700px; + margin: 0 auto; + } + + .pam-reserveBtn--block { + display: flex; + justify-content: space-between; } .reserveBtn { - width: 100%; - height: 110px; - border-radius: 10px; - box-shadow: 0px 0px 6px #22222229; - margin: 0 auto 17px auto; - font-size: 32px; - font-weight: 700; - color: $PRIMARY_BLACK; - - &:nth-child(3) { - margin-bottom: 42px; - } + max-width: 335px; } - - .reserveBtn+.reserveBtn { - margin-left: 0px; - } - - .rowStyle { - .amount { - color: $PRUDENTIAL_GREY; - } - .readMore { - color: $PRIMARY_RED; - cursor: pointer; - text-align: right; - } - } - - @include desktop { - .page-container { - width: 700px; - margin: 0 auto; - } - - .reserveBtn { - max-width: 340px; - - &:nth-child(2) { - margin-right: 15px; - } - } - - } - + } </style> -- Gitblit v1.8.0