保誠-保戶業務員媒合平台
PAMapp/pages/index.vue
@@ -1,7 +1,5 @@
<template>
    <div>
        <el-button @click="login">登入</el-button>
        <el-button @click="remove">登出</el-button>
        <Ui-Carousel></Ui-Carousel>
        <div class="page-container">
            <h5 class="mdTxt mb-30">預約保險顧問</h5>
@@ -30,7 +28,6 @@
            </el-row>
            <ConsultantList
                :agents="consultantList.slice(0, 3)"
                @removeAgent="removeAgent"
            ></ConsultantList>
            <div class='pam-recommend pb-30 pt-30'>
                <h5 class="mdTxt">推薦保險顧問</h5>
@@ -42,11 +39,8 @@
</template>
<script lang="ts">
import { Vue, Component, State, Action } from 'nuxt-property-decorator';
import { getFavoriteFromStorage, setFavoriteToStorage } from '~/assets/ts/storageConsultant';
import { addFavoriteConsultant, Consultants } 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 } from 'nuxt-property-decorator';
import { Consultants } from '~/assets/ts/api/consultant';
@Component({
    layout: 'home'
@@ -57,57 +51,26 @@
    @State('recommendList') recommendList!: Consultants[];
    @Action storeRecommendList!: any;
    @State('myConsultantList') myConsultantList!: Consultants[];
    @Action storeConsultantList!: any;
    @Watch('myConsultantList')
    onMyConsultantListChange() {
        this.consultantList = (this.myConsultantList || [])
                .filter(item => item.contactStatus !== 'contacted')
                .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1)
    }
    mounted() {
        if (!this.recommendList) {
        if (!this.recommendList?.length) {
            this.storeRecommendList();
        }
        if (isLogin()) {
            this.addFavoriteFromStorageToApi();
            getFavoriteConsultant().then((response) => this.consultantList = response.data);
        } else {
            this.consultantList = getFavoriteFromStorage();
        }
    }
    addFavoriteFromStorageToApi() {
        const agentNoList = getFavoriteFromStorage().map(i => i.agentNo)
        if (agentNoList.length > 0) {
            addFavoriteConsultant(agentNoList).then(res => res);
            localStorage.removeItem('favoriteConsultant');
        }
        this.storeConsultantList();
    }
    routerPush(path: string) {
        this.$router.push(path);
    }
    removeAgent(agentNo: string) {
        const findIndex = this.consultantList.findIndex((item, i) => {
            return item.agentNo === agentNo;
        })
        this.consultantList.splice(findIndex, 1);
        if (!isLogin()) {
            setFavoriteToStorage(this.consultantList)
        }
    }
    // TODO: 僅OTP認證開發前 暫時使用
    login() {
        const user = {
            username: "user",
            password: "user"
        }
        login(user).then((res) => {
            localStorage.setItem('id_token', res.data.id_token);
            this.$router.go(0);
        })
    }
    // TODO: 僅OTP認證開發前 暫時使用
    remove() {
        localStorage.removeItem('id_token');
        this.$router.go(0)
    }
}
@@ -157,7 +120,7 @@
        background-image: url('~/assets/images/recommendConsultant/banner_mob.svg');
    }
    @media (min-width: 576px) and (max-width: 1023px) {
    @media (min-width: 576px) and (max-width: 768px) {
        .quickFilter.el-button--default {
            background-image: url('~/assets/images/quickFilter/banner_web.svg');
        }