<template>
    <div class="page">
        <headNav title="短信通知"></headNav>

        <div class="illegal-container" v-if="info">
            <van-cell title="通知时间" :value="info.sendTime"></van-cell>
            <p class="msg">{{info.message_content}}</p>
        </div>

        <v-mask :showOverLay="showOverLay"></v-mask>
    </div>
</template>

<script>
import headNav from '@/components/headNav.vue';
import mask_overLay from "@/components/overLay_xy.vue";

import { get } from '@/utils/http.js';
import { notEmpty, dateFormat } from '@/utils/tool';

export default {
    components: {
        headNav,
        "v-mask": mask_overLay,
    },
    data () {
        return {
            showOverLay: false,
            info: null,
        }
    },
    computed: {
        id() {
            return this.$route.params.id + '';
        },
        type() {
            return this.$route.params.type + '';
        },
    },
    mounted () {
        if (notEmpty(this.id)) {
            this.loadMessage();
        }
    },
    methods: {
        loadMessage() {
            this.showOverLay = true;
            const msgType = this.type == 1 ? 'ILLEGAL_NOTICE' : 'PUNISHMENT_NOTICE';
            get(`/v2/api/enforce_message?page=1&size=1&query=enforce_job_id==${this.id};message_type==${msgType}`).then(res => {
                if (res && res.data && res.data.length > 0) {
                    const data = res.data[0];
                    data.sendTime = dateFormat('YYYY-mm-dd HH:MM:SS', new Date(data.send_time));
                    this.info = data;
                }
                this.showOverLay = false;
            }).catch(e => {
                this.showOverLay = false;
            });
        },
    }
}
</script>

<style lang="scss" scoped>
.illegal-container {
    margin-top: 47px;
    height: calc(100vh - 47px);
    overflow-y: auto;
    .msg {
        padding: 15px 20px;
        font-size: 14px;
        color: #666666;
        line-height: 200%;
    }
}
</style>