index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="message_wrap">
  3. <view class="message_list" v-if="isShow">
  4. <view class="message_item" v-for="(item,index) in list" :key="index" @click="handleToList(item)">
  5. <view class="item_left">
  6. <image :src="item.icon" mode=""></image>
  7. </view>
  8. <view class="item_center">
  9. <view class="item_center_top">
  10. {{item.title}}
  11. </view>
  12. <view class="item_center_bottom">
  13. {{item.message}}
  14. </view>
  15. </view>
  16. <view class="item_bottom">
  17. <text class="informNum" v-if="item.informNum">{{item.informNum}}</text>
  18. <u-icon name="arrow-right" color="#aaa"></u-icon>
  19. </view>
  20. </view>
  21. </view>
  22. <u-loading-page :loading="true" v-else></u-loading-page>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. isShow: false,
  30. list: []
  31. }
  32. },
  33. onPullDownRefresh() {
  34. uni.stopPullDownRefresh();
  35. this.getList();
  36. },
  37. methods: {
  38. handleToList(item) {
  39. uni.navigateTo({
  40. url: "/pages/messageList/index?type=" + item.type,
  41. })
  42. },
  43. async getList() {
  44. const {
  45. data
  46. } = await uni.$u.api.getAppMessageList();
  47. this.list = [{
  48. icon: "/static/message/icon-systemxx.png",
  49. title: "系统消息",
  50. message: data && data.lastSystem ? data.lastSystem.replace(/<\/?.+?>/g, "").replace(/ /g,
  51. "") : "",
  52. type: 4,
  53. informNum: data && data.unReadSysMessage ? data.unReadSysMessage : 0,
  54. }, {
  55. icon: "/static/message/icon-systemgg.png",
  56. title: "系统公告",
  57. message: data && data.lastAnnouncement ? data.lastAnnouncement.replace(/<\/?.+?>/g, "")
  58. .replace(/ /g, "") : "",
  59. type: 1,
  60. informNum: data && data.unReadAnnouncement ? data.unReadAnnouncement : 0,
  61. }, {
  62. icon: "/static/message/icon-systemxx.png",
  63. title: "系统通知",
  64. message: data && data.lastNotice ? data.lastNotice.replace(/<\/?.+?>/g, "").replace(/ /g,
  65. "") : "",
  66. type: 2,
  67. informNum: data && data.unReadNotice ? data.unReadNotice : 0,
  68. }];
  69. this.isShow = true;
  70. }
  71. },
  72. mounted() {
  73. this.getList();
  74. },
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .message_wrap {
  79. padding: 20rpx 0;
  80. .message_list {
  81. background: #ffffff;
  82. .message_item {
  83. display: flex;
  84. justify-content: space-between;
  85. align-items: center;
  86. padding: 36rpx 30rpx;
  87. border-bottom: 2rpx solid #ddd;
  88. .item_left {
  89. margin-right: 20rpx;
  90. image {
  91. width: 60rpx;
  92. height: 60rpx;
  93. }
  94. }
  95. .item_center {
  96. width: calc(100% - 100rpx);
  97. .item_center_top {
  98. font-size: 30rpx;
  99. }
  100. .item_center_bottom {
  101. font-size: 24rpx;
  102. color: #999999;
  103. margin-top: 14rpx;
  104. overflow: hidden;
  105. text-overflow: ellipsis;
  106. white-space: nowrap;
  107. }
  108. }
  109. .item_bottom {
  110. display: flex;
  111. align-items: center;
  112. .informNum {
  113. display: inline-block;
  114. line-height: 36rpx;
  115. width: 36rpx;
  116. background: #ff5e5e;
  117. color: #ffffff;
  118. border-radius: 50%;
  119. text-align: center;
  120. font-size: 22rpx;
  121. margin-right: 10rpx;
  122. }
  123. ::v-deep .u-icon__icon {
  124. font-size: 30rpx !important;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. </style>