import { mapState } from "vuex"; 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"; import { formatMoney, getInsuredPeriod, getBenefitType, getPayPeriod, getPayType, getMoneyName, getPayMode, getPolicyName } from "@/utils/biz.js"; 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; if (this.dataForm.clientNameCn) { let userInfo = JSON.parse(JSON.stringify(this.userInfo)); userInfo.name = this.dataForm.clientNameCn this.$store.commit("SET_USER_INFO", userInfo); } }).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 "港币"; } }, 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 } }); } } }, formatMoney(s, t) { if (typeof t == "undefined") { t = 1; } return formatMoney(s, t); }, // 保障年限,保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: return this.formatNumber(p) + " payment in " + this.formatNumber(y) + " year"; } }, formatPolicyName(c, n) { return getPolicyName(this.$i18n.locale, c, c); }, 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; }, userLogout() { this.showForm = false; }, userLogin(data) { this.showForm = true; } }, computed: { ...mapState({ userInfo: state => state.userInfo }), i18n() { return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {}; }, }, components: { Auth, PolicyHeadList, }, }