From 73a09dcb91e4162aa1820bc2a613d32febb61a8d Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期一, 22 十一月 2021 14:48:30 +0800
Subject: [PATCH] fixed: [註冊畫面] 對整版對於閱讀條約的判定方式,以解決桌機版判定失敗的錯誤

---
 PAMapp/pages/quickFilter/index.vue |  270 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 145 insertions(+), 125 deletions(-)

diff --git a/PAMapp/pages/quickFilter/index.vue b/PAMapp/pages/quickFilter/index.vue
index db81125..57bc9bd 100644
--- a/PAMapp/pages/quickFilter/index.vue
+++ b/PAMapp/pages/quickFilter/index.vue
@@ -5,192 +5,220 @@
                 v-for="(question, index) in questionList"
                 :key="index"
                 class="subTitle quickBtn"
-                :disabled="question.name === 'onlineState'"
-
+                :class="{'isActive': isActive(question.name)}"
                 @click="openPopUp(question)"
             >{{question.title}}</el-button>
         </div>
         <h5 class="mdTxt mb-10 mt-30">蝭拚璇辣</h5>
         <div>
-            <Ui-Tags
-                v-if="selectedItem.gender"
-                @removeTag="removeTag('gender')"
-            >
-                {{selectedItem.gender}}
-            </Ui-Tags>
-            <Ui-Tags
-                v-if="selectedItem.satisfaction"
-                @removeTag="removeTag('satisfaction')"
-            >
-                {{selectedItem.satisfaction + '��誑銝遛��漲'}}
-            </Ui-Tags>
-            <template v-if="selectedItem.style.length > 0">
-                <Ui-Tags
-                    v-for="(item, index) in selectedItem.style"
-                    :key="index"
-                    @removeTag="removeTag('style', index)"
+            <template v-if="confirmItem.length > 0">
+                <UiTags
+                    v-for="(item, index) in confirmItem" :key="index"
+                    @removeTag="removeTag(item.value)"
                 >
-                    {{item}}
-                </Ui-Tags>
+                    <span v-if="item.option === 'gender'">{{item.value === 'male' ? '���' : '憟單��'}}</span>
+                    <span v-else-if="item.option === 'avgScore'">{{item.value + '��誑銝遛��漲'}}</span>
+                    <span v-else>{{item.value}}</span>
+                </UiTags>
             </template>
-
-            <div class="mb-10" v-if="selectedItem.onlineState"></div>
-            <div class="emptyBox text--mid_grey"
-                v-if="!selectedItem.gender && !selectedItem.satisfaction && selectedItem.style.length === 0 && !selectedItem.onlineState">
+            <div
+                v-else
+                class="emptyBox text--mid_grey"
+            >
                 <p class="smTxt">撠蝭拚</p>
             </div>
         </div>
 
-        <h5 class="mdTxt mb-10 mt-30">敹恍�祟���</h5>
-        <template v-if="consultantList.length > 0">
-            <QuickFilterConsultantList></QuickFilterConsultantList>
-        </template>
+        <div class="mb-10 mt-30">
+            <span class="mdTxt">敹恍�祟���</span>
+            <span class="smTxt_bold text--prudential_grey ml-10">� {{consultantList.length}} 蝑�</span>
+        </div>
+        <div class="recommend pam-paragraph">
+            <img class="img" src="~/assets/images/quickFilter/recommend.svg" alt="">
 
-        <template v-else>
-            <div class="emptyBox bg-white"></div>
-        </template>
+            <template v-if="consultantList.length > 0">
+                <QuickFilterConsultantList :consultantList="consultantList"></QuickFilterConsultantList>
+            </template>
 
-        <Ui-Drawer
-            :isVisible.sync="questionDrawer"
-            :size="questionOption.name === 'style' ? '50%' : '30%'"
-            @closeDrawer="closePopUp"
+            <template v-else>
+                <div class="emptyBox text--mid_grey recommendStyle">
+                    <p class="smTxt">撠��鞈��</p>
+                </div>
+            </template>
+        </div>
+
+        <PopUpFrame
+            :isOpen.sync="isOpenQuestionPopUp"
+            :drawerSize="questionOption.name === 'communicationStyles' ? '55%' : '35%'"
+            :dialogWidth="'400px'"
+            class="pam-myDemand-dialog"
         >
             <QuickFilterSelector
                 ref="quickFilterRef"
