TODO#130015/130016 [推薦保險顧問/我的顧問清單] api 串接
¤ñ¹ï·sÀÉ®× |
| | |
| | | import axios from 'axios'; |
| | | import { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios' |
| | | |
| | | export const service = axios.create({ |
| | | baseURL: 'http://localhost:8080/api', |
| | | headers: { |
| | | Authorization: 'Bearer ' + localStorage.getItem('id_token') |
| | | } |
| | | }) |
| | | |
| | | service.interceptors.request.use(function (config: AxiosRequestConfig) { |
| | | return config; |
| | | }, function (error: AxiosError) { |
| | | return Promise.reject(error); |
| | | }); |
| | | |
| | | service.interceptors.response.use(function (response: AxiosResponse) { |
| | | return response; |
| | | }, function (error: AxiosError) { |
| | | return Promise.reject(error); |
| | | }); |
| | | |
| | | // 顧客ç»å
¥(TODO: OTPèªèéç¼å æ«æä½¿ç¨) |
| | | export function login(user: any) { |
| | | return service.post('/authenticate', user) |
| | | } |
| | | |
| | | // æ¨è¦ä¿éªé¡§å |
| | | export function recommend() { |
| | | return service.get('/consultant/recommend') |
| | | } |
| | | |
| | | // æç顧忏
å® |
| | | export function getFavoriteConsultant() { |
| | | return service.get('/consultant/favorite'); |
| | | } |
| | | |
| | | export interface Consultants { |
| | | agentNo: number, |
| | | name: string, |
| | | img: string, |
| | | new: boolean, |
| | | avgScore: number, |
| | | expertise: string[], |
| | | updateTime: Date, |
| | | seniority: string, |
| | | contactStatus?: string; |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | export function isLogin() { |
| | | return !!localStorage.getItem('id_token') |
| | | } |
| | |
| | | :size="50" |
| | | :src="agentInfo.img" |
| | | class="cursor--pointer" |
| | | @click.native="$router.push('/agentInfo')" |
| | | @click.native="$router.push(`/agentInfo`)" |
| | | ></el-avatar> |
| | | <div class="satisfaction"> |
| | | <i class="icon-star pam-icon icon--yellow satisfaction"></i> |
| | | <span>{{agentInfo.satisfaction}}</span> |
| | | <span>{{agentInfo.avgScore }}</span> |
| | | </div> |
| | | </el-col> |
| | | <el-col :xs="10" :sm="15"> |
| | |
| | | <div class="professionals"> |
| | | <span |
| | | class="professionalsTxt" |
| | | v-for="(professional, index) in agentInfo.professionals" |
| | | v-for="(expertise, index) in agentInfo.expertise" |
| | | :key="index" |
| | | >#{{professional}}</span> |
| | | >#{{expertise}}</span> |
| | | </div> |
| | | <div |
| | | class="delete" |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop, Emit } from 'nuxt-property-decorator'; |
| | | import { Agents } from '~/plugins/api/home'; |
| | | import { Consultants } from '~/assets/ts/api/consultant'; |
| | | import { isMobileDevice } from '~/assets/ts/device'; |
| | | |
| | | @Component |
| | | export default class ConsultantCard extends Vue { |
| | | @Prop() agentInfo!: Agents; |
| | | @Prop() agentInfo!: Consultants; |
| | | isVisibleDialog = false; |
| | | width: string = ''; |
| | | |
| | |
| | | <template> |
| | | <div> |
| | | <template v-if="agents.length > 0 && noLogin"> |
| | | <template v-if="agents.length > 0"> |
| | | <ConsultantCard |
| | | v-for="(agent, index) in agents" |
| | | :key="index" |
| | |
| | | @removeAgent="removeAgent" |
| | | ></ConsultantCard> |
| | | </template> |
| | | <template v-else-if="agents.length === 0"> |
| | | <template v-else-if="!isLogin && agents.length === 0"> |
| | | <div class="emptyRowStyle"> |
| | | <div class="smTxt txt">æ¨ç®åç¡å·²é¸é¡§å</div> |
| | | <div class="mdTxt login" @click="$router.push('/login')">ç»å
¥</div> |
| | | <div class="smTxt txt">æ¥çæ´å¤å·²é¸é¡§å</div> |
| | | </div> |
| | | </template> |
| | | <template v-else> |
| | | <div class="emptyRowStyle"> |
| | | <div class="mdTxt login" @click="$router.push('/login')">ç»å
¥</div> |
| | | <div class="smTxt txt">æ¥çæ´å¤å·²é¸é¡§å</div> |
| | | <div class="smTxt txt">æ¨ç®åç¡å·²é¸é¡§å</div> |
| | | </div> |
| | | </template> |
| | | </div> |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop, Emit } from 'nuxt-property-decorator'; |
| | | import { Agents } from '~/plugins/api/home'; |
| | | import { Consultants } from '~/assets/ts/api/consultant'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | |
| | | @Component |
| | | export default class ConsultantList extends Vue { |
| | | @Prop() agents!: Agents[]; |
| | | @Prop() agents!: Consultants[]; |
| | | |
| | | noLogin = true; |
| | | get isLogin() { |
| | | return isLogin(); |
| | | } |
| | | |
| | | @Emit('removeAgent') removeAgent(agentId: number) { |
| | | return agentId; |
| | |
| | | <div class="name">{{agentInfo.name}}</div> |
| | | <div> |
| | | <i class="icon-star pam-icon icon--yellow"></i> |
| | | <span class="satisfaction">{{agentInfo.satisfaction}}</span> |
| | | <span class="satisfaction">{{agentInfo.avgScore}}</span> |
| | | </div> |
| | | </div> |
| | | </swiper-slide> |
| | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop } from 'vue-property-decorator'; |
| | | import { SwiperOptions } from 'swiper'; |
| | | import { Agents } from '~/plugins/api/home' |
| | | import { Consultants } from '~/assets/ts/api/consultant' |
| | | |
| | | @Component |
| | | export default class UiSwiper extends Vue { |
| | | @Prop() agents!: Agents[]; |
| | | @Prop() agents!: Consultants[]; |
| | | |
| | | swiperOptions: SwiperOptions = { |
| | | loop: true, |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop, Emit, Watch } from 'nuxt-property-decorator'; |
| | | import { Agents } from '~/plugins/api/home'; |
| | | import { Consultants } from '~/assets/ts/api/consultant'; |
| | | |
| | | @Component |
| | | export default class UiPagination extends Vue { |
| | | @Prop() totalList!: Agents[]; |
| | | @Prop() totalList!: Consultants[]; |
| | | pageSize = 5; |
| | | currentPage = 1; |
| | | pageList: Agents[] = []; |
| | | pageList: Consultants[] = []; |
| | | |
| | | mounted() { |
| | | this.handleCurrentChange(this.currentPage); |
| | | } |
| | | |
| | | @Emit('changePage') chagnePage(): Agents[] { |
| | | @Emit('changePage') chagnePage(): Consultants[] { |
| | | return this.pageList |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @Watch('totalList') watchtotalList(newValue: Agents[]) { |
| | | @Watch('totalList') watchtotalList(newValue: Consultants[]) { |
| | | if (newValue) { |
| | | this.handleCurrentChange(this.currentPage); |
| | | } |
| | |
| | | <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> |
| | |
| | | <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) { |
| | |
| | | }) |
| | | 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> |
| | |
| | | import { Context } from '@nuxt/types'; |
| | | import { Vue, Component, Watch } from 'vue-property-decorator'; |
| | | import { Route } from 'vue-router/types/router.d' |
| | | import { Agents } from '~/plugins/api/home'; |
| | | import { Consultants, getFavoriteConsultant } from '~/assets/ts/api/consultant'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | |
| | | @Component |
| | | export default class myConsultantList extends Vue { |
| | | activeTabName = 'consultantList'; |
| | | agents: Agents[] = []; |
| | | contactedList: Agents[] = []; |
| | | consultantList: Agents[] = []; |
| | | agents: Consultants[] = []; |
| | | contactedList: Consultants[] = []; |
| | | consultantList: Consultants[] = []; |
| | | |
| | | tabClick(path: string) { |
| | | this.activeTabName = path; |
| | |
| | | } |
| | | |
| | | async asyncData(context: Context) { |
| | | let agents: Agents[] = []; |
| | | let contactedList: Agents[] = []; |
| | | let consultantList: Agents[] = []; |
| | | let agents: Consultants[] = []; |
| | | let contactedList: Consultants[] = []; |
| | | let consultantList: Consultants[] = []; |
| | | |
| | | await context.$service.home.recommendConsultantList().then((result: Agents[]) => { |
| | | agents = result; |
| | | }) |
| | | if (isLogin()) { |
| | | await getFavoriteConsultant().then((response) => agents = response.data); |
| | | } |
| | | |
| | | contactedList = agents.filter(item => item.contactStatus === 'contacted'); |
| | | consultantList = agents.filter(item => item.contactStatus !== 'contacted'); |
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop, Emit } from 'nuxt-property-decorator'; |
| | | import { Agents } from '~/plugins/api/home'; |
| | | import { Vue, Component, Prop, Emit, Getter } from 'nuxt-property-decorator'; |
| | | import { Consultants } from '~/assets/ts/api/consultant'; |
| | | |
| | | @Component |
| | | export default class ConsultantPage extends Vue { |
| | | @Prop() consultantList!: Agents[]; |
| | | pageList: Agents[] = []; |
| | | @Prop() consultantList!: Consultants[]; |
| | | @Getter isLogin!: boolean; |
| | | pageList: Consultants[] = []; |
| | | |
| | | @Emit('remove') remove(agentNo: number) { |
| | | @Emit('remove') removeAgent(agentNo: number) { |
| | | return agentNo; |
| | | } |
| | | |
| | | changePage(pageList: Agents[]) { |
| | | changePage(pageList: Consultants[]) { |
| | | this.pageList = pageList; |
| | | } |
| | | |
| | | removeAgent(agentNo: number) { |
| | | this.remove(agentNo); |
| | | } |
| | | } |
| | | </script> |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop } from 'nuxt-property-decorator' ; |
| | | import { Agents } from '~/plugins/api/home'; |
| | | import { Consultants } from '~/assets/ts/api/consultant'; |
| | | |
| | | @Component |
| | | export default class ContactedList extends Vue { |
| | | @Prop() contactedList!: Agents[]; |
| | | pageList: Agents[] = []; |
| | | @Prop() contactedList!: Consultants[]; |
| | | pageList: Consultants[] = []; |
| | | |
| | | changePage(pageList: Agents[]) { |
| | | changePage(pageList: Consultants[]) { |
| | | this.pageList = pageList; |
| | | } |
| | | } |
| | |
| | | <script lang="ts"> |
| | | import { Context } from '@nuxt/types'; |
| | | import { Vue, Component } from 'nuxt-property-decorator'; |
| | | import { Agents } from '~/plugins/api/home'; |
| | | import { Consultants } from '~/assets/ts/api/consultant'; |
| | | import { isMobileDevice } from '~/assets/ts/device'; |
| | | import QuickFilterDrawer from '~/components/QuickFilter/QuickFilterSelector.vue'; |
| | | |
| | |
| | | ]; |
| | | |
| | | async asyncData(context: Context) { |
| | | let consultantList: Agents[] = []; |
| | | let consultantList: Consultants[] = []; |
| | | |
| | | await context.$service.home.recommendConsultantList().then((result: Agents[]) => { |
| | | await context.$service.home.recommendConsultantList().then((result: Consultants[]) => { |
| | | consultantList = result; |
| | | }) |
| | | |
| | |
| | | |
| | | return CommonService.prototype.withDebugData(debugData, '') |
| | | } |
| | | }) |
| | | |
| | | export interface Agents { |
| | | agentNo: number, |
| | | name: string, |
| | | img: string, |
| | | new: boolean, |
| | | satisfaction: number, |
| | | professionals: string[], |
| | | contactStatus: string, |
| | | updateTime: Date |
| | | } |
| | | }) |
| | |
| | | import { Module, VuexModule } from 'vuex-module-decorators' |
| | | |
| | | import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' |
| | | import { Consultants } from '~/assets/ts/api/consultant'; |
| | | import { recommend } from '~/assets/ts/api/consultant' |
| | | @Module |
| | | export default class Store extends VuexModule { |
| | | recommendList: Consultants[] | null = null; |
| | | |
| | | @Mutation updateRecommend(data: Consultants[]) { |
| | | this.recommendList = data; |
| | | } |
| | | |
| | | @Action storeRecommendList() { |
| | | recommend().then(res => { |
| | | this.context.commit('updateRecommend', res.data) |
| | | }) |
| | | } |
| | | |
| | | } |