<template>
    <div class="identification_page">
        <div>密钥：<input type="text" autofocus /></div>
        <div class="button" @click="getFingerprint2">记录浏览器</div>
    </div>
</template>
<script lang="ts">
import { defineComponent, ref, createVNode, computed } from "vue";
import { setCookie, getCookie, WriteCookie } from "@/tool/cookie";
import HeaderComponent from "@/component/HomePage/Header.vue";
import HistoryDetail from "@/component/Detail/HistoryDetail.vue";
import router from "@/router/index";
import { Https } from "@/tool/https";
import { formatTime, getBrowserInfo } from "@/tool/util";
import { Modal, message } from "ant-design-vue";
import RobotAssist from "@/component/HomePage/RobotAssist.vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import { useI18n } from "vue-i18n";
import Fingerprint2 from "fingerprintjs2"; //获取浏览器唯一标识
export default defineComponent({
    components: {
        HeaderComponent,
        HistoryDetail,
        RobotAssist,
    },
    setup() {
        let collectionList: any = ref([]);
        let userInfo: any = {};
        let status: any = ref(0);
        let voluntarily: any = ref(false);
        return {
            collectionList,
            userInfo,
            status,
            voluntarily,
        };
    },
    data() {
        return {};
    },
    mounted() {
        // this.userInfo = JSON.parse(getCookie("userInfo") as any);
        // if (this.userInfo.userId == 83) {
        // } else {
        // 	router.replace("/home");
        // 	return
        // }
    },
    methods: {
        async getFingerprint2() {
			let murmur:any = ''
			await new Promise((resolve,reject)=>{
				Fingerprint2.get(function (components: any) {
					const values = components.map(function (
						component: any,
						index: any
					) {
						if (index === 0) {
							//把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样
							return component.value.replace(/\bNetType\/\w+\b/, "");
						}
						return component.value;
					});
					// 生成最终id murmur
					murmur = Fingerprint2.x64hash128(values.join(""), 31);
					console.log("浏览器指纹码：" + murmur);
					resolve('')
				});
			})
            
			let data = {}
			console.log(11);
			// Https.axiosPost(Https.httpUrls.designSingle, data)
			// 	.then((rv) => {
			// 		// designItemDetail.clothes[index].printObject.path = rv.clothes[0].printObject.path
			// 	})
			// 	.catch((res) => {
			// 	});
        },
    },
});
</script>
<style lang="less">
.identification_page {
    margin-top: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    input {
        padding-left: 10px;
        border: 2px solid rgba(0, 0, 0, 0.2);
        border-radius: 10px;
    }
    .button {
        margin-top: 20px;
        border: 2px solid;
        border-radius: 20px;
        padding: 0 20px;
        cursor: pointer;
    }
}
</style>