<template>
    <Cn-page :loading="loading">
        <view class="content" slot="body">
            <uni-list :border="false">
                <uni-list-item
                    isDot
                    show-badge
                    badgeType="error"
                    :badge-text="item.status == 1 ? '' : '未读'"
                    :title="item.showName"
                    :note="item.startTime"
                    @click="jump(item)"
                    clickable
                    v-for="(item, index) in store.data"
                />
            </uni-list>
            <Cn-empty v-if="store.empty" style="padding-top: 400rpx"></Cn-empty>
            <uni-load-more v-if="store.data && store.data.length > 0" :status="store.status"></uni-load-more>
        </view>
    </Cn-page>
</template>
<script>
import list from '@/common/js/list'
import { updateStatus } from '@/common/api/message'

export default {
    mixins: [list],
    data() {
        return {
            loading: true,
        }
    },
    onShow() {
        this.init()
    },
    onNavigationBarButtonTap(e) {
        uni.showModal({
            title: '提示',
            content: '确定要全部标记为已读吗？',
            success: (res) => {
                if (res.confirm) {
                    updateStatus({
                        type: 2,
                        eventIds:[]
                    }).then(() => {
                        this.store.reload()
                    })
                }
            },
        })
    },
    methods: {
        async init() {
            let dictData = await this.$util.getDictData('app_event')
            console.log(dictData)
            this.store = this.DataSource('/cs-harmonic-boot/eventUser/queryEventpage')
            this.store.params.type = 2
            this.store.firstCallBack = (res) => {
                this.loading = false
            }
            this.store.reload()
        },
        jump(item) {
            let str = JSON.stringify(item).replace(/%/g, '百分比')
            uni.navigateTo({ url: '/pages/message/runDetail?detail=' + encodeURIComponent(str) })
        },
    },
}
</script>
<style lang="scss">
.content {
    padding-top: 20rpx;
}
/deep/ .uni-list-item {
    background-color: $uni-theme-white !important;
}
/deep/ .uni-badge {
    background-color: unset !important;
    color: #dd524d !important;
    font-size: 28rpx !important;
}
</style>
