Blame view

src/pages/custom-service/components/insurance-query.js 5.08 KB
joe committed
1
import { mapState } from "vuex";
1  
joe committed
2 3 4 5 6 7
import api from '@/api/api'
import {
    httpGet,
    httpPost
} from '@/api/fetch-api.js'

joe committed
8
import Auth from '@components/auth/auth.vue';
joe committed
9
import PolicyHeadList from "./policy-head-list.vue";
joe committed
10

1  
joe committed
11
import { formatMoney, getInsuredPeriod, getBenefitType, getPayPeriod, getPayType, getMoneyName, getPayMode, getPolicyName } from "@/utils/biz.js";
joe committed
12

1  
joe committed
13
export default {
1  
joe committed
14
    name: "InsuranceQuery",
1  
joe committed
15 16
    data() {
        return {
joe committed
17
            showForm: false,
joe committed
18
            dataForm: null,
1  
joe committed
19
            insuranceForm: {
1  
joe committed
20 21 22 23 24
                f1: true,
                f2: true,
                f3: true,
                f4: true,
                f5: true,
joe committed
25 26
            },
            policy: null,
1  
joe committed
27 28
        }
    },
1  
joe committed
29
    methods: {
joe committed
30 31 32 33 34 35 36 37 38
        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;
simon committed
39
                console.log("this.dataForm:",this.dataForm.productCode)
joe committed
40 41 42 43 44 45 46


                if (this.dataForm.clientNameCn) {
                    let userInfo = JSON.parse(JSON.stringify(this.userInfo));
                    userInfo.name = this.dataForm.clientNameCn
                    this.$store.commit("SET_USER_INFO", userInfo);
                }
joe committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
            }).catch(err => {
                if (err.code == 404) {
                    this.$refs.auth.noAuth();
                }
            });
        },
        toMoneyCode(moneyCode) {
            switch (moneyCode) {
                case "USD":
                    return "$";
                default:
                    return "HK$";
            }
        },
        toMoneyCodeName(moneyCode) {
            switch (moneyCode) {
                case "USD":
                    return "美元";
                default:
                    return "港币";
            }
        },
joe committed
69
        toModifyPage(type, toContact) {
joe committed
70 71 72 73 74 75 76 77
            // 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 } });
joe committed
78 79 80 81 82 83
            } 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 } });
                }
1  
joe committed
84
            }
joe committed
85
        },
joe committed
86 87 88 89 90 91
        formatMoney(s, t) {
            if (typeof t == "undefined") {
                t = 1;
            }
            return formatMoney(s, t);
        },
1  
joe committed
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
        // 保障年限,保n年
        formatInsuredPeriod(t, v) {
            return getInsuredPeriod(this.$i18n.locale, t, v);
        },
        formatBenefitType(t) {
            return getBenefitType(this.$i18n.locale, t);
        },
        // 缴费方式,交n年
        formatPayPeriod(t, v) {
            return getPayPeriod(this.$i18n.locale, t, v);
        },
        // 支付方式,支票xxx
        formatPayMode(v) {
            return getPayMode(this.$i18n.locale, v);
        },
        // 缴费频率
        formatPayType(v) {
            return getPayType(this.$i18n.locale, v);
        },
        // 钱的名字
        formatMoneyName(c) {
            return getMoneyName(this.$i18n.locale, c);
        },
        formatPanduPayPeriod(y, p) {
            switch (this.$i18n.locale) {
                case "zh":
                case "tc":
                    return "第" + y + "年第" + p + "期";
                default:
1  
joe committed
121
                    return this.formatNumber(p) + " payment in " + this.formatNumber(y) + " year";
1  
joe committed
122 123
            }
        },
joe committed
124 125 126
        formatPolicyName(c, n) {
            return getPolicyName(this.$i18n.locale, c, c);
        },
1  
joe committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
        formatNumber(p) {
            let pmod = p % 4;
            let pstr = p + "";
            switch (pmod) {
                case 0:
                    pstr += "th";
                    break;
                case 1:
                    pstr += "st";
                    break;
                case 2:
                    pstr += "nd";
                    break;
                case 3:
                    pstr += "rd";
                    break;
                default:
                    pstr += "th";
                    break;
            }
            return pstr;
        },
joe committed
149 150 151 152 153
        userLogout() {
            this.showForm = false;
        },
        userLogin(data) {
            this.showForm = true;
1  
joe committed
154 155
        }
    },
joe committed
156 157 158 159
    computed: {
        ...mapState({
            userInfo: state => state.userInfo
        }),
1  
joe committed
160 161 162
        i18n() {
            return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
        },
joe committed
163
    },
joe committed
164
    components: {
joe committed
165
        Auth,
joe committed
166
        PolicyHeadList,
joe committed
167
    },
1  
joe committed
168
}