list.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="mobile-item-container">
  3. <Navbar title="通知公告" bgColor="#fff" :h5Show="false"></Navbar>
  4. <u-tabs :activeStyle="activeStyle" :list="tabs" @change="tabChange"></u-tabs>
  5. <!-- 未读 -->
  6. <view v-if="activeKey == 'unread'">
  7. <view style="padding: 16px 0 10px;">
  8. <view class="notice-item-tips">
  9. <text>通知</text>
  10. <u-tag text="1" size="mini" type="primary" style="margin: 0 8px;"></u-tag>
  11. <text>条,公告</text>
  12. <u-tag text="1" size="mini" type="success" style="margin: 0 8px;"></u-tag>
  13. <text>条,共 2 条。</text>
  14. </view>
  15. </view>
  16. <Record :list="list" @click="toDetail"></Record>
  17. </view>
  18. <!-- 已读 -->
  19. <view v-if="activeKey == 'read'">
  20. <view style="padding: 16px 0 10px;">
  21. <u-search :show-action="true" actionText="搜索" :animation="true" shape="square" height="40px"></u-search>
  22. </view>
  23. <Record :list="[]" @click="toDetail"></Record>
  24. </view>
  25. <!-- 全部 -->
  26. <view v-if="activeKey == 'all'">
  27. <view style="padding: 16px 0 10px;">
  28. <u-search :show-action="true" actionText="搜索" :animation="true" shape="square" height="40px"></u-search>
  29. </view>
  30. <Record :list="list" @click="toDetail"></Record>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import * as NoticeApi from '@/api/work/notice'
  36. import Navbar from '@/components/navbar/Navbar'
  37. import Record from './record'
  38. export default {
  39. components: {
  40. Navbar,
  41. Record,
  42. },
  43. data () {
  44. return {
  45. activeKey: 'unread',
  46. tabs: [{
  47. name: '未读',
  48. key: 'unread',
  49. badge: {
  50. value: 2,
  51. }
  52. }, {
  53. name: '已读',
  54. key: 'read'
  55. }, {
  56. name: '全部',
  57. key: 'all'
  58. }],
  59. params: {
  60. pageNum: 0,
  61. pageSize: 10
  62. },
  63. list: [],
  64. activeStyle: {
  65. color: '#303133',
  66. fontSize: '20px',
  67. fontWeight: 'bold',
  68. transform: 'scale(1.05)'
  69. }
  70. }
  71. },
  72. created () {
  73. this.loadData()
  74. },
  75. methods: {
  76. // 加载通知公告数据
  77. loadData () {
  78. const app = this
  79. this.params.pageNum += 1;
  80. NoticeApi.noticeList(this.params).then(res => {
  81. app.list = res.rows;
  82. })
  83. },
  84. tabChange (item) {
  85. this.activeKey = item.key;
  86. this.params.pageNum = 0;
  87. this.loadData();
  88. },
  89. // 滚动分页加载数据
  90. scrolltolower () {
  91. this.loadData();
  92. },
  93. toDetail (notice) {
  94. uni.navigateTo({ url: '/pages/work/notice/detail?id=' + notice.noticeId })
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .notice-item-tips {
  101. border-radius: 8px;
  102. background-color: #f4f4f5;
  103. padding: 9px 16px;
  104. display: flex;
  105. flex-direction: row;
  106. flex-wrap: wrap;
  107. align-items: center;
  108. }
  109. </style>