<template>
    <view class="book-item">
        <view class="book-info">
            <image class="book-cover" :src="book.cover" mode="aspectFill" />
            <view class="book-detail">
                <view class="top-info">
                    <view class="book-title">{{ book.bookName }}</view>
                    <view class="book-tags">
                        <text class="tzs tag-text" v-if="book.suit == 1">套装书</text>
                        <text class="kmdb tag-text" v-if="book.maxNum > 1">可卖多本</text>
                    </view>

                    <view class="flex flex-j-b flex-a-c mt-20" v-if="!isReturn">
                        <view class="book-price">预估价： ¥{{ book.expectMoney }}</view>
                        
                        <view class="has-upsell" v-if="book.upsellFinalMoney">
                            限时加价 {{ book.upsellFinalMoney }} 元
                            <image
                                src="/static/img/activity/up3.png"
                                mode="aspectFill"
                                style="width: 22rpx; height: 16rpx; margin-left: 6rpx"
                            />
                        </view>

                        <view class="has-upsell" v-if="!book.upsellFinalMoney && book.upsellExpectMoney">
                            限时加价 {{ book.upsellExpectMoney }} 元
                            <image
                                src="/static/img/activity/up3.png"
                                mode="aspectFill"
                                style="width: 22rpx; height: 16rpx; margin-left: 6rpx"
                            />
                        </view>

                        <view class="has-upsell" v-if="!book.upsellFinalMoney && book.currUpsellMoney">
                            限时加价 {{ book.currUpsellMoney }} 元
                            <image
                                src="/static/img/activity/up3.png"
                                mode="aspectFill"
                                style="width: 22rpx; height: 16rpx; margin-left: 6rpx"
                            />
                        </view>
                    </view>
                </view>
                <view v-if="isReturn" class="book-price">退回信息</view>
                <template v-else>
                    <view class="book-price" v-if="book.auditCommentList && book.auditCommentList.length">审核信息</view>
                    <view v-else class="book-price">暂无审核信息</view>
                </template>
            </view>
            <view class="delete-btn">
                <text>×{{ book.num || book.refundNum }}</text>
            </view>
        </view>
        <view class="mt-10" style="padding-left: 150rpx;">
            <view class="audit-info" v-if="isReturn">
                <view class="audit-item" v-for="(comment, index) in book.commentCom" :key="index">
                    <view class="audit-reason" v-if="comment">
                        原因：{{ comment }}
                    </view>
                </view>
            </view>
            <template v-else>
                <view class="audit-info" v-if="book.auditCommentList && book.auditCommentList.length">
                    <view class="audit-item" v-for="(audit, index) in book.auditCommentList" :key="index">
                        <view class="flex-a w100">
                            <view class="flex-a flex-1">
                                <view class="common-text-2 mr-16">第{{ index + 1 }}本</view>
                                <view class="audit-status" :class="audit.sts == 1 ? 'status-good' : 'status-bad'">
                                    {{ audit.sts == 1 ? '良好' : '不良' }}
                                </view>
                            </view>
                            <view class="audit-price flex-1"><text class="common-text-2">审核：</text> ¥{{ audit.sts == 1 ?
                                book.recyclePrice||0 : 0 }}
                            </view>
                        </view>
                        <view class="audit-reason" v-if="audit.com">
                            原因：{{ audit.com }}
                        </view>
                    </view>
                </view>
            </template>
        </view>

        <common-dialog ref="deleteDialog" title="温馨提示" @confirm="confirmDelete">
            <text>确定删除这本图书吗？</text>
        </common-dialog>
    </view>
</template>

<script>
import commonDialog from '@/components/common-dialog.vue';
export default {
    components: {
        commonDialog
    },
    props: {
        book: {
            type: Object,
            required: true
        },
        isReturn: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {}
    },
    methods: {

    }
}
</script>

<style lang="scss" scoped>
.book-item {
    background: #FFFFFF;
    margin-bottom: 30rpx;
    border-radius: 10rpx;

    .has-upsell{
        font-size: 22rpx;
        padding: 2rpx 10rpx;
        border-radius: 4rpx;
        margin-right: 10rpx;
        display: inline-flex;
        align-items: center;
        color: #276f1e;
        background-color: #a8dda2;
    }

    .tag-text {
        font-family: Source Han Sans CN;
        font-weight: 400;
        font-size: 24rpx;
        color: #FFFFFF;
    }

    .tzs {
        width: 91rpx;
        height: 30rpx;
        background: linear-gradient(263deg, #98E05F, #0DE3AC);
        border-radius: 2rpx;
        padding: 4rpx 10rpx;
        margin-right: 10rpx;
    }

    .kmdb {
        width: 117rpx;
        height: 30rpx;
        background: linear-gradient(263deg, #F7CB6B, #FBA980);
        border-radius: 2rpx;
        padding: 4rpx 10rpx;
        margin-right: 10rpx;
    }

    .book-info {
        display: flex;
        position: relative;

        .book-cover {
            width: 140rpx;
            height: 196rpx;
            border-radius: 8rpx;
        }

        .book-detail {
            flex: 1;
            margin-left: 20rpx;
            display: flex;
            flex-direction: column;
            justify-content: space-between;

            :v-deep .u-number-input {
                background: #F9F9F9 !important;
                border-radius: 6rpx;
            }

            .book-title {
                max-width: 400rpx;
                font-size: 28rpx;
                color: #333;
                line-height: 1.4;
                margin-bottom: 20rpx;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
                overflow: hidden;
                font-family: Source Han Sans CN;
                font-weight: 400;
            }

            .book-price {
                font-family: Source Han Sans CN;
                font-weight: 400;
                font-size: 24rpx;
                color: #999999;
            }
        }

        .delete-btn {
            position: absolute;
            right: 0;
            top: -10rpx;
            padding: 10rpx;
        }
    }

    .audit-info {
        min-height: 60rpx;
        background: #FAFAFA;
        border-radius: 10rpx;
        padding: 12rpx 20rpx;
        box-sizing: border-box;

        .audit-item {
            margin-bottom: 6rpx;
            font-size: 24rpx;
            line-height: 42rpx;
        }

        .audit-status {
            margin-right: 20rpx;

            &.status-good {
                color: #67C23A;
            }

            &.status-bad {
                color: #F56C6C;
            }
        }

        .audit-price {
            color: #F56C6C;
        }

        .audit-reason {
            font-size: 26rpx;
            color: #999;
            font-weight: 400;
            font-family: PingFang SC;
            margin-top: 6rpx;
        }
    }
}
</style>