<template>
    <view>
        <scroll-view class="wrapper" :style="{top: top + 'px'}" scroll-y refresher-enabled refresher-default-style="white"
            @refresherrefresh="pullRefresh" :refresher-triggered="refreshing" @scrolltolower="loadMore">
            <view v-if="tableData" class="paddingX14">
                <view v-for="(item, index) in tableData" :key="item.tradeGoodsId" class="cell marginB12 paddingX15 relative"
                    @click="showDetail(item)">
                    <view class="paddingT15 paddingB10 flex-align">
                        <image :src="item.cover" class="image flex-shrink0" mode="aspectFit" />
                        <view class="flex1 self-stretch paddingY5 flex-column-between paddingL12 color-white">
                            <view class="flex-align">
                                <view class="font4 line-ellipsis flex1 bold" style="width: 0">{{item.name}}</view>
                            </view>
                            <view class="flex-align font4">
                                <view>售价：¥</view>
                                <view class="bold flex1">{{item.price}}</view>
                                <image v-if="item.level" style="width: 110rpx; height: 32rpx" :src="LEVEL_MAP[item.level].titleText" />
                            </view>
                            <view class="flex-align font4">
                                <view>我的出价：¥</view>
                                <view class="bold flex1">{{item.bidPrice}}</view>
                            </view>
                        </view>
                    </view>
                </view>
            </view>
            <empty v-if="isEmpty" :top="200" light />
        </scroll-view>
        <change-price ref="changeRef" @success="onChangeSuccess"/>
    </view>
</template>
<script>
import { LEVEL_MAP } from '@/utils/config'
import tabbar2 from '@/components/tabbar2'
import empty from '@/components/empty'
import pageMixin from './../../mixin/page'
import resource from '@/utils/resource'
import changePrice from './change_price'

export default {
    mixins: [pageMixin],
    components: { empty, tabbar2, changePrice },
    data() {
        return {
            resource,
            LEVEL_MAP,
            refreshing: false
        }
    },
    computed: {
        top() {
            let height = this.$store.state.systemInfo.statusBarHeight + 36 + 50 + 5
            return height
        }
    },
    mounted() {
        this.refresh(true)
    },
    methods: {
        pullRefresh() {
            this.refreshing = true
            this.refresh()
        },
        async loadData(loading) {
            const res = await this.$service.sell.listBidMy(
                this.pageNum,
                this.pageSize,
                loading
            )
            setTimeout(() => {
                this.refreshing = false
            }, 1000)
            return res
        },
        showDetail(item) {
            if (item.status !== 1) return
            this.$router.push('sell_detail', { id: item.tradeGoodsId })
        }
    }
}
</script>
<style lang="scss" scoped>
.wrapper {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
}
.cell {
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0px 0px 5px 0px rgba(167, 110, 244, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    .line {
        height: 1px;
        opacity: 0.2;
        background: #e9d9ff;
    }
    .image {
        box-shadow: 0px 0px 5px 0px rgba(167, 110, 244, 0.5);
        border-radius: 8px;
        width: 180rpx;
        height: 180rpx;
    }
    .mask {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        background: rgba($color: #222335, $alpha: 0.6);
        .btn-delete {
            width: 88px;
            height: 30px;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 15px;
            border: 1px solid #a66ef4;
            color: #fff;
            font-size: 14px;
        }
        .btn-cm {
            width: 88px;
            height: 30px;
            background: linear-gradient(270deg, #d070ff 0%, #8b3dff 100%);
            border-radius: 15px;
            color: #fff;
            font-size: 14px;
        }
    }
    .status {
        width: 100rpx;
        height: 36rpx;
        position: absolute;
        right: 0;
        top: 0;
        z-index: 100;
    }
    .btn {
        height: 48rpx;
        line-height: 48rpx;
        text-align: center;
        padding: 0 20rpx;
        color: #fff;
        font-size: 28rpx;
        background: linear-gradient(270deg, #d070ff 0%, #8b3dff 100%);
        border-radius: 24rpx;
    }
}
</style>