messageIndex.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <!-- #ifdef MP-WEIXIN -->
  6. <wk-nav-bar
  7. :command-list="commandList"
  8. title="消息"
  9. @command="handleCommand" />
  10. <!-- #endif -->
  11. <!-- #ifndef MP-WEIXIN -->
  12. <wk-nav-bar title="消息">
  13. <!-- <text
  14. class="read-all"
  15. @click="handleReadAll">
  16. 全部已读
  17. </text> -->
  18. </wk-nav-bar>
  19. <!-- #endif -->
  20. <view class="list-view">
  21. <message-list v-if="showList" />
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { ReadAllMessage } from '@/api/admin.js'
  28. import MessageList from './messageList.vue'
  29. export default {
  30. name: 'MessageIndex',
  31. components: {
  32. MessageList
  33. },
  34. data() {
  35. return {
  36. showList: false,
  37. commandList: [
  38. {
  39. label: '全部已读',
  40. imgIcon: 'dealStatus',
  41. value: 'readAll'
  42. }
  43. ]
  44. }
  45. },
  46. onShow() {
  47. this.showList = false
  48. this.$nextTick(() => {
  49. this.showList = true
  50. })
  51. },
  52. methods: {
  53. handleCommand(command) {
  54. console.log('command: ', command)
  55. if (command.value === 'readAll') {
  56. this.handleReadAll()
  57. }
  58. },
  59. handleReadAll() {
  60. ReadAllMessage().then(res => {
  61. this.$toast('操作成功')
  62. this.showList = false
  63. this.$nextTick(() => {
  64. this.showList = true
  65. })
  66. }).catch(() => {})
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .list-view {
  73. flex: 1;
  74. overflow-y: hidden;
  75. }
  76. .read-all {
  77. font-size: $wk-font-base;
  78. margin-right: 20rpx;
  79. }
  80. </style>