| | |
| | | <template> |
| | | <div> |
| | | <Ui-Carousel></Ui-Carousel> |
| | | <div class="page-container"> |
| | | <h5 class="mdTxt mb-30">預約保險顧問</h5> |
| | | <el-button |
| | | class="reserveBtn recommendConsultant" |
| | | @click="routerPush('/recommendConsultant')" |
| | | > |
| | | <p>嚴選配對</p> |
| | | </el-button> |
| | | <el-button |
| | | class="reserveBtn quickFilter" |
| | | @click="routerPush('/quickFilter')" |
| | | > |
| | | <p>快速篩選</p> |
| | | </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" |
| | | v-if="consultantList.length > 3" |
| | | @click.native="routerPush('/myConsultantList/consultantList')">查看更多</el-col> |
| | | </el-row> |
| | | <ConsultantList |
| | | :agents="consultantList.slice(0, 3)" |
| | | @removeAgent="removeAgent" |
| | | ></ConsultantList> |
| | | <div class='pam-recommend pb-30 pt-30'> |
| | | <h5 class="mdTxt">推薦保險顧問</h5> |
| | | <img class="absulate img" src="~/assets/images/index_recommend.svg" alt=""> |
| | | </div> |
| | | <ConsultantSwiper :agents="recommendList"></ConsultantSwiper> |
| | | <div> |
| | | <Ui-Carousel></Ui-Carousel> |
| | | <div class="page-container"> |
| | | <div class="mb-30"> |
| | | <h5 class="mdTxt">預約保險顧問</h5> |
| | | <div class="mt-10 pam-reserveBtn--block"> |
| | | <el-button class="reserveBtn recommendConsultant" |
| | | @click="routerPush('/recommendConsultant')"> |
| | | <p>嚴選配對</p> |
| | | </el-button> |
| | | <el-button class="reserveBtn quickFilter" |
| | | @click="routerPush('/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="routerPush('/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> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, State, Action } from 'nuxt-property-decorator'; |
| | | import { getFavoriteFromStorage, setFavoriteToStorage } from '~/assets/ts/storageConsultant'; |
| | | import { addFavoriteConsultant, Consultants, deleteConsultant } from '~/assets/ts/api/consultant'; |
| | | import { login, getFavoriteConsultant } from '~/assets/ts/api/consultant'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator'; |
| | | import { Consultant } from '~/shared/models/consultant.model'; |
| | | |
| | | @Component({ |
| | | const localStorage = namespace('localStorage'); |
| | | @Component({ |
| | | layout: 'home' |
| | | }) |
| | | export default class MainComponent extends Vue { |
| | | consultantList: Consultants[] = []; |
| | | agents: Consultants[] = []; |
| | | @State('recommendList') recommendList!: Consultants[]; |
| | | }) |
| | | export default class MainComponent extends Vue { |
| | | consultantList: Consultant[] = []; |
| | | |
| | | @State('recommendList') recommendList!: Consultant[]; |
| | | @Action storeRecommendList!: any; |
| | | |
| | | @State('myConsultantList') myConsultantList!: Consultant[]; |
| | | @Action storeConsultantList!: any; |
| | | |
| | | @localStorage.Mutation storageClearQuickFilter!: () => void; |
| | | @localStorage.Mutation storageClearRecommendConsultant!: () => void; |
| | | |
| | | @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) |
| | | } |
| | | |
| | | mounted() { |
| | | if (!this.recommendList) { |
| | | this.storeRecommendList(); |
| | | } |
| | | if (!this.recommendList?.length) { |
| | | this.storeRecommendList(); |
| | | } |
| | | |
| | | if (isLogin()) { |
| | | this.addFavoriteFromStorageToApi(); |
| | | } else { |
| | | this.consultantList = getFavoriteFromStorage(); |
| | | } |
| | | } |
| | | |
| | | getMyConsutant() { |
| | | getFavoriteConsultant().then((response) => { |
| | | this.consultantList = response.data |
| | | .filter(item => item.contactStatus !== 'contacted') |
| | | .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1) |
| | | }); |
| | | } |
| | | |
| | | addFavoriteFromStorageToApi() { |
| | | const agentNoList = getFavoriteFromStorage().map(i => i.agentNo) |
| | | if (agentNoList.length > 0) { |
| | | addFavoriteConsultant(agentNoList).then(res => this.getMyConsutant()); |
| | | localStorage.removeItem('favoriteConsultant'); |
| | | return; |
| | | } |
| | | this.getMyConsutant(); |
| | | this.storeConsultantList(); |
| | | this.storageClearQuickFilter(); |
| | | this.storageClearRecommendConsultant(); |
| | | } |
| | | |
| | | routerPush(path: string) { |
| | | this.$router.push(path); |
| | | this.$router.push(path); |
| | | } |
| | | |
| | | removeAgent(agentNo: string) { |
| | | |
| | | if (!isLogin()) { |
| | | const findIndex = this.consultantList.findIndex((item, i) => { |
| | | return item.agentNo === agentNo; |
| | | }) |
| | | this.consultantList.splice(findIndex, 1); |
| | | setFavoriteToStorage(this.consultantList) |
| | | } else { |
| | | deleteConsultant(agentNo).then(res => this.$router.go(0)) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | </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; |
| | | } |
| | | |
| | | .reserveBtn.el-button--default { |
| | | width: 100%; |
| | | height: 110px; |
| | | border-radius: 10px; |
| | | margin: 0 auto 17px auto; |
| | | 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; |
| | | } |
| | | |
| | | &:nth-child(3) { |
| | | margin-bottom: 42px; |
| | | } |
| | | |
| | | .pam-reserveBtn--block { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .reserveBtn+.reserveBtn { |
| | | margin-left: 0px; |
| | | .reserveBtn { |
| | | max-width: 335px; |
| | | } |
| | | |
| | | .quickFilter { |
| | | background-image: url('~/assets/images/quickFilter/banner_mob.svg'); |
| | | } |
| | | |
| | | .recommendConsultant { |
| | | background-image: url('~/assets/images/recommendConsultant/banner_mob.svg'); |
| | | } |
| | | |
| | | @media (min-width: 576px) and (max-width: 768px) { |
| | | .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'); |
| | | } |
| | | } |
| | | |
| | | .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; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .pam-recommend { |
| | | position: relative; |
| | | |
| | | .img { |
| | | position: absolute; |
| | | right: 20px; |
| | | bottom: 0px; |
| | | } |
| | | } |
| | | } |
| | | |
| | | </style> |