保誠-保戶業務員媒合平台
劉鈞霖
2021-11-15 cd4a64b39c429f2f5b45cb042d1b66f1cd3904cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<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>
    </div>
</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';
 
@Component({
    layout: 'home'
})
export default class MainComponent extends Vue {
    consultantList: Consultants[] = [];
    agents: Consultants[] = [];
    @State('recommendList') recommendList!: Consultants[];
    @Action storeRecommendList!: any;
 
    mounted() {
        if (!this.recommendList) {
            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');
        }
    }
 
    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)
        }
    }
}
 
</script>
 
<style lang="scss" scoped>
 
    .page-container {
        padding: 0px 20px 30px 20px;
    }
 
    .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;
        }
 
    }
 
    .reserveBtn+.reserveBtn {
        margin-left: 0px;
    }
 
    .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: 1023px) {
        .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>