clarms-plugins-verifyform.js 3.93 KB
import { mapState } from "vuex";
import api from '@/api/api'
import {
    httpGet,
    httpPost,
    formdata
} from '@/api/fetch-api.js'

import { getPolicyIdTypeList } from '@/utils/biz.js';
import Vue from 'vue';
import DatePicker from '@/components/date-picker/date-picker.vue';
import { Loading } from 'vant';
import { Select, Option } from 'element-ui';

Vue.use(Select);
Vue.use(Option);
Vue.use(Loading);

export default {
    data() {
        return {
            birthdayIllegal: false,
            loading: false,
            showTips: false,
            data: {
                firstName: "玛丽",
                lastName: "何",
                birthDate: "1999-07-15",
                idNo: "H4099030",
                idType: "40"

                // firstName: "",
                // lastName: "",
                // birthDate: "",
                // idNo: "",
                // idType: ""
            }
        }
    },
    components: {
        DatePicker
    },
    computed: {
        ...mapState({
            userInfo: state => state.userInfo,
            policyList: state => state.policyList
        }),
        i18n() {
            return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
        },
        policyIdTypeList() {
            return getPolicyIdTypeList(this.$i18n.locale);
        },
        btnDisabled() {
            let b1 = this.data.firstName ? false : true;
            let b2 = this.data.lastName ? false : true;
            let b3 = this.data.birthDate ? false : true;
            let b4 = this.data.idType ? false : true;
            let b5 = this.data.idNo ? false : true;
            let b6 = this.birthdayIllegal;
            return b1 || b2 || b3 || b4 || b5 || b6;
        }
    },
    methods: {
        initData() {

        },
        checkDate(data) {
            this.birthdayIllegal = data.disable;
        },
        toRegisterPage() {
            this.$router.push({
                path: "/register"
            });
        },
        toLoginPage() {
            this.$router.push({
                path: "/login"
            });
        },
        toContactUs() {
            this.$router.push({
                path: "/custom/service?q=m1"
            });
        },
        handleConfirm() {
            if (this.btnDisabled) {
                return;
            }
            if (this.loading) {
                return;
            }
            this.loading = true;
            httpPost({ url: api.getCidByVerify, data: this.data }).then(res => {
                if (res) {
                    let cid = res;
                    httpPost({ url: api.clarmsCustomerList, data: { cid: cid } }).then(res => {
                        this.loading = false;
                        if (res && res.insuredInfoList && res.insuredInfoList.length > 0) {
                            sessionStorage.setItem("clarmsRequestCid", cid);
                            this.$emit("insuredInfoList", { cid: cid, list: res.insuredInfoList });
                        } else {
                            this.showTips = true;
                        }
                    }).catch(e => {
                        this.loading = false;
                        this.showTips = true;
                    });
                } else {
                    this.loading = false;
                    this.showTips = true;
                }
            }).catch(e => {
                this.loading = false;
            });
        }
    },
    watch: {
        'data.firstName': function () {
            this.showTips = false;
        },
        'data.lastName': function () {
            this.showTips = false;
        },
        'data.birthDate': function () {
            this.showTips = false;
        },
        'data.idNo': function () {
            this.showTips = false;
        },
        'data.idType': function () {
            this.showTips = false;
        },
    },
    mounted() {
        this.initData();
    },
    created() { }
}