<template>
    <div class="discover">
        <van-sticky ref="top" :offset-top="bar.value && bar.value.show ? barHeight : 0">
            <!-- <div class="top">
                <div class="top-btn">
                    <div class="btn" :class="{ active: type === 'DEFAULT' }" @click="changeActive('DEFAULT')">
                        作品订单
                    </div>
                    <div class="btn" :class="{ active: type === 'BLIND_BOX' }" @click="changeActive('BLIND_BOX')">
                        盲盒订单
                    </div>
                </div>
            </div> -->

            <van-tabs v-model:active="status" :ellipsis="false" line-width="16" line-height="2" @click="changeStatus">
                <van-tab v-for="(item, index) in tabs" :key="index" :title="item.name" :name="item.status"></van-tab>
            </van-tabs>
        </van-sticky>

        <van-list class="list" v-model:loading="loading" :finished="finished" finished-text="- 更多藏品敬请期待 -" @load="getData">
            <order-info-act
                @delFn="delFn"
                v-for="(item, index) in list"
                :key="item.id"
                v-model:info="list[index]"
            ></order-info-act>
            <van-empty v-if="empty" description="你还没有订单哦~" :image="require('@assets/kong_png_wudingdan.png')" />
        </van-list>
    </div>
</template>

<script>
import OrderInfoAct from '../../components/order/OrderInfoAct.vue';
import list from '../../mixins/list';
export default {
    name: 'discover',
    inject: ['bar','barHeight'],
    mixins: [list],
    components: {
        OrderInfoAct
    },
    data() {
        return {
            active: 'explore',
            stiky: null,
            status: 'PROCESSING,FINISH',
            type: 'DEFAULT',
            list: [],
            tabs: [
                {
                    status: 'DELIVERY,RECEIVE,AIR_DROP,FINISH',
                    name: '全部'
                },
                {
                    status: 'DELIVERY,',
                    name: '待发货'
                },
                {
                    status: 'AIR_DROP,',
                    name: '待空投'
                },
                {
                    status: 'RECEIVE',
                    name: '待收货'
                },
                {
                    status: 'FINISH',
                    name: '已完成'
                }
            ],
            url: '/mintOrder/all'
        };
    },
    mounted() {
        if (this.$route.query.status) {
            this.status = this.$route.query.status;
        }
    },
    methods: {
        beforeData() {
            return {
                query: {
                    userId: this.$store.state.userInfo.id,
                    status: this.status,
                    // type: this.type,
                    hide: false,
                    del: false
                }
            };
        },
        delFn() {
            console.log('删除成功');
            this.getData(true);
            this.beforeData();
        },
        changeStatus(name) {
            this.$router.replace({
                path: '/activityOrders',
                query: {
                    status: name,
                    type: this.type
                }
            });
            this.getData(true);
        },
        changeActive(type) {
            this.$router.replace({
                path: '/orders',
                query: {
                    status: this.status,
                    type: type
                }
            });
            this.type = type;
            this.getData(true);
        }
    }
};
</script>

<style lang="less" scoped>
.top {
    display: flex;
    padding: 10px 16px;
    background-color: @bg;
    align-items: center;
    .top-btn {
        flex-grow: 1;
        .flex();
        .btn {
            font-size: @font3;
            line-height: 26px;
            display: inline-block;
            vertical-align: text-bottom;

            &.active {
                color: @prim;
                font-size: @font3;
                font-weight: bold;
                line-height: 30px;
            }
        }

        .btn + .btn {
            margin-left: 30px;
        }
    }
}

.discover {
    background-color: @bg3;
    min-height: var(--app-height);
}

.list {
    padding-bottom: 100px;
}
/deep/.van-tab {
    margin-right: 30px;
}
/deep/.van-list__finished-text{
    font-size: 12px;
}
/deep/.van-tabs__nav--line.van-tabs__nav--complete {
    border-color: @tabBorder;
}
.grid-img {
    display: block;
}
.van-grid {
    margin-top: 12px;
}
/deep/ .van-grid-item__content {
    padding: 14px 20px 16px;
}
/deep/ .van-grid-item__text {
    color: #fff;
    font-size: 13px;
    line-height: 18px;
    margin-top: 4px;
}

.title {
    padding: 16px 20px 8px;
    color: @prim;
    font-size: 18px;
    font-weight: bold;
}

.box-list {
    // display: flex;
    // flex-wrap: wrap;
    padding: 0 8px;
}

.discover {
    padding-bottom: 50px;
}
.van-tabs {
    background-color: @bg;
}
</style>
