import { TimeSelect } from "element-ui"

export default {
    data() {
        return {
            tableData: [],
            btctagsLoding: false,
            totalPage: 0,
            currentPage4: 1,//当前页数
            params: {
                req: "",
                page: 1,
                limit: 50
            },
            radius:"btc"

        }
    },
    watch:{
        radius(val){
            if (val=="BTC") {
                this.params.req="btcTags"
                
            }else if (val=="ETH") {
                this.params.req="ethTags"
            }
            let radius = val.toLowerCase()
           
            this.fetchTabelData(this.params.req, radius, this.params.page, this.params.limit)
        }
    },
    mounted() {
        //不显示时间框
         this.$addStorageEvent(1, "timeShow", false);
        let menuObj = localStorage.getItem("params");
        this.params.req = JSON.parse(menuObj).componentReq;
        this.radius = localStorage.getItem("radius");
   
        //监听localstorage变化
        window.addEventListener("setItem", () => {
            let menuObj = localStorage.getItem("params");
            this.params.req = JSON.parse(menuObj).componentReq;
            this.radius = localStorage.getItem("radius");
            // this.introduce = JSON.parse(menuObj).introduce;
        });
        // this.fetchTabelData(this.params.req, this.radius, this.params.page, this.params.limit)
    },
    methods: {
        async fetchTabelData(req, radius, page,limit) {
           
            this.btctagsLoding = true
            this.currentPage4 = page
            const { data } = await this.$API.getBtctags(req, radius, page,limit);
            this.tableData = data.data.data
            this.totalPage = data.data.totalPage

            this.btctagsLoding = false
        },
        //点击的改变页数
        handleCurrentChange(value) {
            this.params.page = value
            this.fetchTabelData(this.params.req, this.radius, this.params.page, this.params.limit)
            this.params.page = 1
            this.currentPage4 = this.params.page
        },
        //改变每页条数
        handleSizeChange(val) {
            this.params.limit = val
            this.fetchTabelData(this.params.req, this.radius, this.params.page,val)
            // this.params.limit = 50

        },
    }
}