import * as echarts from "echarts";
import { msgBoradTabel, msgBoradNum, responMsg } from "../../api/messageBoard"
import { privateOrder } from "../../api/pay"
import { Debounce } from "../../util/processingData"
export default {
    data() {
        return {
            from: [{
                id: 0,
                title: "标题1",
                source: "来源1",
                date: "2023-12-8",
            },
            {
                id: 0,
                title: "标题22",
                source: "来源222",
                date: "2023-12-7",
            },
            {
                id: 0,
                title: "标题22",
                source: "来源222",
                date: "2023-12-7",
            },
            {
                id: 0,
                title: "标题22",
                source: "来源222",
                date: "2023-12-7",
            },
            {
                id: 0,
                title: "标题22",
                source: "来源222",
                date: "2023-12-7",
            },
            {
                id: 0,
                title: "标题22",
                source: "来源222",
                date: "2023-12-7",
            },
            {
                id: 0,
                title: "标题22",
                source: "来源222",
                date: "2023-12-7",
            },
            {
                id: 0,
                title: "标题22",
                source: "来源222",
                date: "2023-12-7",
            },
            ],
            successData: [{
                id: 0,
                userDate: "",
                userName: "",
                msgPage: "",
                userMsg: ""


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


            }],
            params: {
                page: 1,
                limit: "300",
                status: ""
            },
            payHistories: false,
            activeName: "Unread",
            currentPage1: 1,
            pageSizes: [1, 50, 100,],
            totalLimit1: 3,
        }
    },
    mounted() {
        // this.params.status=2
        // this.fetchPrivateOrder2(this.params)
        // this.params.status=0
        // this.fetchPrivateOrder0(this.params)
        // this.params.status=1
        // this.fetchPrivateOrder1(this.params)
    },
    methods: {

        //请求支付历史 待处理
        async fetchPrivateOrder2(params) {
            this.payHistories = true
            const { data } = await privateOrder(params)
            this.from = data.rows
            this.payHistories = false

        },
        //请求支付历史 成功
        async fetchPrivateOrder1(params) {
            this.payHistories = true
            const { data } = await privateOrder(params)
            this.successData = data.rows
            this.payHistories = false

        },
        //请求支付历史 失败
        async fetchPrivateOrder0(params) {
            this.payHistories = true
            const { data } = await privateOrder(params)
            this.failData = data.rows
            this.payHistories = false

        },
        handelTime(time) {
            if (time) {
                return `${time.split("T")[0]} ${time.split("T")[1].split(".")[0]}`
            }
        },


        //点击刷新
        handelRefresh: Debounce(function () {
            this.params.status = 2
            this.fetchPrivateOrder2(this.params)
            this.params.status = 0
            this.fetchPrivateOrder0(this.params)
            this.params.status = 1
            this.fetchPrivateOrder1(this.params)
        }, 1000),

        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.params.limit = val
            this.params.page = 1
            switch (this.activeName) {
                case `pending`:
                    this.params.status = 1
                    this.fetchRepairList1(this.params)
                    break;
                case `toBeSent`:
                    this.params.status = 21
                    this.fetchRepairList21(this.params)
                    break;
                case `goodsToBeReceived`:
                    this.params.status = 3
                    this.fetchRepairList3(this.params)
                    break;
                case `receivedGoods`:
                    this.params.status = 4
                    this.fetchRepairList4(this.params)
                    break;
                case `Quoted`:
                    this.params.status = 5
                    this.fetchRepairList5(this.params)
                    break;
                case `ConfirmPaid`:
                    this.params.status = 20
                    this.fetchRepairList20(this.params)
                    break;
                case `Paid`:
                    this.params.status = 6
                    this.fetchRepairList6(this.params)
                    break;
                case `service`:
                    this.params.status = 7
                    this.fetchRepairList7(this.params)
                    break;
                case `toBeSentBack`:
                    this.params.status = 8
                    this.fetchRepairList8(this.params)
                    break;
                case `remand`:
                    this.params.status = 9
                    this.fetchRepairList9(this.params)
                    break;
                case `Completed`:
                    this.params.status = 10
                    this.fetchRepairList10(this.params)
                    break;

                default:
                    break;
            }
            this.currentPage1 = 1,
                this.currentPage3 = 1,
                this.currentPage4 = 1,
                this.currentPage5 = 1,
                this.currentPage6 = 1,
                this.currentPage7 = 1,
                this.currentPage8 = 1,
                this.currentPage9 = 1,
                this.currentPage10 = 1,
                this.currentPage20 = 1,
                this.currentPage21 = 1,




                this.currentPage = 1
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.params.page = val

            switch (this.activeName) {
                case `pending`:
                    this.params.status = 1
                    this.fetchRepairList1(this.params)
                    break;
                case `toBeSent`:
                    this.params.status = 21
                    this.fetchRepairList21(this.params)
                    break;
                case `goodsToBeReceived`:
                    this.params.status = 3
                    this.fetchRepairList3(this.params)
                    break;
                case `receivedGoods`:
                    this.params.status = 4
                    this.fetchRepairList4(this.params)
                    break;
                case `Quoted`:
                    this.params.status = 5
                    this.fetchRepairList5(this.params)
                    break;
                case `ConfirmPaid`:
                    this.params.status = 20
                    this.fetchRepairList20(this.params)
                    break;
                case `Paid`:
                    this.params.status = 6
                    this.fetchRepairList6(this.params)
                    break;
                case `service`:
                    this.params.status = 7
                    this.fetchRepairList7(this.params)
                    break;
                case `toBeSentBack`:
                    this.params.status = 8
                    this.fetchRepairList8(this.params)
                    break;
                case `remand`:
                    this.params.status = 9
                    this.fetchRepairList9(this.params)
                    break;
                case `Completed`:
                    this.params.status = 10
                    this.fetchRepairList10(this.params)
                    break;

                default:
                    break;
            }

        },



    }
}