message.vue 3.7 KB

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