<template>
    <router-link
        :to="{
            path: '/assetDetail',
            query: {
                id: info.id
            }
        }"
        class="product"
        @click="click"
    >
        <van-image width="100%" height="calc(45vw - 21.6px)" :src="getImg(changeImgs(info.pic))" fit="cover" />

        <div class="content">
            <div class="name van-ellipsis">
                {{ info.name }}
            </div>
            <div class="price" v-if="info.status === 'ON_SALE'">
                <i class="font_family icon-icon_jiage"></i>{{ info.price }}
            </div>
            <div class="status" v-else-if="info.status === 'NORMAL'">
                {{ info.publicShow ? '仅展示' : '未展示' }}
            </div>
            <div class="status" v-else>
                {{ getLabelName(info.status, assetStatusOptions) }}
            </div>
            <div class="text">
                <van-image width="18" height="18" :radius="100" :src="info.minterAvatar" fit="cover" />
                <span>{{ info.minter }}</span>
                <!-- <div class="text1" v-if="info.type === 'BLIND_BOX'">
          <span>{{ info.sale }}/ </span>
          <span>{{ info.stock }}</span>
        </div>
        <div class="flex1"></div>
        <like-button :isLike="info.liked" @click="likeProduct">
          {{ info.likes }}
        </like-button> -->
            </div>
        </div>
    </router-link>
</template>

<script>
import asset from '../../mixins/asset';
import product from '../../mixins/product';

export default {
    mixins: [asset, product],
    props: {
        info: {
            type: Object,
            default: () => {
                return {};
            }
        }
    },
    setup() {
        const click = function () {
            console.log('wyt6w');
        };

        return { click };
    },
    methods: {
        likeProduct() {
            if (!this.info.liked) {
                this.$http.get(`/collection/${this.info.id}/like`).then(() => {
                    this.$emit('update:info', {
                        ...this.info,
                        liked: true,
                        likes: this.info.likes + 1
                    });
                    this.$toast.success('收藏成功');
                });
            } else {
                this.$http.get(`/collection/${this.info.id}/unlike`).then(() => {
                    this.$emit('update:info', {
                        ...this.info,
                        liked: false,
                        likes: this.info.likes - 1
                    });
                    this.$toast.success('取消收藏');
                });
            }
        }
    }
};
</script>

<style lang="less" scoped>
.product {
    width: calc(50vw - 24px);
    margin: 8px;
    background-color: @bg2;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;

    .van-image {
        overflow: hidden;
        display: block;
    }
    .content {
        padding: 10px;

        .name {
            font-size: 16px;
            font-weight: bold;
            color: #ffffff;
            line-height: 24px;
        }

        .status {
            font-size: 16px;
            color: #939599;
            line-height: 24px;
            margin-top: 6px;
        }

        .price {
            font-size: 24px;
            font-family: OSP;
            color: @prim;
            line-height: 22px;
            padding: 7px 0;

            i {
                vertical-align: text-bottom;
                font-size: 10px;
            }
        }
    }

    .text {
        display: flex;
        // justify-content: space-between;
        align-items: center;
        margin-top: 9px;
        .van-image {
            border-radius: 100px;
        }
        span {
            font-size: 12px;
            color: #939599;
            line-height: 24px;
            margin-left: 5px;
        }
    }
}
</style>
