<template>
    <ifrm ref="ifrm">
        <!-- 未读消息列表 -->
        <uni-list>
            <template v-for="(item, index) in messList">
                <uni-list-item :title="item.content" :ellipsis="1" clickable @click="itemClick(item)" :key="index" />
            </template>
        </uni-list>
        <u-modal :show="show" @confirm="confirm" :title="title" :content="content"></u-modal>
    </ifrm>
</template>
<script>
import ifrm from '@/pages/index/ifrm';
export default {
    components: {
        ifrm
    },
    data() {
        return {
            messList: [],
            title: '',
            content: '',
            show: false,
            msgId: null
        };
    },
    methods: {},
    onNavigationBarButtonTap(btn) {
        this.$refs.ifrm.topMenuClick(btn);
    },
    onShow() {
        this.getData();
    },
    methods: {
        getData() {
            this.$ajax.request({
                url: 'pfMessage/query',
                method: 'POST',
                data: {
                    paging: { pageNumber: 1, pageSize: 999999 }
                },
                success: data => {
                    this.messList = data.list;
                }
            });
        },
        itemClick(item) {
            this.title = item.content;
            this.content = item.msgContent || '';
            this.msgId = item.msgId;
            this.show = true;
        },
        confirm() {
            this.show = false;
            this.$ajax.request({
                url: 'pfMessage/signRead',
                data: { msgIds: [this.msgId] },
                method: 'POST',
                success: data => {
                    this.getData();
                }
            });
        }
    }
};
</script>

<style scoped></style>
