const app = getApp()


import {
    selfFormatTimeYMD,
    selfFormatTimeHM,
    twoTimeIntervalReturnHours,
    twoTimeInterval
} from "../../../../../utils/util.js"

import {
    selectShowroomRecordByIdRq
} from "../../../../../api/meeting/exhibition.js"

Page({

    /**
     * 页面的初始数据
     */
    data: {
        IMG_NAME: app.IMG_NAME,
        id: null,
        detail: null,
        personList: [],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        let _this = this;
        _this.setData({
            ...options
        })
        // 获取详情
        _this.getDetail();
    },

    // 获取详情
    getDetail() {
        let _this = this;
        let id = _this.data.id;
        selectShowroomRecordByIdRq(id).then(res => {
            let detail = res.data;
            // 时间段
            detail.timeSlot = selfFormatTimeYMD(detail.startTime) + ' ' + selfFormatTimeHM(detail.startTime) + '~' + selfFormatTimeHM(detail.endDate);
            // 合计时间
            detail.countTime = twoTimeIntervalReturnHours(detail.startTime, detail.endDate)
            // 颜色
            let color = "#3794FF"
            if (detail.status == 0) { // 待审核
                color = "#3794FF"
            } else if (detail.status == 1) { // 审核通过
                color = "#62c855"
            } else if (detail.status == 2) { // 审核驳回
                color = "red"
            }
            detail.statusColor = color;
            // persons
            let persons = detail.persons;
            let personList = []
            if (persons) {
                personList = JSON.parse(persons);
            }
            //
            _this.setData({
                detail,
                personList,
            })
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage(e) {
        console.log('onShareAppMessage', e);
    }

})