<template>
	<div>
        <div></div>
        <img src="http://baidu.com/">
        <div>
            <input type="checkbox">
        </div>
        <iframe></iframe>
	</div>
</template>

<script>
import * as myModule from '/modules/my-module.js';
import {myExport} from '/modules/my-module.js';
import {foo, bar} from '/modules/my-module.js';
import {reallyReallyLongModuleExportName as shortName} from '/modules/my-module.js';
import {
  reallyReallyLongModuleMemberName as shortName, 
  anotherLongModuleName as short
} from "my-module";
import '/modules/my-module.js';
import myDefault, * as myModule from "my-module";

import computed from '../../js/computed.js';
import {
    regCn,
    regEn
} from '../../js/utils.js';
import { addClickLog } from '../../js/service.js';
let a = b + 1;
export default {
    components: {},
    data() {
        return { computed };
    },
    props: {
        projectList: {
            type: Array,
            default() {
                return [];
            }
        },
        cityId: {
            type: Number,
            default: -1
        },
        type: {
            type: Number,
            default: 1
        },
        isRC: {
            type: Boolean,
            default: false
        },
        seid: {
            type: Number,
            default: 0
        },
        from: {
            type: String,
            default: 'ticket_list'
        }
    },
    methods: {
        regCn,
        toProjectDetail(options) {
            const id = options.id, index = options.index, listName = this.$data.isRC ? 'commend_list' : 'list';
            let loggerName = '';
            let extraParams = {
                itemid: id,
                module_index: index,
                time: this.$data.seid,
                pagetype: /^search/.test(this.$data.from) ? 2 : 8
            };
            switch (this.$data.from) {
            case 'ticket_list':
                loggerName = 'click-ticket_home-list';
                break;
            case 'recommend_list':
                loggerName = 'click-ticket_home-recommend_list';
                break;
            case 'search':
                loggerName = 'click-ticketSearchResult-product_list';
                break;
            case 'search_recommend':
                loggerName = 'click-ticketSearchResult-remommend_list';
                break;
            default:
                loggerName = 'click-ticket_home-list';
            }
            addClickLog({
                logger: loggerName,
                extra: extraParams
            });
            bl.navigateTo({ url: `/pages/detail/detail?id=${ id }` });
        }
    },
    computed: {},
    created() {

    },
    onLoad() {
        regEn();
    },
    watch: {
        projectList(newValue, oldValue) {
            if (newValue && newValue.length > 0) {
                this.$data.projectList.forEach((item, index) => {
                    if (item.sale_flag_number === 1) {
                        const time = item.sale_start_time, startTime = time * 1000, now = new Date(), today = new Date().setHours(0, 0, 0, 0), timeZoneFix = new Date(time * 1000 + 8 * 3600 * 1000), nowFix = new Date(today + 8 * 3600 * 1000);
                        if (startTime < +now) {
                            this.setData({ [`projectList[${ index }].beginText`]: '' });
                            return;
                        }
                        if (timeZoneFix.toJSON().split('T')[0] === nowFix.toJSON().split('T')[0]) {
                            this.setData({
                                [`projectList[${ index }].willSaleTextLength`]: 73,
                                [`projectList[${ index }].beginText`]: '今天' + timeZoneFix.toJSON().split('T')[1].slice(0, 5) + '开售'
                            });
                        } else {
                            let text = '距开售' + Math.floor((startTime - today) / 1000 / 3600 / 24) + '天', totalLength = 0, cn = text.match(regCn), en = text.match(regEn);
                            if (cn) {
                                totalLength += cn.length;
                            }
                            if (en) {
                                totalLength += en.length / 2;
                            }
                            this.setData({
                                [`projectList[${ index }].willSaleTextLength`]: totalLength * 10 + 8,
                                [`projectList[${ index }].beginText`]: text
                            });
                        }
                    }
                });
            }
        }
    }
};
</script>
