
export default {
    data() {
        return {
            newContractLoading: false,
            params: {
                req: "newContract",
                radius: "ETH",
            },
            newContractData: [],
            page: 1,
            limit: 50,
            currentPage4: 1,
            totalPage: 0,
            value: "",
            state:"",

        }
    },
    mounted() {
        //不显示时间框
        this.$addStorageEvent(1, "timeShow", false);
        this.fetchCnewContract(this.params.req, this.params.radius, this.page, this.limit)
    },
    methods: {

        async fetchCnewContract(req, radius, page, limit,total) {
            this.newContractLoading = true
            const { data } = await this.$API.getNewContract(req, radius, page, limit,total)
            this.newContractData = data.data.data

            this.totalPage = data.data.totalPage
            this.currentPage4 = page

            this.newContractLoading = false
        },

        formatTime(time) {
            let date = time.split("T")[0]
            let hour = time.split("T")[1].split(".")[0]
            return `${date} ${hour}`
        },
        //点击的改变页数
        handleCurrentChange(value) {
            this.page = value;
            this.fetchCnewContract(this.params.req, this.params.radius, this.page, this.limit)
        },
        //改变每页条数
        handleSizeChange(val) {
            this.page = 1;
            this.limit = val;
            this.fetchCnewContract(this.params.req, this.params.radius, this.page, this.limit)

        },
        //双击表格单元格复制
        cellDblclick(row, column, cell, event) {
            if (event.type === "dblclick") {
                var save = (e) => {
                    e.clipboardData.setData("text/plain", event.target.innerText);
                    e.preventDefault(); //阻止默认行为
                };
                document.addEventListener("copy", save);
                document.execCommand("copy");
                document.removeEventListener("copy", save);
            }
            this.$message({ message: this.$t(`home.copy`), type: "success" }); //加提示
        },
  
        //搜索框输入参数     
        handelSearch() {
            this.page = 1;
            this.fetchCnewContract(this.params.req, this.params.radius, this.page, this.limit, this.state)
            // this.state = ""
        },


    }
}