/* eslint-disable no-empty */
<template>
    <!-- <TopNavigation/> -->
    <div class="detail_content">
        <!-- <swiper pagination class="mySwiper" v-if="banners.length > 0">
            <swiper-slide v-for="(item, index) in banners" :key="index">
                <video
                    class="swiper-video"
                    v-if="isVideo(item)"
                    :src="item.url"
                    :poster="getImg(changeImgs([item]), '', 1200)"
                    controls="controls"
                >
                    您的浏览器不支持 video 标签。
                </video>
                <van-image
                    v-else
                    @click="preview(index, changeImgs(banners))"
                    :src="getImg(item.url, '', 1200)"
                    width="100vw"
                    height="100vw"
                    fit="scale-down"
                />
            </swiper-slide>
        </swiper> -->
        <!-- <div class="detail_content_img">
            <video
                    class="swiper-video"
                    v-if="isVideo(item)"
                    :src="item.url"
                    :poster="getImg(changeImgs([item]), '', 1200)"
                    controls="controls"
            >
                    您的浏览器不支持 video 标签。
                </video>
                <van-image
                    v-else
                    @click="preview(index, changeImgs(banners))"
                    :src="getImg(item.url, '', 1200)"
                    width="100vw"
                    height="100vw"
                    fit="scale-down"
                />
        </div> -->
        <!-- <img src="" alt="" class="detail_content_img" />
        <div class="detail_content_one">
            <div class="detail_content_point">
                <img :src="info.liked == true ? likes : noLikes" alt="" class="detail_content_point_img" />
                <div class="detail_content_point_number">{{ info.likes }}</div>
            </div>
            <div class="detail_content_share">
                <img :src="require('@assets/icon-share.png')" alt="" class="detail_content_share_img" />
                <div class="detail_content_share_con">分享</div>
            </div>
        </div> -->
        <product-banner :info="info" pageType="asset"></product-banner>
        <div :class="!!info.model3d ? 'detail_content_title' : 'detail_content_title_one'">{{ info.name }}</div>
        <div class="item_number">
            <div class="item_number_collection">{{ info.category }}</div>
            <div class="item_number_number">编号&nbsp;{{ info.number }}</div>
        </div>
        <div class="self_information">
            <div class="display_price">
                <div v-if="info.consignment" class="display_price_con">
                    <div class="display_price_left">售价</div>
                    <div class="display_price_right">
                        <div class="display_price_right_symbol">¥</div>
                        <div class="display_price_right_number">{{ info.sellPrice || 0 }}</div>
                    </div>
                </div>
                <div class="display_price_title" v-else-if="info.status == 'NORMAL'">
                    {{ info.publicShow ? '当前仅展示' : '当前未展示' }}
                </div>
            </div>
            <div class="self_information_one">
                <div class="self_information_one_con">
                    <van-image
                        width="32px"
                        height="32px"
                        radius="23"
                        :src="info.minterAvatar || require('@assets/svgs/img_default_photo.svg')"
                        fit="cover"
                    />
                    <div class="self_information_one_text">
                        <div class="self_information_one_text_one">{{ info.minter }}</div>
                        <div class="self_information_one_text_two">创作者</div>
                    </div>
                </div>
                <div class="split_line"></div>
                <div class="self_information_one_con">
                    <van-image
                        width="32px"
                        height="32px"
                        radius="23"
                        :src="userInfo.avatar || require('@assets/svgs/img_default_photo.svg')"
                        fit="cover"
                    />
                    <div class="self_information_one_text">
                        <div class="self_information_one_text_one">{{ userInfo.nickname }}</div>
                        <div class="self_information_one_text_two">持有者</div>
                    </div>
                </div>
            </div>
            <div class="description_of_works">
                <div class="description_of_works_title">作品描述</div>
                <div class="description_of_works_text" v-html="info.detail"></div>
                <!-- <div >{{title}}</div>
                <img :src="require('@assets/commodity-background-map.png')" alt="" class="description_of_works_img"> -->
            </div>
            <!-- 持有特权 -->
            <div class="hold_privileges">
                <div class="hold_privileges_title">
                    持有特权<span class="hold_privileges_tip">(灰色表示已使用)</span>
                </div>
                <div class="hold_privileges_name" v-if="privileges.length == 0">创作者者暂时未设置</div>
                <div class="hold_privileged_information" v-else>
                    <div class="hold_privileged_information_con" v-for="(item, index) in privileges" :key="index">
                        <van-image
                            width="18px"
                            height="18px"
                            :src="item.icon[0]"
                            fit="cover"
                            class="hold_privileged_information_con_img"
                        />
                        <!-- <img :src="item.icon[0]" alt="" class="hold_privileged_information_con_img" /> -->
                        <div class="hold_privileged_information_con_title">{{ item.name }}</div>
                    </div>
                </div>
            </div>
            <!-- 作品特性 -->
            <div class="hold_privileges">
                <div class="hold_privileges_title">作品特性</div>
                <div class="hold_privileges_name" v-if="properties.length == 0">创作者者暂时未设置</div>
                <div class="digital_equity_card" v-else>
                    <div class="digital_equity_card_con" v-for="(item, index) in properties" :key="index">
                        <span class="digital_equity_card_con_one">{{ item.name }}</span>
                        <span class="digital_equity_card_con_two">{{ item.value }}</span>
                    </div>
                </div>
            </div>
            <div class="hold_privileges">
                <hash-code :info="info"></hash-code>
            </div>
            <div class="hold_privileges">
                <div class="hold_privileges_title">交易记录</div>
                <div v-if="list.length > 0">
                    <div class="hold_privileges_list" v-for="item in list" :key="item.id">
                        <div class="hold_privileges_list_con">
                            <div class="hold_privileges_list_con_one text1 van-ellipsis">
                                {{ item.fromUser || '保密' }}
                            </div>
                            <div class="hold_privileges_list_con_one text2" v-if="item.price">
                                {{ item.operation }}¥{{ item.price }}
                            </div>
                            <div class="hold_privileges_list_con_one text2" v-else>{{ item.operation }}</div>
                            <div class="hold_privileges_list_con_one text3 van-ellipsis">
                                {{ item.toUser || '保密' }}
                            </div>
                            <div class="hold_privileges_list_con_one text4">{{ item.createdAt.substr(0, 16) }}</div>
                        </div>
                    </div>
                </div>
                <div v-else class="textName">暂无购买记录</div>
            </div>
        </div>
        <!-- 购买之后交易按钮 -->
        <div class="purchase_transaction_button">
            <div class="purchase_transaction_button_con">
                <div class="purchase_transaction_button_left">
                    <div class="purchase_transaction_button_give" v-if="startTime">
                        <div class="purchase_transaction_button_give_one">赠送</div>
                        <div class="purchase_transaction_button_give_two">{{ startTime }}</div>
                    </div>
                    <div class="purchase_transaction_button_give_con" @click="Add" v-else>赠送</div>
                </div>
                <div class="purchase_transaction_button_right">
                    <div class="public_display" @click="Exhibition">
                        {{ info.publicShow ? '取消展示' : '公开展示' }}
                    </div>
                    <div class="purchase_transaction_button_deposit" v-if="startTime">
                        <div class="purchase_transaction_button_deposit_one">寄售倒计时</div>
                        <div class="purchase_transaction_button_deposit_two">{{ startTime }}</div>
                    </div>
                    <div class="purchase_transaction_button_deposit_consignment" v-else @click="Consignment">
                        {{ info.consignment ? '取消寄售' : '寄售上架' }}
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- <div class="detail">
        <product-banner :info="info" pageType="asset"></product-banner>

        <div class="info">
            <div class="info-title">
                <product-title :isSmall="info.name && info.name.length > 16">{{ info.name }}</product-title>
            </div>
            <div class="price-line">
                <template v-if="info.consignment">
                    <div class="price">
                        <img src="@assets/jiage_huang.png" alt="" />
                        <span>{{ info.sellPrice || 0 }}</span>
                    </div>
                    <div class="sub" v-if="info.royalties">
                        含 <span>{{ info.royalties }}%</span> 版税
                    </div>
                </template>

                <div class="status" v-else-if="info.status == 'NORMAL'">
                    {{ info.publicShow ? '仅展示' : '未展示' }}
                </div>
                <div class="status" v-else>
                    {{ getLabelName(info.status, assetStatusOptions) }}
                </div>
                <div class="flex1"></div>

                <span class="text1" v-if="info.number"> 编号 {{ info.number }} </span>
            </div>
            <div class="info-bottom">
            </div>
        </div>

        <div class="goods">
            <van-collapse v-model="activeNames">
                <van-collapse-item name="1" class="goods-info">
                    <template #title>
                        <div class="page-title"><img src="@assets/fenxiang-icon.png" alt="" />用户信息</div>
                    </template>
                    <div class="user">
                        <van-cell
                            class="creator"
                            :to="{
                                path: '/creatorDetail',
                                query: {
                                    id: info.minterId
                                }
                            }"
                        >
                            <template #icon>
                                <van-image
                                    width="40"
                                    height="40"
                                    class="user-img"
                                    :src="info.minterAvatar || require('@assets/svgs/img_default_photo.svg')"
                                    fit="cover"
                                    radius="100"
                                />
                            </template>
                            <template #title>
                                <div class="text1 van-ellipsis">{{ info.minter }}</div>
                                <div class="text2">铸造者</div>
                            </template>
                        </van-cell>
                        <van-cell class="creator">
                            <template #icon>
                                <van-image
                                    width="40"
                                    height="40"
                                    class="user-img"
                                    :src="userInfo.avatar || require('@assets/svgs/img_default_photo.svg')"
                                    fit="cover"
                                    radius="100"
                                />
                            </template>
                            <template #title>
                                <div class="text1 van-ellipsis">{{ userInfo.nickname }}</div>
                                <div class="text2">持有者</div>
                            </template>
                        </van-cell>
                    </div>
                </van-collapse-item>

                <van-collapse-item name="2" class="goods-info">
                    <template #title>
                        <div class="page-title"><img src="@assets/icon-miaoshu.png" alt="" />作品描述</div>
                    </template>
                    <div v-if="info.detail" class="page-text page-detail" v-html="info.detail"></div>
                    <div v-else class="textName">铸造者未设置</div>
                </van-collapse-item>
                <van-collapse-item name="3" class="goods-info">
                    <template #title>
                        <div class="page-title"><img src="@assets/icon-lianshangxinxi.png" alt="" />类型</div>
                    </template>
                    <div class="top1">
                        <div v-if="info.category" class="text2">
                            <span>{{ info.category }}</span>
                        </div>
                        <div v-else class="text5">铸造者未设置</div>
                    </div>
                </van-collapse-item>
                <van-collapse-item name="4" class="goods-info init">
                    <template #title>
                        <div class="page-title">
                            <img src="@assets/qiaoqiaohua-icon-weidakai.png" alt="" /> 悄悄话<span
                                >（灰色表示已使用）</span
                            >
                        </div>
                    </template>
                    <div class="top1">
                        <div class="text2 text3" @click="Whisper" v-if="init2" :class="{ prim: init2.opened }">
                            <img v-if="!init2.opened" class="img" :src="init2.icon[0]" alt="" />
                            <img v-if="init2.opened" class="img" :src="init2.icon[2]" alt="" />
                            <div class="text4" :class="{ prim: init2.opened }">
                                {{ init2.opened ? '已打开' : '未打开' }}
                            </div>
                        </div>
                        <div class="text5" v-else>铸造者未设置</div>
                    </div>
                </van-collapse-item>
                <van-collapse-item name="5" class="goods-info">
                    <template #title>
                        <div class="titleIcon page-title">
                            <img src="@assets/icon-lianshangxinxi(1).png" alt="" />持有特权<span
                                >（灰色表示已使用）</span
                            >
                        </div>
                    </template>
                    <div class="prive" v-if="init.length > 0">
                        <div class="prive1" :class="{ opened: item.opened }" v-for="(item, index) in init" :key="index">
                            <img v-if="!item.opened" class="img" :src="item.icon[0]" alt="" />
                            <div style="margin-top: 4px" v-if="item.icon[2]">
                                <img v-if="item.opened" class="img" :src="item.icon[2]" alt="" />
                            </div>
                    

                            <div v-if="item.once" @click="privilegeFn2(item)" class="prive2">
                                {{ item.name }}
                            </div>
                            <div v-else @click="privilegeFn(item)" class="prive2">
                                {{ item.name }}
                            </div>
                        </div>
                    </div>
                    <div v-if="init.length === 0" class="tips">铸造者未设置</div>
                </van-collapse-item>
                <van-collapse-item name="6" class="goods-info">
                    <template #title>
                        <div class="page-title"><img src="@assets/icon-lianshangxinxi(2).png" alt="" />作品特性</div>
                    </template>
                    <div class="specific-list" v-if="properties.length > 0">
                        <div class="specific-item" v-for="(item, index) in properties" :key="index">
                            <div class="text1">{{ item.name }}</div>
                            <div class="text2">{{ item.value }}</div>
                        </div>
                    </div>
                    <div v-else class="textName">铸造者未设置</div>
                </van-collapse-item>
                <hash-code :info="info" pageType="asset"></hash-code>
                <van-collapse-item name="8" class="goods-info">
                    <template #title>
                        <div class="page-title"><img src="@assets/info_icon_jiaoyijilu1.png" alt="" />交易记录</div>
                    </template>
                    <div v-if="list.length > 0">
                        <div class="user-detail" v-for="item in list" :key="item.id">
                            <div class="text1 van-ellipsis">{{ item.fromUser || '保密' }}</div>
                            <div class="text2" v-if="item.price">{{ item.operation }}¥{{ item.price }}</div>
                            <div class="text2" v-else>{{ item.operation }}</div>
                            <div class="text3 van-ellipsis">{{ item.toUser || '保密' }}</div>
                            <div class="text4">{{ item.createdAt.substr(0, 16) }}</div>
                        </div>
                    </div>
                    <div v-else style="display: flex; justify-content: center">暂无购买记录</div>
                </van-collapse-item>
            </van-collapse>

          
        </div>

        
        <div class="btn van-safe-area-bottom" ref="btn" v-if="info.status === 'NORMAL'">
            <div class="btns1">
                <div class="add" @click="Add">
                    <img class="img" src="@assets/icon-dianzan.png" alt="" />
                    <div class="text2">赠送</div>
                </div>
                <van-button class="btn1" type="primary" block round @click="Exhibition">{{
                    info.publicShow ? '取消展示' : '公开展示'
                }}</van-button>

                <van-button v-if="startTime" block class="no-btn" round color="#303133">
                    <div>寄售倒计时</div>
                    <div>{{ startTime }}</div>
                </van-button>

                <van-button type="primary" v-else block round @click="Consignment">
                 
                    {{ info.consignment ? '取消寄售' : '寄售上架' }}
                </van-button>
            </div>
        </div>
        <div
            class="btn van-safe-area-bottom"
            ref="btn"
            v-else-if="info.status === 'TRADING' || info.status === 'GIFTING'"
        >
            <div class="status-text">{{ getLabelName(info.status, assetStatusOptions) }}</div>
        </div>
        <van-popup v-model:show="show">
            <div class="title2">
                <div class="top">
                    <img class="img" v-if="list2.icon[1]" :src="list2.icon[1]" alt="" />
                    <img class="img" v-else :src="list2.icon[0]" alt="" />
                    <div class="title3">{{ list2.name }}</div>
                </div>
                <img @click="allFn" class="icon" :src="require('@assets/icon-dianzan.png')" alt="" />
            </div>
            <div class="border"></div>
            <div class="name">{{ list2.description }}</div>
            <div class="name1" v-if="list2.type === 'text'">
              
                <span>{{ list2.detail || '暂无' }}</span>
            </div>
            <div class="name1" v-if="list2.type === 'exchange'">
                <span>{{ list2.detail }}</span>
            </div>
            <div class="name1" v-if="list2.type == 'qrcode'">
                <img class="qrcodeImg" :src="list2.detail" alt="" />
                <div class="qrcode1">扫描二维码进行票务核销</div>
                <span>{{ list2.remark || '暂无' }}</span>
            </div>
            <div v-if="list2.type === 'code'">
                <div class="copy">
                    <div class="id">
                        
                        yshsbn
                    </div>
                    <img class="copyImg" @click="copy" src="@assets/svgs/copy_icon.svg" alt="" />
                </div>
                <span class="span">说明：</span> <span>{{ list2.remark || '暂无' }}</span>
                <div class="border"></div>
                <div class="code">每次交易都会产生校验码</div>
            </div>
            <div v-if="list2.openTime">
                <div v-if="list2.type == 'qrcode'" class="timename">
                    <span class="time">截止时间：</span>{{ list2.openTime }}
                </div>
                <div v-else class="timename"><span class="time">打开时间：</span>{{ list2.openTime }}</div>
            </div>
        </van-popup>
        
        <van-popup v-model:show="show3">
            <div class="title2">
                <div class="top">
                    <img class="img" :src="init2.icon[1]" alt="" />
                    <div class="title3">{{ init2.name }}</div>
                </div>
                <img
                    @click="allFn2"
                    class="icon"
                    src="https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-11-13-13-52-01rJiHiwBy.png"
                    alt=""
                />
            </div>
            <div class="border"></div>
            <div class="name">{{ init2.description }}</div>
            <div class="name1">
                <span>{{ init2.detail || '暂无' }}</span>
            </div>
            <div v-if="init2.openTime" class="timename"><span class="time">开启时间：</span>{{ init2.openTime }}</div>
        </van-popup>
      
        <div class="whisper">
            <van-popup v-model:show="show2">
                <div class="con">
                    <div class="Whisper">提示</div>
                    <img
                        @click="show2 = false"
                        class="icon"
                        src="https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-11-12-16-13-37tvHvqsIN.png"
                        alt=""
                    />
                </div>
                <img
                    @click="openedFn"
                    class="imgBox"
                    src="https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-11-12-16-13-07DtWLMcPy.png"
                    alt=""
                />
                <div class="Whisper1">
                    <div>点击图标打开悄悄话</div>
                    <div v-if="init2.once">(隐藏内容，只能开启一次)</div>
                </div>
            </van-popup>
        </div>

        <order-open
            ref="box"
            @getProduct="getProduct(true)"
            :id="orderInfo.id"
            :imgSrc="getImg(changeImgs(info.pic))"
        ></order-open>
    </div> -->
