insurance-query.js 2.49 KB
import api from '@/api/api'
import {
    httpGet,
    httpPost
} from '@/api/fetch-api.js'

import Auth from '@components/auth/auth.vue';
import PolicyHeadList from "./policy-head-list.vue";

export default {
    name: "InsuranceQuery",
    data() {
        return {
            showForm: false,
            dataForm: null,
            insuranceForm: {
                f1: true,
                f2: true,
                f3: true,
                f4: true,
                f5: true,
            },
            policy: null,
        }
    },
    methods: {
        handlePolicySelect(data) {
            let submitData = {
                policyId: data[0].id,
                policyCode: data[0].code
            }
            this.policy = submitData;
            this.dataForm = null;
            httpPost({ url: api.policyDetail, sid: true, data: submitData }).then(res => {
                this.dataForm = res;
            }).catch(err => {
                if (err.code == 404) {
                    this.$refs.auth.noAuth();
                }
            });
            // console.log(data);
        },

        toMoneyCode(moneyCode) {
            switch (moneyCode) {
                case "USD":
                    return "$";
                default:
                    return "HK$";
            }
        },
        toMoneyCodeName(moneyCode) {
            switch (moneyCode) {
                case "USD":
                    return "美元";
                default:
                    return "港币";
            }
        },
        toModifyPage(type, toContact) {
            // 1=受保人;2=投保人
            if (!this.policy || !this.dataForm) {
                return;
            }
            let data = encodeURIComponent(JSON.stringify({ id: this.policy.policyId, code: this.policy.policyCode }));
            sessionStorage.setItem("_hklife_policy", data);
            if (type == 1) {
                this.$router.push({ path: "/custom/service", query: { q: "m43", u: 2 } });
            } else {
                if (1 == toContact) {
                    this.$router.push({ path: "/custom/service", query: { q: "m42" } });
                } else {
                    this.$router.push({ path: "/custom/service", query: { q: "m43", u: 1 } });
                }
            }
        },
        userLogout() {
            this.showForm = false;
        },
        userLogin(data) {
            this.showForm = true;
        }
    },
    components: {
        Auth,
        PolicyHeadList
    },
    mounted() {
    },
}