-                :drawerVisible.sync="questionDrawer"
+                :isOpenQuestionPopUp="isOpenQuestionPopUp"
                 :questionOption="questionOption"
-                :selectedItem="selectedItem"
+                @confirm="confirm"
+                :confirmItem="confirmItem"
             ></QuickFilterSelector>
-        </Ui-Drawer>
-
-        <Ui-Dialog :isVisible.sync="dialog"
-            @closeDialog="closePopUp"
-        >
-            <QuickFilterSelector
-                ref="quickFilterRef"
-                :drawerVisible.sync="questionDrawer"
-                :questionOption="questionOption"
-                :selectedItem="selectedItem"
-            ></QuickFilterSelector>
-        </Ui-Dialog>
+        </PopUpFrame>
     </div>
 </template>
 
 <script lang="ts">
-import { Context } from '@nuxt/types';
 import { Vue, Component } from 'nuxt-property-decorator';
-import { Agents } from '~/plugins/api/home';
-import { isMobileDevice } from '~/assets/ts/device';
-import QuickFilterDrawer from '~/components/QuickFilter/QuickFilterSelector.vue';
+import { Consultants, FastQueryParams } from '~/assets/ts/api/consultant';
+import { Selected } from '~/components/QuickFilter/QuickFilterSelector.vue';
+import { fastQuery } from '~/assets/ts/api/consultant';
 
 @Component
 export default class QuickFilter extends Vue {
-    dialog = false;
-    consultantList = [];
-    questionDrawer = false;
+    isOpenQuestionPopUp = false;
+    consultantList: Consultants[] = [];
     questionOption = {};
-    selectedItem: selectedItem = {
-        gender: '',
-        satisfaction: 0,
-        style: [],
-        onlineState: ''
-    };
+    confirmItem: Selected[] = [];
     questionList: QuestionOption[] = [
         {
             name: 'gender',
             title: '憿批��批',
-            detail: ['���', '憟單��'],
+            detail: [
+                { name: '���', value: 'male', className: 'btn_man'},
+                { name: '憟單��', value: 'female', className: 'btn_woman'}
+            ],
             type: 'radio'
         },
         {
-            name: 'satisfaction',
+            name: 'avgScore',
             title: '憿批�遛��漲',
             detail: [],
             type: ''
         },
         {
-            name: 'style',
+            name: 'communicationStyles',
             title: '皞�◢�',
-            detail: ['雓寞��祕', '��翰銝餃��', '���', '�隢◢頞�'],
+            detail: [
+                { value: '雓寞��祕', className: 'btn_owl'},
+                { value: '��翰銝餃��', className: 'btn_tiger'},
+                { value: '���', className: 'btn_koala'},
+                { value: '�隢◢頞�', className: 'btn_peacock'}
+            ],
             type: 'checkbox'
         },
-        {
-            name: 'onlineState',
-            title: '銝�����',
-            detail: [],
-            type: 'radio'
-        }
+        // {
+        //     name: 'status',
+        //     title: '銝�����',
+        //     detail: [],
+        //     type: 'radio'
+        // }
     ];
 
-    async asyncData(context: Context) {
-        let consultantList: Agents[] = [];
+    get gender() {
+        const filter = this.confirmItem.filter(item => item.option === 'gender').map(i => i.value);
+        return filter.length === 0 ? '' : filter[0];
+    }
 
-        await context.$service.home.recommendConsultantList().then((result: Agents[]) => {
-            consultantList = result;
-        })
+    get avgScore() {
+        const filter = this.confirmItem.filter(item => item.option === 'avgScore').map(i => i.value);
+        return filter.length === 0 ? '' : filter[0];
+    }
 
-        return {
-            consultantList,
-        }
+    get communicationStyles() {
+        return this.confirmItem.filter(item => item.option === 'communicationStyles').map(i => i.value);
+    }
+
+    isActive(name: string) {
+        return name === 'gender' && !!this.gender
+            || name === 'avgScore' && !!this.avgScore
+            || name === 'communicationStyles' && !!this.communicationStyles.length
     }
 
     openPopUp(question: QuestionOption) {
         this.questionOption = question;
-        isMobileDevice() ? this.questionDrawer = true : this.dialog = true;
+        this.isOpenQuestionPopUp =true;
     }
 
-    removeTag(type: string, index: number = 0) {
-
-        if (type === 'gender') {
-            this.selectedItem.gender = ''
-        }
-
-        if (type === 'satisfaction') {
-             this.selectedItem.satisfaction = 0
-        }
-
-        if (type === 'style') {
-            this.selectedItem.style.splice(index, 1)
-        }
-
+    removeTag(value: string) {
+        this.confirmItem = this.confirmItem.filter(item => item.value !== value);
+        this.confirmItem.length > 0 ? this.getRecommendList() : this.consultantList = [];
     }
 
-    closePopUp() {
-        this.selectedItem = JSON.parse(JSON.stringify((this.$refs.quickFilterRef as QuickFilterDrawer).pickedItem));
+    confirm(event: any) {
+        this.setConfirmData(event);
+        this.confirmItem.length > 0 ? this.getRecommendList() : this.consultantList = [];
+        this.isOpenQuestionPopUp = false;
+    }
+
+    setConfirmData(event: Selected) {
+        if (event.option === 'communicationStyles') {
+            this.filterCommunicationStyles(event);
+        } else {
+            const findIndex = this.confirmItem.findIndex(item => item.option === event.option);
+            findIndex === -1 ? this.confirmItem.push(event) : this.confirmItem[findIndex] = event;
+        }
+    }
+
+    filterCommunicationStyles(event: Selected) {
+        const confirmValue = this.confirmItem
+            .filter(item => item.option === 'communicationStyles')
+            .map(i => i.value);
+        const pickerValue = event.value;
+
+        this.confirmItem = this.confirmItem
+            .filter(item => pickerValue.includes(item.value) || item.option !== 'communicationStyles');
+
+        const addValue = pickerValue.filter(item => !confirmValue.includes(item)).map(i => {
+            return {
+                option: 'communicationStyles',
+                value: i
+            }
+        })
+        if (addValue.length > 0) {
+            this.confirmItem.push(...addValue);
+        }
+    }
+
+    getRecommendList() {
+        const data: FastQueryParams = {
+            gender: this.gender,
+            communicationStyles: this.communicationStyles,
+            avgScore: this.avgScore,
+            status: ''
+        }
+
+        fastQuery(data).then((res) => this.consultantList = res.data)
     }
 
 }
 
 export interface QuestionOption {
     title: string;
-    detail: string[];
+    detail: Detail[];
     type: string;
     name: string;
 }
 
-export interface selectedItem {
+interface Detail {
+    value: string;
     name?: string;
-    gender: string;
-    satisfaction: number;
-    style: string[];
-    onlineState: string;
+    className: string;
 }
+
 </script>
 
 <style lang="scss" scoped>
     .emptyBox {
         width: 100%;
         height: 100px;
-
         border: solid 1px $LIGHT_GREY;
         text-align: center;
+        border-radius: 10px;
 
         .smTxt {
             line-height: 100px;
         }
     }
 
-    .bg-white {
+    .recommendStyle {
+        box-shadow: 0 0 6px #00000029;
         background-color: $PRIMARY_WHITE;
     }
 
@@ -206,35 +234,27 @@
             height: 56px;
             text-align: center;
             box-shadow: 0 0 6px #22222229;
-            border-color: $PRIMARY_WHITE;
             border-radius: 10px;
-            color: $PRIMARY_BLACK;
+            border-color: $CORAL;
 
-            &:hover,&:focus {
-                color: $PRIMARY_BLACK;
-                border-color: $PRIMARY_WHITE;
-                background-color: $PRIMARY_WHITE;
-            }
-
-            &:disabled {
+            &.isActive {
+                background-color: $CORAL;
                 color: $PRIMARY_WHITE;
-                border-color: $LIGHT_GREY;
-                background-color: $LIGHT_GREY;
             }
         }
         .quickBtn+.quickBtn {
             margin-left: 0;
         }
 
-        .is-disabled {
-            background-color: $LIGHT_GREY;
-            color: $PRIMARY_WHITE;
+    }
 
-            &:hover,&:focus {
-                color: $PRIMARY_WHITE;
-                border-color: $LIGHT_GREY;
-                background-color: $LIGHT_GREY;
-            }
+    .recommend {
+        position: relative;
+
+        .img {
+            position: absolute;
+            top: -50px;
+            right: 10px;
         }
     }
 

--
Gitblit v1.8.0