import * as echarts from "echarts";
import { msgBoradTabel, msgBoradNum, responMsg } from "../../api/messageBoard"
import { allAddCreditOrder } from "../../api/pay"
import { Debounce } from "../../util/processingData"
export default {
    data() {
        return {
            from0: [{
                id: 0,
                userDate: "",
                userName: "",
                msgPage: "",
                userMsg: ""


            }],
            from1: [{
                id: 0,
                userDate: "",
                userName: "",
                msgPage: "",
                userMsg: ""


            }],
            from2: [{
                id: 0,
                userDate: "",
                userName: "",
                msgPage: "",
                userMsg: ""


            }],
            params: {
                page: 1,
                limit: 300,
                status: 0,
                address: "",
            },
            rechargeRecord: false,
            activeName:"pending",


        }
    },
    mounted() {
        this.params.status = 0
        this.fetchRechargeRecord0(this.params)
        this.params.status = 1
        this.fetchRechargeRecord1(this.params)
        this.params.status = 2
        this.fetchRechargeRecord2(this.params)
    },
    methods: {

        //请求支付历史 支付成功
        async fetchRechargeRecord0(params) {
            this.rechargeRecord = true
            const { data } = await allAddCreditOrder(params)
            this.from0 = data.rows
            this.rechargeRecord = false

        },
        //请求支付历史 支付失败
        async fetchRechargeRecord1(params) {
            const { data } = await allAddCreditOrder(params)
            this.from1 = data.rows

        },
        //请求支付历史 待处理
        async fetchRechargeRecord2(params) {
            const { data } = await allAddCreditOrder(params)
            this.from2 = data.rows

        },
        handelTime(time) {
            if (time) {
                return `${time.split("T")[0]} ${time.split("T")[1].split(".")[0]}`
            }
        },
        //点击搜索
        handelSearch(status) {
            for (const key in this.params) { //判空
                if (key !== `status` && this.params[key] == "") {
                    this.$message({
                        message: this.$t(`pay.search`),
                        type: "error",
                    });
                    return
                }
            }
            switch (status) {
                case 0:
                  this.params.status = 0
                  this.fetchRechargeRecord0(this.params)
                  break;
                  case 1:
                    this.params.status = 1
                    this.fetchRechargeRecord1(this.params)
                  
                  break;
                  case 2:
                    this.params.status = 2
                    this.fetchRechargeRecord2(this.params)
                  break;
              
                default:
                  break;
              }
        
         
            
        },


        //点击刷新
        handelRefresh: Debounce(function () {
            this.params.status = 0
            this.fetchRechargeRecord0(this.params)
            this.params.status = 1
            this.fetchRechargeRecord1(this.params)
            this.params.status = 2
            this.fetchRechargeRecord2(this.params)
        }, 1000),
        handleClick(){
            this.params.address = ""
          }

    }
}