import dayjs from 'dayjs';
require('dayjs/locale/zh-cn');
dayjs.locale('zh-cn');
var relativeTime = require('dayjs/plugin/relativeTime');
dayjs.extend(relativeTime);
var calendar = require('dayjs/plugin/calendar');
dayjs.extend(calendar);
var duration = require('dayjs/plugin/duration');
dayjs.extend(duration);
export default {
    data() {
        return {
            typeOptions: [
                {
                    label: '精选推荐',
                    value: ''
                },
                {
                    label: '原创系列',
                    value: 'DEFAULT'
                },
                {
                    label: '数字盲盒',
                    value: 'BLIND_BOX'
                },
                {
                    label: '拍卖系列',
                    value: 'AUCTION'
                }
            ],
            picsTypes: [
                {
                    label: '视频',
                    value: 'video/mp4'
                }
            ],
            startTime: ''
        };
    },
    computed: {
        bannerList() {
            return [...this.changeImgs(this.banners)].map(item => {
                return this.getImg(item, '', 800);
            });
        },
        isAppointment() {
            if (this.info.startTime) {
                return dayjs().isBefore(dayjs(this.info.startTime));
            } else {
                return false;
            }
        }
    },
    methods: {
        changeImgs(list = []) {
            console.log(list);
            return list.map(item => {
                if (item.type === 'video/mp4') {
                    return item.thumb;
                } else {
                    return item.url;
                }
            });
        },
        isVideo(info = {}) {
            return info.type === 'video/mp4';
        },
        getTime(startTime) {
            if (!startTime) {
                return;
            }
            if (!this.isAppointment) {
                return;
            }
            console.log(222);
            var x = dayjs(startTime);
            var y = dayjs();
            let d = dayjs.duration(x.diff(y));
            let day = parseInt(d.asDays());
            let str = '';
            if (day > 0) {
                str += day + '天 ';
            }
            this.startTime = str + dayjs.duration(x.diff(y)).format('HH:mm:ss');
            console.log(this.startTime);
            setTimeout(() => {
                this.getTime(startTime);
            }, 1000);
        }
    }
};
