message.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view>
  3. <view class="tab">
  4. <u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
  5. </view>
  6. <view class="list">
  7. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  8. <view class="top">
  9. <view class="icon">&#xe60d;</view>
  10. <view class="title" v-if="item.types == 1">系统消息</view>
  11. <view class="title" v-if="item.types == 2">交易消息</view>
  12. <view class="date">{{ item.createTime }}</view>
  13. </view>
  14. <view class="content">{{ item.contents }}</view>
  15. </view>
  16. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  17. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. user: this.getUser(),
  26. tab: [
  27. { name: '交易消息', types: 2 },
  28. { name: '系统消息', types: 1 }
  29. ],
  30. list: [],
  31. param: { pageNo: 1, pageSize: 10, types: 2 },
  32. loadMore: true
  33. };
  34. },
  35. onShow() {
  36. uni.removeTabBarBadge({ index: 1 });
  37. this.param.types = 2;
  38. this.refresh();
  39. },
  40. methods: {
  41. getData() {
  42. this.http.request({
  43. url: '/sp-admin/app/TbMessage/getList',
  44. data: this.param,
  45. loading: 'false',
  46. success: res => {
  47. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  48. this.list.push(...res.data.data);
  49. }
  50. });
  51. },
  52. //点击tab切换
  53. click(e) {
  54. this.param.types = e.types;
  55. this.refresh();
  56. },
  57. detail(item) {
  58. uni.navigateTo({ url: item.url });
  59. },
  60. //刷新数据
  61. refresh() {
  62. this.loadMore = true;
  63. this.param.pageNo = 1;
  64. this.list = [];
  65. this.getData();
  66. }
  67. },
  68. //下拉刷新
  69. onPullDownRefresh() {
  70. setTimeout(() => {
  71. this.refresh();
  72. uni.stopPullDownRefresh();
  73. }, 1000);
  74. },
  75. //上拉加载
  76. onReachBottom() {
  77. if (this.loadMore) {
  78. this.param.pageNo++;
  79. this.getData();
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="scss">
  85. page {
  86. background-color: #f5f5f5;
  87. }
  88. .list {
  89. padding: 12px;
  90. .item {
  91. background-color: white;
  92. border-bottom: 1px solid #f0f2f7;
  93. padding: 14px;
  94. margin-bottom: 10px;
  95. border-radius: 10px;
  96. .top {
  97. color: $font-c;
  98. border-bottom: 1px solid $line;
  99. padding-bottom: 13px;
  100. overflow: hidden;
  101. .icon {
  102. float: left;
  103. width: 17px;
  104. height: 17px;
  105. border-radius: 50%;
  106. background-color: $main-color;
  107. padding: 5px;
  108. text-align: center;
  109. line-height: 19px;
  110. color: white;
  111. }
  112. .title {
  113. float: left;
  114. font-weight: bold;
  115. padding-left: 7px;
  116. color: #192b20;
  117. }
  118. .date {
  119. float: right;
  120. color: #a0a2a6;
  121. }
  122. }
  123. .content {
  124. padding-top: 15px;
  125. color: #666666;
  126. line-height: 25px;
  127. }
  128. }
  129. }
  130. </style>