</template>

<script>
import { abs } from 'mathjs';
import asset from '../../mixins/asset';
import product from '../../mixins/product';
import { mapState } from 'vuex';
import { ImagePreview } from 'vant';
import { Dialog } from 'vant';
// import HashCode from '../../components/product/HashCode.vue';
// import ProductTitle from '../../components/product/ProductTitle.vue';
import ProductBanner from '../../components/product/ProductBanner.vue';
import HashCode from '../../components/product/HashCode.vue';
// import OrderOpen from '../../components/order/OrderOpen.vue';
// import TopNavigation from "../../components/TopNavigation.vue"
export default {
    components: {
        HashCode,
        // ProductTitle,
        ProductBanner
        // OrderOpen,
        // TopNavigation
    },
    mixins: [asset, product],
    data() {
        return {
            activeNames: ['1', '2', '3', '4', '5', '6', 'hashCode', '8'],
            noLikes: require('@assets/icon-dianzan.png'),
            likes: require('@assets/icon-dianzan@2x.png'),
            info: {},
            orderInfo: {},
            liked: false,
            show2: false,
            show3: false,
            btn: null,
            list: [],
            show: false,
            init: [],
            init2: null,
            holdDays: 0,
            typeOptions: [
                { label: '文本', value: 'text' },
                { label: '二维码', value: 'qrcode' },
                { label: '验证码', value: 'code' },
                { label: '铸造', value: 'exchange' }
            ]
        };
    },
    computed: {
        ...mapState(['userInfo']),
        banners() {
            return this.info.pic || [];
        },
        properties() {
            return this.info.properties || [];
        },
        privileges() {
            return this.info.privileges || [];
        },
        isBuy() {
            return this.info.stock && this.info.onShelf;
        }
    },
    mounted() {
        this.getProduct(true);
        setTimeout(() => {
            this.record();
        }, 1000);
    },
    methods: {
        allFn() {
            this.show = false;
            this.getProduct();
        },
        allFn2() {
            this.show3 = false;
            this.getProduct();
        },
        copy() {
            this.$copyText(this.list2.id).then(
                e => {
                    this.$toast.success('复制成功');
                    console.log(e);
                },
                e => {
                    this.$toast('复制失败');
                    console.log(e);
                }
            );
        },
        privilegeFn(init) {
            this.list2 = init;
            this.show = true;
            this.$http
                .post('/asset/usePrivilege', {
                    assetId: this.info.id,
                    privilegeId: init.id
                })
                .then(res => {
                    console.log(res);
                });
        },
        privilegeFn2(init) {
            if (init.once && init.opened == false) {
                this.list2 = init;
                this.show = true;
                this.$http
                    .post('/asset/usePrivilege', {
                        assetId: this.info.id,
                        privilegeId: init.id
                    })
                    .then(res => {
                        console.log(res);
                    });
            }
        },
        openedFn() {
            this.show2 = false;
            this.show3 = true;
            if (!this.init2.once) {
                // this.show2 = false;
                this.$http
                    .post('/asset/usePrivilege', {
                        assetId: this.info.id,
                        privilegeId: this.init2.id
                    })
                    .then(res => {
                        console.log(res);
                    });
            }
        },
        Whisper() {
            if (!this.init2.once || (this.init2.once && !this.init2.opened)) {
                this.show2 = true;
                this.$http
                    .post('/asset/usePrivilege', {
                        assetId: this.info.id,
                        privilegeId: this.init2.id
                    })
                    .then(res => {
                        this.init2.opened = true;
                        console.log(res);
                    });
            }
        },
        record() {
            this.$http
                .get('/asset/tokenHistory', {
                    tokenId: this.info.tokenId,
                    assetId: this.info.id
                })
                .then(res => {
                    this.list = res;
                });
        },
        Consignment() {
            this.checkAuth()
                .then(() => {
                    return this.checkBank();
                })
                .then(() => {
                    if (this.dayjs().diff(this.dayjs(this.info.createdAt), 'day') < this.holdDays) {
                        this.$toast('持有满' + this.holdDays + '天才能寄售');
                    } else if (!this.info.consignment) {
                        Dialog.confirm({
                            title: '寄售上架',
                            message: '确定寄售上架吗？'
                        }).then(() => {
                            this.$router.push('/Consignment?id=' + this.info.id);
                        });
                    } else {
                        Dialog.confirm({
                            title: '取消寄售',
                            message: '确定取消寄售吗？'
                        })
                            .then(() => {
                                return this.$http.post(`/asset/cancelConsignment?id=${this.info.id}`);
                            })
                            .then(res => {
                                this.$toast.success('取消寄售');
                                setTimeout(() => {
                                    this.getProduct();
                                }, 1000);
                            });
                    }
                });
        },
        Add() {
            if (this.userInfo.authStatus === 'PENDING' || this.userInfo.authStatus === 'FAIL') {
                Dialog.confirm({
                    title: '认证信息',
                    message: '用户认证中,是否查看认证'
                }).then(() => {
                    this.$router.push('/waiting');
                });
            } else if (this.userInfo.authStatus === 'NOT_AUTH') {
                Dialog.confirm({
                    title: '认证信息',
                    message: '用户未认证,是否立即认证'
                }).then(() => {
                    this.$router.push('/verified');
                });
            } else if (this.dayjs().diff(this.dayjs(this.info.createdAt), 'day') < this.holdDays) {
                this.$toast('持有满' + this.holdDays + '天才能转赠');
            } else if (this.userInfo.authStatus === 'SUCCESS') {
                this.$router.push('/giveSearch?id=' + this.info.id);
            }
        },
        Exhibition() {
            // this.$toast.loading({
            //     message: '加载中...',
            //     forbidClick: true
            // });
            if (!this.info.publicShow) {
                Dialog.confirm({
                    title: '公开展示',
                    message: '藏品将公开展示，无报价'
                }).then(() => {
                    this.$toast.loading({
                        message: '加载中...',
                        forbidClick: true
                    });
                    return this.$http
                        .post(`/asset/publicShow?id=${this.info.id}`)
                        .then(res => {
                            this.$toast.success('展示成功');
                            setTimeout(() => {
                                this.getProduct();
                            }, 1000);
                        })
                        .catch(e => {
                            this.$toast(e.error);
                        });
                });
            } else {
                Dialog.confirm({
                    title: '取消展示',
                    message: '藏品将取消展示，无报价'
                })
                    .then(() => {
                        this.$toast.loading({
                            message: '加载中...',
                            forbidClick: true
                        });
                        return this.$http.post(`/asset/cancelPublic?id=${this.info.id}`);
                    })
                    .then(res => {
                        this.$toast.success('取消成功');
                        setTimeout(() => {
                            this.getProduct();
                        }, 1000);
                    });
            }
        },
        preview(index = 0, list = []) {
            ImagePreview({
                images: [...list],
                startPosition: index
            });
        },
        getProduct(init = false) {
            this.$toast.loading({
                message: '加载中...',
                forbidClick: true
            });
            this.$http.get('/asset/get/' + this.$route.query.id).then(res => {
                this.info = res;

                if (res.orderId) {
                    this.$http.get('/order/get/' + res.orderId).then(res => {
                        this.orderInfo = res;
                        if (this.orderInfo.type === 'BLIND_BOX' && !this.orderInfo.opened) {
                            this.$toast.clear();
                            this.openBlindBox();
                        }
                    });
                }
                wx.updateAppMessageShareData({
                    title: '第九空间-' + res.name,
                    desc: '全球首个基于区块链的游戏资产集换中心',
                    link: location.origin + '/9th/assetDetail?id=' + res.id,
                    imgUrl: this.getImg(this.changeImgs(this.banners), '', 600)
                });
                wx.updateTimelineShareData({
                    title: '第九空间-' + res.name,
                    link: location.origin + '/9th/assetDetail?id=' + res.id,
                    imgUrl: this.getImg(this.changeImgs(this.banners), '', 600)
                });
                this.tokenId = this.info.tokenId;
                if (res.privileges) {
                    this.init2 = res.privileges.find(item => {
                        return item.name === '悄悄话';
                    });
                }
                if (res.privileges) {
                    this.init = res.privileges.filter(item => {
                        return item.name !== '悄悄话';
                    });
                }

                this.$nextTick(() => {
                    if (this.isBuy) {
                        this.btn = this.$refs.btn;
                    }
                });
                console.log(init);
                if (init) {
                    if (this.info.holdDays) {
                        this.holdDays = Number(this.info.holdDays);
                        this.getTime();
                    } else {
                        this.$http.get('/sysConfig/get/hold_days').then(res => {
                            this.holdDays = Number(res.value);
                            // this.holdDays = 10;
                            this.getTime();
                        });
                    }
                } else {
                    this.$toast.clear();
                }
            });
        },
        openBlindBox() {
            this.$refs.box.show = true;
        },
        likeProduct() {
            if (!this.info.liked) {
                this.$http.get(`/collection/${this.info.id}/like`).then(() => {
                    this.getProduct();
                    this.$toast.success('收藏成功');
                });
            } else {
                this.$http.get(`/collection/${this.info.id}/unlike`).then(() => {
                    this.getProduct();
                    this.$toast.success('取消收藏');
                });
            }
        },
        buy() {
            this.checkLogin().then(() => {
                this.$router.push({
                    path: '/submit',
                    query: {
                        id: this.$route.query.id
                    }
                });
            });
        },
        pad(n, width, z) {
            z = z || '0';
            n = n + '';
            return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
        },
        getTime() {
            let startTime = this.dayjs(this.info.createdAt).add(this.holdDays, 'days');
            let seconds = this.dayjs(startTime, 'YYYY-MM-DD HH:mm:ss').diff(this.dayjs(), 'second');
            let str = '';
            let d = Math.floor(seconds / 24 / 3600);
            if (abs(d) > 0) {
                str += d + '天 ';
            }

            this.startTime =
                str +
                this.pad(parseInt(seconds / 3600) % 24, 2) +
                ':' +
                this.pad(parseInt(seconds / 60) % 60, 2) +
                ':' +
                this.pad(seconds % 60, 2);
            if (this.timer) {
                clearTimeout(this.timer);
                this.timer = null;
            }
            if (!this.dayjs().isBefore(this.dayjs(startTime, 'YYYY-MM-DD HH:mm:ss'))) {
                if (this.getProduct) {
                    this.getProduct(false);
                }
                this.startTime = '';
            } else {
                this.$toast.clear();
                this.timer = setTimeout(() => {
                    this.getTime();
                }, 1000);
            }
        }
    },
    beforeRouteLeave(from, to, next) {
        this.emitter.emit('updateList', this.info);
        next();
    }
};
</script>

