notification.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!-- 消息通知 -->
  2. <template>
  3. <view class="notice">
  4. <z-paging
  5. ref="paging"
  6. v-model="noticeList"
  7. @query="queryList"
  8. >
  9. <!-- 选项卡 -->
  10. <view class="notice-tab" slot="top">
  11. <u-tabs :list="tabList" :is-scroll="false" :current="current" @change="tabChange" bg-color="#f2f2f2" inactive-color="#000000" active-color="#709078" :bold="false" bar-width="40" bar-height="6" :active-item-style="{color: '#000000'}" is-scroll=""></u-tabs>
  12. </view>
  13. <view class="notice-list">
  14. <view class="notice-list-item" v-for="(item, index) in noticeList" :key="index" @click="jumpPage('/pages/notification/noticeDetails/noticeDetails', { id: item.id })">
  15. <view class="notice-list-item-title">{{ item.name }}</view>
  16. <view class="notice-list-item-content">{{ item.content }}</view>
  17. <view class="notice-list-item-bottom">
  18. <view>发布于{{ item.releasTime }}</view>
  19. <view class="is-read" v-if="item.isRead == 1">已读</view>
  20. <view class="no-read" v-else>未读</view>
  21. </view>
  22. </view>
  23. </view>
  24. </z-paging>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. current: 0,
  32. tabList: [
  33. { value: 2, name: '培训通知', count: 0 },
  34. { value: 3, name: '就业消息', count: 0 },
  35. { value: 0, name: '系统通知', count: 0 }
  36. ],
  37. tabValue: 2,
  38. pageNum: 1,
  39. pageSize: 5,
  40. noticeList: []
  41. }
  42. },
  43. onShow() {
  44. this.getClassifyUnreadNum();
  45. this.getNoticeListByType(this.pageNum, this.pageSize)
  46. },
  47. methods: {
  48. /**
  49. * 查询每类通知未读的条数
  50. */
  51. getClassifyUnreadNum() {
  52. this.$u.api.noticeApi.getClassifyUnreadNumApi().then(res => {
  53. if (res.code === 200) {
  54. this.tabList[0].count = res.data.trainUnreadCount
  55. this.tabList[1].count = res.data.empUnreadCount
  56. this.tabList[2].count = res.data.sysUnreadCount
  57. }
  58. })
  59. },
  60. /**
  61. * 获取
  62. * @param {Object} pageNum
  63. * @param {Object} pageSize
  64. */
  65. getNoticeListByType(pageNum, pageSize) {
  66. const params = {
  67. type: this.tabValue,
  68. pageNum,
  69. pageSize
  70. }
  71. this.$u.api.noticeApi.getNoticeListByTypeApi(params).then(res => {
  72. if (res.code === 200) {
  73. this.$refs.paging.complete(res.rows);
  74. }
  75. })
  76. },
  77. /**
  78. * tab切换
  79. * @param { Number } cur
  80. */
  81. tabChange(cur) {
  82. this.current = cur
  83. this.tabValue = this.tabList[cur].value;
  84. this.getNoticeListByType(1, 5);
  85. },
  86. /**
  87. * 下拉分页组件触发
  88. * @param {Number} pageNum
  89. * @param {Number} pageSize
  90. */
  91. queryList(pageNum, pageSize) {
  92. this.pageNum = pageNum
  93. this.pageSize = pageSize
  94. this.getNoticeListByType(pageNum, pageSize);
  95. },
  96. /**
  97. * 跳转到指定页面
  98. * @param {Object} url
  99. * @param {Object} params
  100. */
  101. jumpPage(url, params) {
  102. this.$u.route({ url, params })
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. @import './scss/notification.scss';
  109. </style>