message.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view style="position: relative;">
  3. <!-- 胶囊 -->
  4. <mvBar :mysNavConfig="mysNavConfig"></mvBar>
  5. <view style="margin-top: 160rpx;"></view>
  6. <view v-for="item in messageList">
  7. <view class="message-list-cell">
  8. <view class="message-list-cell-left">
  9. <image :src="item.icon_url" style="height: 70rpx;width: 70rpx"></image>
  10. <view class="message-list-cell-left-txt">
  11. <p style="font-weight: 600;margin-bottom: 10rpx;">{{item.project_name}}</p>
  12. <p>{{item.message_content}}</p>
  13. </view>
  14. </view>
  15. <view class="message-list-cell-right">
  16. <image src="../../static/img/delete.png" style="height: 50rpx;width: 50rpx"
  17. @click="delMessage(item)"></image>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import mvBar from "@/components/mys_navBar/mysNavBar";
  25. export default {
  26. components: {
  27. mvBar,
  28. },
  29. data() {
  30. return {
  31. messageTextList: [],
  32. messageIconList: [
  33. "https://horastar.obs.cn-east-3.myhuaweicloud.com/talent_upload/icon-success.png",
  34. "https://horastar.obs.cn-east-3.myhuaweicloud.com/talent_upload/icon-notice.png",
  35. "https://horastar.obs.cn-east-3.myhuaweicloud.com/talent_upload/icon-error.png",
  36. "https://horastar.obs.cn-east-3.myhuaweicloud.com/talent_upload/icon-warning.png"
  37. ],
  38. messageList: [],
  39. mysNavConfig: {
  40. /* 开启单页显示首页图标 */
  41. isHome: true,
  42. /* 固定导航 */
  43. navFixed: true,
  44. /* 标题 (屏幕中心居中 两边图标中心居中使用slot center1) */
  45. navTitle: {
  46. text: "通知",
  47. color: "",
  48. fontSize: "32rpx", // px upx rpx
  49. fontWeight: "normal", // 100 - 700
  50. },
  51. btnType: "type2",
  52. onLeftClick: "/pages/mycenter/mycenter",
  53. /* type2 按钮 */
  54. type2Config: {
  55. // 左图标
  56. leftPath: "/static/img/png2.png",
  57. // 右图标
  58. rightPath: "/static/img/png4.png",
  59. // 圆角
  60. radius: "40rpx",
  61. },
  62. },
  63. }
  64. },
  65. async onShow() {
  66. // 显示加载中
  67. uni.showLoading({
  68. title: '加载中'
  69. });
  70. await this.getInfoList();
  71. await this.getMessage();
  72. uni.hideLoading();
  73. this.setRead();
  74. },
  75. onLoad() {},
  76. methods: {
  77. getInfoList() {
  78. return this.$http.get('/youngee/c/g/get-info-tables')
  79. .then(res => {
  80. this.messageTextList = res.data.data.MessageInfo
  81. })
  82. },
  83. getMessage() {
  84. return this.$https.get('/youngee/c/t/g/get-message')
  85. .then(res => {
  86. this.messageList = res.data.data
  87. if (this.messageList !== null) {
  88. for (let i = 0; i < this.messageList.length; ++i) {
  89. let messageId = this.messageList[i].message_id
  90. let messageType = this.messageList[i].message_type
  91. this.messageList[i].message_content = this.messageTextList[messageId - 1].text
  92. this.messageList[i].icon_url = this.messageIconList[messageType - 1]
  93. }
  94. }
  95. })
  96. },
  97. setRead() {
  98. return this.$https.post('/youngee/c/t/p/set-message-read')
  99. .then(res => {})
  100. },
  101. async delMessage(item) {
  102. // 在前端消息列表中删除该消息
  103. var i = this.messageList.indexOf(item)
  104. this.messageList.splice(i, 1)
  105. // 调用后端接口将该消息设为已读
  106. return this.$https.post('/youngee/c/t/p/delete-message', {
  107. message_id: item.id
  108. }).then(res => {})
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. p {
  115. font-size: 32rpx;
  116. }
  117. .message-list-cell {
  118. display: flex;
  119. align-items: center;
  120. justify-content: space-between;
  121. margin: 20rpx 5rpx;
  122. padding: 30rpx;
  123. box-shadow: 0 0 5px rgba(0, 0, 0, .1);
  124. }
  125. .message-list-cell-left {
  126. display: flex;
  127. align-items: center;
  128. }
  129. .message-list-cell-left-txt {
  130. margin-left: 20rpx;
  131. }
  132. </style>