123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <template>
- <view class="uni-app">
- <view class="status-bar" />
- <view class="main-container">
- <wk-nav-bar
- :command-list="commandList"
- :title="typeObj.label"
- @command="handleCommand" />
- <wk-scroll-view
- :status="listStatus"
- class="list-scroll"
- @refresh="getList(true)"
- @loadmore="getList()">
- <template v-if="type === 4">
- <notice-item
- v-for="(item, index) in listData"
- :key="item.messageId"
- :item-data="item"
- @delete="deleteOne(index)" />
- </template>
- <template v-else>
- <message-item
- v-for="(item, index) in listData"
- :key="item.messageId"
- :item-data="item"
- @read="handlerRead(index)"
- @delete="deleteOne(index)" />
- </template>
- </wk-scroll-view>
- </view>
- <uni-popup ref="popup" type="dialog">
- <uni-popup-dialog
- :content="dialogMsg"
- :duration="2000"
- type="warning"
- @confirm="deleteAllRead" />
- </uni-popup>
- </view>
- </template>
- <script>
- import {
- QueryMessageList,
- ReadAllMessage,
- MessageClear,
- MessageDeleteById
- } from 'API/admin'
- import MessageItem from './message/messageItem.vue'
- import NoticeItem from './message/noticeItem.vue'
- import mainListMixins from '@/mixins/mainList.js'
- import config from './message.js'
- export default {
- name: 'MessageDetail',
- components: {
- MessageItem,
- NoticeItem
- },
- mixins: [mainListMixins],
- data() {
- return {
- type: null,
- listData: [],
- commandList: [
- {
- label: '全部已读',
- imgIcon: 'dealStatus',
- value: 'readAll'
- },
- {
- label: '删除已读',
- imgIcon: 'delete',
- value: 'delete'
- }
- ],
- dialogMsg: ''
- }
- },
- computed: {
- typeObj() {
- if (!this.type) return {}
- return config.typeList.find(o => o.value === this.type) || {}
- }
- },
- onLoad(options) {
- this.type = Number(options.type)
- this.getList()
- },
- methods: {
- getList(refresh = false) {
- this.listStatus = 'loading'
- if (refresh) {
- this.listParams.page = 0
- }
- this.listParams.page++
- QueryMessageList({
- ...this.listParams,
- label: this.type
- }).then(res => {
- if (this.listParams.page === 1) {
- this.listData = []
- }
- this.listData = this.listData.concat(res.list)
- if (res.hasOwnProperty('lastPage')) {
- this.listStatus = res.lastPage ? 'noMore' : 'more'
- } else {
- this.listStatus = res.list.length === 0 ? 'noMore' : 'more'
- }
- }).catch(() => {
- this.listStatus = 'more'
- })
- },
- handlerRead(index) {
- this.listData[index].isRead = 1
- this.$set(this.listData, index, this.listData[index])
- },
- handleCommand(command) {
- if (command.value === 'readAll') {
- // 全部标记已读
- ReadAllMessage({
- label: this.type
- }).then(res => {
- this.$toast('操作成功')
- this.getList(true)
- }).catch(() => {})
- } else if (command.value === 'delete') {
- this.dialogMsg = '确定删除全部已读消息?'
- this.$refs.popup.open()
- }
- },
- deleteAllRead(next) {
- // 删除已读
- next()
- MessageClear({
- label: this.type
- }).then(res => {
- this.$toast('操作成功')
- this.getList(true)
- }).catch(() => {})
- },
- deleteOne(index) {
- MessageDeleteById({
- messageId: this.listData[index].messageId
- }).then(res => {
- this.$toast('操作成功')
- this.listData.splice(index, 1)
- }).catch(() => {})
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .main-container {
- .list-scroll {
- flex: 1;
- padding-top: 20rpx;
- overflow: hidden;
- }
- }
- </style>
|