index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="page_container">
  3. <custom-nav-bar title="消息">
  4. <view class="nav_right_action" slot="more">
  5. <u-button
  6. type="primary"
  7. size="mini"
  8. loadingSize="12"
  9. :loading="loading"
  10. text="清空"
  11. @click="clearAll"
  12. >
  13. </u-button>
  14. </view>
  15. </custom-nav-bar>
  16. <z-paging
  17. ref="paging"
  18. default-page-size="20"
  19. loading-more-no-more-text="没有更多消息了"
  20. use-virtual-list
  21. cell-height-mode="dynamic"
  22. @query="queryList"
  23. >
  24. <template slot="cell" slot-scope="{ item, index }">
  25. <i-message-item :item="item" />
  26. </template>
  27. </z-paging>
  28. </view>
  29. </template>
  30. <script>
  31. import CustomNavBar from "../../../components/CustomNavBar/index.vue";
  32. import IMessageItem from "./IMessageItem.vue";
  33. import { PageEvents } from "../../../constant";
  34. import { getMomentLogs } from "../../../api/moments";
  35. import { clearMomentUnreadCount } from "../../../api/moments";
  36. export default {
  37. components: {
  38. CustomNavBar,
  39. IMessageItem,
  40. },
  41. data() {
  42. return {
  43. loading: false,
  44. };
  45. },
  46. methods: {
  47. queryList(pageNo, pageSize) {
  48. getMomentLogs(pageNo, Number(pageSize)).then((data) => {
  49. console.log(data);
  50. this.$refs.paging.complete(data.workMoments ?? []);
  51. });
  52. },
  53. clearAll() {
  54. this.loading = true;
  55. clearMomentUnreadCount(3)
  56. .then(() => this.$refs.paging.reload())
  57. .catch(() => uni.$u.toast("操作失败!"))
  58. .finally(() => (this.loading = false));
  59. },
  60. },
  61. onBackPress() {
  62. uni.$emit(PageEvents.RefreshMomentsUnreadCount);
  63. return false;
  64. },
  65. };
  66. </script>
  67. <style lang="scss" scoped>
  68. .page_container {
  69. .nav_right_action {
  70. font-size: 14px;
  71. padding-right: 44rpx;
  72. .u-button {
  73. background-color: transparent;
  74. border: none;
  75. color: #333;
  76. /deep/.u-button__text,
  77. /deep/.u-button__loading-text {
  78. font-size: 28rpx !important;
  79. }
  80. }
  81. }
  82. .z-paging-content {
  83. top: 44px;
  84. margin-top: var(--status-bar-height);
  85. /deep/.zp-l-container {
  86. background-color: #f6f6f6;
  87. }
  88. /deep/.zp-list-cell:last-of-type {
  89. .bottom_line {
  90. height: 0px;
  91. }
  92. }
  93. }
  94. }
  95. </style>