notification.vue 3.1 KB

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