import request from "../../../../../../core/utils/request";
import { accountinfoUrl } from "../../../../../../core/utils/constants";
import monitor from "../../../../../../core/utils/alipayLogger";
Component({
  props: {
    onSuccess: () => {},
    componentData: {}
  },
  data: {
    showAmount: true,
    accountBalance: '',
    name: '',
    idCardNo: '',
    status: '',
    company: '',
    individualNo: '',
    InsuredTime: '',
    InsuredArea: ''
  },

  async didMount() {
    const params = {
      isShowLoadig: true,
      isShowError: true,
      method: 'GET',
      url: accountinfoUrl
    };
    const startTime = Date.now();
    const [err, res = {}] = await request(params);
    const endTime = Date.now();
    const time = endTime - startTime;
    if (err) return;
    monitor.api({
      api: '参保状态',
      success: true,
      c1: "taSR_YL",
      time
    });
    monitor.api({
      api: '账户余额',
      success: true,
      c1: "taSR_YL",
      time
    });
    this.setData({ ...res
    }, () => {
      // callback 重新计算吸顶高度
      this.props.onSuccess();
    });
  },

  methods: {
    onChangeEye() {
      this.setData({
        showAmount: !this.data.showAmount
      });
    },

    onInfo() {
      const {
        serviceList = []
      } = this.props.componentData;
      const {
        url,
        urlType,
        accessMode
      } = serviceList[0] || {};
      const payload = {
        url,
        urlType,
        accessMode
      };

      if (url) {
        return this.$page.dispatchGlobal('handleJumpService', payload);
      }
    }

  }
});