<template>
    <div class="qrcode">
        <qrcode @success="success" />
    </div>
</template>
<script>
import { getFun, postFun } from "@/service/table.js";
export default {
    components: {
        // 注册
        qrcode: () => import("@/components/QrCodeReader"),
    },
    mounted() {},
    methods: {
        success(val) {
            // alert(val);
            let formdata = new FormData();
            formdata.append("activityid", val);
            postFun("/train/sign", formdata)
                .then((res) => {
                    this.$toast.clear();
                    // this.$toast.success("扫码成功");
                    let obj ={
                      签到成功:'success',
                      签到失败:'fail',
                      重复签到:'warn'
                    }
                    this.$router.replace({
                      name:obj[res.data.details],
                      query:{
                        text:res.data.details
                      }
                    })
                })
                .catch(() => {
                    this.$toast.clear();
                    this.$toast.fail("扫码失败,请稍后再试");
                });
        },
    },
};
</script>