<style lang="less" scoped>
.detail_content {
    width: 100%;
    background: #0f0f27;
    // margin-top: 44px;
    .detail_content_img {
        margin-top: 30px;
        padding: 0px 57px;
        box-sizing: border-box;
        width: 100%;
        height: 260px;
        border-radius: 30px;
        margin-bottom: 20px;
    }
    .detail_content_one {
        width: 100%;
        padding: 0px 128px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        margin-bottom: 16px;
        .detail_content_point {
            display: flex;
            .detail_content_point_img {
                width: 18px;
                height: 18px;
                margin-right: 2px;
            }
            .detail_content_point_number {
                font-size: 12px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #939599;
            }
        }
        .detail_content_share {
            display: flex;
            // margin-left: 41px;
            .detail_content_share_img {
                width: 18px;
                height: 18px;
                margin-right: 2px;
            }
            .detail_content_share_con {
                font-size: 12px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #939599;
            }
        }
    }
    .detail_content_title_one {
        padding: 0 20px;
        box-sizing: border-box;
        font-size: 18px;
        // margin-top: -25px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        line-height: 24px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        margin-bottom: 12px;
        text-align: center;
    }
    .detail_content_title {
        padding: 0 20px;
        box-sizing: border-box;
        font-size: 18px;
        margin-top: 25px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        line-height: 24px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        margin-bottom: 12px;
        text-align: center;
    }
    .item_number {
        // padding: 0 117px;
        // box-sizing: border-box;
        display: flex;
        justify-content: center;
        font-size: 10px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #28b6ff;
        margin-bottom: 20px;
        .item_number_collection {
            width: 54px;
            height: 18px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
            line-height: 18px;
            text-align: center;
            margin-right: 10px;
        }
        .item_number_number {
            width: 77px;
            height: 18px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
            line-height: 18px;
            text-align: center;
        }
    }
    .limited_label {
        margin-left: 108px;
        margin-bottom: 20px;
        display: flex;
        .limited_label_name {
            width: 44px;
            height: 18px;
            background: #28b6ff;
            border-radius: 4px 0px 0px 4px;
            font-size: 10px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #ffffff;
            text-align: center;
            line-height: 18px;
        }
        .limited_label_number {
            width: 51px;
            height: 18px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
            font-size: 10px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #28b6ff;
            line-height: 18px;
            text-align: center;
            margin-right: 10px;
        }
        .limited_label_collection {
            width: 54px;
            height: 18px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
            font-size: 10px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #28b6ff;
            line-height: 18px;
            text-align: center;
        }
    }
    .self_information {
        padding: 0 10px;
        padding-bottom: 53px;
        box-sizing: border-box;
        .display_price {
            width: 100%;
            height: 56px;
            background: #29293f;
            border-radius: 8px;
            padding-left: 10px;
            box-sizing: border-box;
            display: flex;
            margin-bottom: 10px;
            .display_price_con{
                display: flex;
            }
            .display_price_title {
                font-size: 20px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #939599;
                line-height: 56px;
            }
            .display_price_left {
                font-size: 12px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #939599;
                padding-top: 28px;
                box-sizing: border-box;
                margin-right: 4px;
            }
            .display_price_right {
                display: flex;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #ffffff;
                .display_price_right_symbol {
                    font-size: 14px;
                    padding-top: 27px;
                    box-sizing: border-box;
                }
                .display_price_right_number {
                    font-size: 26px;
                    padding-top: 15px;
                    box-sizing: border-box;
                }
            }
        }
        .self_information_one {
            padding: 12px 10px;
            box-sizing: border-box;
            background: #29293f;
            border-radius: 8px;
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
            position: relative;
            .self_information_one_con {
                // width: 50%;
                display: flex;
                .self_information_one_text {
                    font-size: 12px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    margin-left: 6px;
                }
                .self_information_one_text_one {
                    color: #ffffff;
                }
                .self_information_one_text_two {
                    color: #939599;
                }
            }
            .split_line {
                position: absolute;
                left: 48%;
                top: 12px;
                width: 1px;
                height: 34px;
                background: rgba(95, 100, 111, 0.2);
                // opacity: 0.2;
                // border: 1px solid #5F646F;
                // box-sizing: border-box;
            }
        }
        .description_of_works {
            width: 100%;
            background: #29293f;
            border-radius: 8px;
            padding: 10px;
            box-sizing: border-box;
            .description_of_works_title {
                font-size: 14px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #ffffff;
                margin-bottom: 10px;
            }
            .description_of_works_text {
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #939599;
                line-height: 20px;
                margin-bottom: 10px;
            }
            .description_of_works_img {
                width: 100%;
                height: 489px;
                border-radius: 8px;
            }
        }
        .hold_privileges {
            background: #29293f;
            border-radius: 8px;
            padding: 10px;
            box-sizing: border-box;
            margin: 10px 0;
            .textName {
                color: #939599;
                margin-top: 10px;
                // text-align: center;
            }
            .hold_privileges_list {
                .hold_privileges_list_con {
                    display: flex;
                    padding: 10px 0px;
                    border-bottom: 1px solid #5f646f;
                    box-sizing: border-box;
                    .hold_privileges_list_con_one {
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                        flex: 1;
                        font-size: 12px;
                        font-family: PingFangSC-Regular, PingFang SC;
                        font-weight: 400;
                        color: #939599;
                        margin-left: 20px;
                        line-height: 37px;
                        margin-right: 10px;
                        // text-align: center;
                    }
                    .hold_privileges_list_con_one {
                        margin-left: 0;
                    }
                    .text3 {
                        flex: 2;
                    }
                    .text4 {
                        flex: 2;
                    }
                }
                .hold_privileges_list_con:last-child {
                    padding-bottom: 0;
                    border-bottom: none;
                }
            }
            .hold_privileges_title {
                font-size: 14px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #ffffff;
            }
            .hold_privileges_tip {
                font-size: 12px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #939599;
                margin-left: 6px;
            }
            .hold_privileges_name {
                margin-top: 10px;
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #939599;
            }
        }
        .hold_privileges:last-child {
            margin-bottom: 30px;
        }
        // .information_on_the_chain {
        //     display: flex;
        //     justify-content: space-between;
        //     .information_on_the_chain_title {
        //         font-size: 14px;
        //         font-family: PingFangSC-Regular, PingFang SC;
        //         font-weight: 400;
        //         color: #939599;
        //         line-height: 24px;
        //     }
        //     .information_on_the_chain_content {
        //         width: 158px;
        //         font-size: 14px;
        //         font-family: PingFangSC-Regular, PingFang SC;
        //         font-weight: 400;
        //         color: #939599;
        //         line-height: 24px;
        //         overflow: hidden; //超出的文本隐藏
        //         text-overflow: ellipsis; //溢出用省略号显示
        //         white-space: nowrap; //溢出则不换行
        //     }
        // }
        // .information_on_the_chain_con {
        //     font-size: 14px;
        //     font-family: PingFangSC-Medium, PingFang SC;
        //     font-weight: 500;
        //     color: #ffffff;
        //     margin-bottom: 8px;
        // }
        .transaction_record_one {
            display: flex;
            justify-content: space-between;
            margin: 10px 0;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #939599;
            .user_information {
                margin-right: 20px;
            }
        }
        .transaction_record_two {
            margin-bottom: 0;
            .selling_price {
                margin-right: 32px;
            }
        }
    }
    .hold_privileged_information {
        display: flex;
        flex-wrap: wrap;
        margin-top: 10px;
        .hold_privileged_information_con {
            width: 94px;
            height: 24px;
            background: #28b6ff;
            border-radius: 4px;
            margin-right: 26px;
            margin-bottom: 10px;
            display: flex;
            .hold_privileged_information_con_img {
                width: 18px;
                height: 18px;
                margin-right: 3px;
                padding-top: 6px;
                margin-left: 12px;
                box-sizing: border-box;
            }
            .hold_privileged_information_con_title {
                width: 100%;
                padding-top: 3px;
                box-sizing: border-box;
                font-size: 12px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #ffffff;
                text-align: center;
            }
        }
        .hold_privileged_information_con:nth-of-type(3n) {
            margin-right: 0;
        }
    }
    .digital_equity_card {
        margin-top: 10px;
        .digital_equity_card_con {
            width: 100%;
            height: 24px;
            border-radius: 4px;
            border: 1px solid #28b6ff;
            padding-left: 10px;
            box-sizing: border-box;
            line-height: 23px;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            margin-bottom: 10px;
            .digital_equity_card_con_one {
                color: #f5f7fa;
                margin-right: 12px;
            }
            .digital_equity_card_con_two {
                color: #28b6ff;
            }
        }
        .digital_equity_card_con:last-child {
            margin-bottom: 0;
        }
    }
    .transaction_button {
        width: 100%;
        background: #15152d;
        padding: 0 16px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        position: fixed;
        bottom: 0;
        .transaction_button_left {
            display: flex;
            .transaction_price {
                padding: 18px 0 12px 12px;
                box-sizing: border-box;
                font-size: 26px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #ffffff;
                position: relative;
                margin-right: 4px;
                .amount_symbol {
                    font-size: 14px;
                    position: absolute;
                    bottom: 16px;
                    left: 0px;
                }
            }
            .transaction_tax {
                padding: 28px 0 12px 0;
                box-sizing: border-box;
                font-size: 12px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #949699;
                .transaction_tax_con {
                    color: #ffffff;
                }
            }
        }
        .transaction_button_right {
            padding: 8px 0;
            box-sizing: border-box;
            .sold_out {
                width: 160px;
                height: 40px;
                background: #29293f;
                border-radius: 8px;
                font-size: 16px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #939599;
                line-height: 40px;
                text-align: center;
            }
            .coming_on_sale {
                width: 160px;
                height: 46px;
                background: #29293f;
                border-radius: 8px;
                padding: 6px 0 0 52px;
                box-sizing: border-box;
                .coming_on_sale_con {
                    font-size: 14px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #939599;
                }
                .coming_on_sale_time {
                    font-size: 10px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #939599;
                }
            }
            .buy_now {
                width: 160px;
                height: 46px;
                background: #28b6ff;
                border-radius: 8px;
                padding-top: 6px;
                box-sizing: border-box;
                text-align: center;
                .buy_now_con {
                    font-size: 14px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #ffffff;
                }
                .purchase_sold {
                    font-size: 10px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #f5f7fa;
                    margin-right: 12px;
                }
                .Purchase_surplus {
                    font-size: 10px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #f5f7fa;
                }
            }
        }
    }
    .purchase_transaction_button {
        width: 100%;
        height: 56px;
        background: #15152d;
        position: fixed;
        bottom: 0;
        // justify-content: space-between;
        font-size: 16px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        .purchase_transaction_button_con{
            display: flex;
            padding: 8px 16px;
            box-sizing: border-box;
            // justify-content: center;
        }
        .purchase_transaction_button_give {
            width: 80px;
            height: 40px;
            border-radius: 8px;
            background: #29293f;
            margin-right: 16px;
            // border: 1px solid #28b6ff;
            // box-sizing: border-box;
            // color: #28b6ff;
            color: #939599;
            // line-height: 38px;
            text-align: center;
            .purchase_transaction_button_give_one {
                font-size: 14px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                line-height: 24px;
            }
            .purchase_transaction_button_give_two {
                font-size: 10px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                line-height: 10px;
            }
        }
        .purchase_transaction_button_give_con {
            width: 76px;
            height: 40px;
            border-radius: 8px;
            border: 1px solid #28b6ff;
            box-sizing: border-box;
            color: #28b6ff;
            line-height: 38px;
            text-align: center;
            font-size: 16px;
            font-weight: 500;
            margin-right: 16px;
        }
        .purchase_transaction_button_right {
            display: flex;
            width: calc(100vw - 124px);
        }
        .public_display {
            width: 50%;
            height: 40px;
            border-radius: 8px 0px 0px 8px;
            border: 1px solid #28b6ff;
            box-sizing: border-box;
            color: #28b6ff;
            line-height: 38px;
            text-align: center;
            // border-width: 0px;
        }
        .purchase_transaction_button_deposit {
            width: 50%;
            height: 40px;
            background: #29293f;
            border-radius: 0px 8px 8px 0px;
            color: #939599;
            // line-height: 40px;
            text-align: center;
            .purchase_transaction_button_deposit_one {
                font-size: 14px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                line-height: 24px;
            }
            .purchase_transaction_button_deposit_two {
                font-size: 10px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                line-height: 10px;
            }
        }
        .purchase_transaction_button_deposit_consignment {
            width: 50%;
            height: 40px;
            background: #28b6ff;
            border-radius: 0px 8px 8px 0px;
            color: #ffffff;
            text-align: center;
            font-size: 16px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            line-height: 40px;
        }
    }
    .show_only {
        width: 100%;
        height: 56px;
        background: #15152d;
        padding: 8px 16px;
        box-sizing: border-box;
        position: fixed;
        bottom: 0;
        .show_only_con {
            width: 100%;
            height: 40px;
            background: #29293f;
            border-radius: 8px;
            font-size: 16px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #939599;
            line-height: 40px;
            text-align: center;
        }
    }
}
</style>
