保誠-保戶業務員媒合平台
Mila
2021-11-10 391d7db141245798c64aa8acb0f143ab4152aa79
PAMapp/pages/index.vue
@@ -1,5 +1,7 @@
<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>
@@ -31,36 +33,36 @@
                <h5 class="mdTxt">推薦保險顧問</h5>
                <img class="absulate img" src="~/assets/images/index_recommend.svg" alt="">
            </div>
            <ConsultantSwiper :agents="agents"></ConsultantSwiper>
            <ConsultantSwiper :agents="recommendList"></ConsultantSwiper>
        </div>
    </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 } from 'nuxt-property-decorator';
import { Consultants } from '~/assets/ts/api/consultant';
import { login, recommend, getFavoriteConsultant } from '~/assets/ts/api/consultant';
import { isLogin } from '~/assets/ts/auth';
@Component({
    layout: 'home'
})
export default class MainComponent extends Vue {
    agents: Agents[] = [];
    consultantList: Agents[] = [];
    consultantList: Consultants[] = [];
    agents: Consultants[] = [];
    @State('recommendList') recommendList!: Consultants[];
    @Action storeRecommendList!: any;
    async asyncData(context: Context) {
        let agents: Agents[] = [];
        let consultantList: Agents[] = [];
        await context.$service.home.recommendConsultantList().then((result: Agents[]) => {
            agents = result;
        })
    mounted() {
        consultantList = agents.filter(item => item.contactStatus !== 'contacted');
        return {
            agents,
            consultantList
        if (!this.recommendList) {
            this.storeRecommendList();
        }
        if (isLogin()) {
            getFavoriteConsultant().then((response) => this.consultantList = response.data);
        }
    }
    routerPush(path: string) {
@@ -73,6 +75,25 @@
        })
        this.consultantList.splice(findIndex, 1)
    }
    // 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.clear();
        this.$router.go(0)
    }
}
</script>