messagePush.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="tips" @click="navigateToMessagePush">
  3. <img alt="" src="@/static/images/messagePush.png">
  4. <div class="message-container">
  5. <div class="message-line message-title">近15天违禁品查获情况群体消息推送</div>
  6. <div class="message-line">{{ prohibitedItemText }}</div>
  7. <div class="message-line">{{ concealmentPositionText }}</div>
  8. <div class="message-line">{{ highRiskChannelText }}</div>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import { getPushMessage } from '@/api/home-new/home-new';
  14. export default {
  15. name: 'MessagePush',
  16. data() {
  17. return {
  18. concealmentPositionsTop3: [],
  19. highRiskChannelsTop3: [],
  20. prohibitedItemsTop3: [],
  21. }
  22. },
  23. computed: {
  24. prohibitedItemText() {
  25. if (!this.prohibitedItemsTop3 || this.prohibitedItemsTop3.length === 0) {
  26. return '移交公安TOP1:火种/打火机';
  27. }
  28. const item = this.prohibitedItemsTop3[0];
  29. const nameOne = item.categoryNameOne || '';
  30. const nameTwo = item.categoryNameTwo || '';
  31. return `移交公安TOP1:${nameOne}${nameTwo ? '/' + nameTwo : ''}`;
  32. },
  33. concealmentPositionText() {
  34. if (!this.concealmentPositionsTop3 || this.concealmentPositionsTop3.length === 0) {
  35. return '藏匿部位TOP1:随身行礼物品';
  36. }
  37. const item = this.concealmentPositionsTop3[0];
  38. const nameOne = item.positionNameOne || '';
  39. const nameTwo = item.positionNameTwo || '';
  40. return `藏匿部位TOP1:${nameOne}${nameTwo ? '/' + nameTwo : ''}`;
  41. },
  42. highRiskChannelText() {
  43. if (!this.highRiskChannelsTop3 || this.highRiskChannelsTop3.length === 0) {
  44. return '高发通道TOP1:T1航站楼/a区域/a01';
  45. }
  46. const item = this.highRiskChannelsTop3[0];
  47. const terminalName = item.terminalName || '';
  48. const areaName = item.areaName || '';
  49. const channelName = item.channelName || '';
  50. let text = '高发通道TOP1:';
  51. if (terminalName) text += terminalName;
  52. if (areaName) text += '/' + areaName;
  53. if (channelName) text += '/' + channelName;
  54. return text;
  55. }
  56. },
  57. mounted() {
  58. this.fetchPushMessage();
  59. },
  60. methods: {
  61. // 获取推送消息数据
  62. async fetchPushMessage() {
  63. try {
  64. const response = await getPushMessage();
  65. console.log('推送消息响应:', response);
  66. if (response && response.data) {
  67. const { concealmentPositionsTop3, highRiskChannelsTop3, prohibitedItemsTop3 } = response.data;
  68. this.concealmentPositionsTop3 = concealmentPositionsTop3 || [];
  69. this.highRiskChannelsTop3 = highRiskChannelsTop3 || [];
  70. this.prohibitedItemsTop3 = prohibitedItemsTop3 || [];
  71. }
  72. } catch (error) {
  73. console.error('获取推送消息失败:', error);
  74. }
  75. },
  76. // 跳转到消息推送详情页面
  77. navigateToMessagePush() {
  78. uni.navigateTo({
  79. url: '/pages/messagePush/index'
  80. });
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .tips {
  87. display: flex;
  88. align-items: center;
  89. padding: 20rpx 28rpx;
  90. background: #FFF4F4;
  91. border-radius: 32rpx;
  92. font-size: 24rpx;
  93. color: #222222;
  94. line-height: 32rpx;
  95. margin-bottom: 32rpx;
  96. cursor: pointer;
  97. transition: all 0.3s ease;
  98. img {
  99. width: 66rpx;
  100. padding-right: 28rpx;
  101. border-right: 1px solid rgba(0, 0, 0, 0.1);
  102. margin-right: 28rpx;
  103. flex-shrink: 0;
  104. margin-top: 4rpx;
  105. }
  106. .message-container {
  107. flex: 1;
  108. display: flex;
  109. flex-direction: column;
  110. gap: 8rpx;
  111. }
  112. .message-line {
  113. white-space: nowrap;
  114. overflow: hidden;
  115. text-overflow: ellipsis;
  116. }
  117. .message-title {
  118. font-weight: bold;
  119. font-size: 26rpx;
  120. }
  121. // 鼠标悬停效果
  122. &:hover {
  123. background: #FFE8E8;
  124. transform: scale(1.01);
  125. }
  126. }
  127. </style>