// const app = getApp()
const app = {};
import downloadBtnIcon from '../../static/images/download.png';
import { mapState } from 'vuex';
import uni from '@/utils/uniHooks';
import { invoicesAgainSandEmail, invoiceEmails } from '@/api/parking';

export default {
  data() {
    return {
      picUrl: this.$picUrl,
      downloadBtnIcon: downloadBtnIcon,
      globalData: app.globalData,
      setTime: 60,
      timer: null,
      order: {},
      res: {},
      preUrl: '',
    };
  },
  created() {
    this.order = JSON.parse(this.$route.query.order);
    console.log('order::::', this.order)
  },
  mounted() {
    setTimeout(() => {
      uni.setNavigationBarTitle({
        title: '停车发票',
      });
    }, 300);
    setTimeout(() => {
      window?.toWXSendMsg({
        type: 'uni_func',
        funcName: 'setNavigationBarColor',
        options: {
          frontColor: '#000000',
          backgroundColor: '#FBFCFF',
        },
      });
    }, 500)
  },
  onUnload() {
    if (this.timer) {
      clearTimeout(this.timer);
      this.timer = null;
    }
  },
  computed: {
    ...mapState({
      custTypeId: (state) => state.custTypeId,
    }),
  },
  methods: {
    getEmail: async function () {
      try {
        const res = await invoiceEmails() 
        this.res = res
      } catch {
        uni.showToast({
          title: '未请求到邮箱信息',
          icon: 'none',
        });
      }
    },
    pushAgain: async function () {
      const id = this.order.id
      try {
        await invoicesAgainSandEmail(id)
        uni.showToast({
          title: '邮件已发送邮箱，请注意查收',
          icon: 'none',
          duration: 2000
        });
      } catch {
        uni.showToast({
          title: '服务器开小差了呢，请您稍后再试',
          icon: 'none',
        });
      }
    },
  },
};
