message.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="app-content">
  3. <view class="title-box">{{navname}}</view>
  4. <uni-section title="消息列表" type="line" class="box">
  5. <uni-list class="messageList">
  6. <uni-list-item v-for="(item, index) in msgList" :key="index" :title="item.msg" />
  7. </uni-list>
  8. </uni-section>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. navname: "消息",
  16. msgList: [],
  17. msgSJ: null
  18. }
  19. },
  20. onShow() {
  21. let that = this;
  22. this.$msg.stopMsg()
  23. uni.removeTabBarBadge({
  24. index: 1
  25. })
  26. uni.$on("scancodemsg", (data) => {
  27. if (data.msg.length > 9) {
  28. uni.navigateTo({
  29. url: "/pages/detail/index?luggageNum=" + data.msg
  30. })
  31. }
  32. });
  33. this.msgSJ = setInterval(function() {
  34. that.getMsg()
  35. }, 3000)
  36. },
  37. onLoad() {},
  38. onUnload() {
  39. this.$msg.getMsg()
  40. clearInterval(this.msgSJ)
  41. uni.$off("scancodemsg");
  42. },
  43. onHide() {
  44. uni.$off("scancodemsg");
  45. clearInterval(this.msgSJ)
  46. },
  47. methods: {
  48. getMsg() {
  49. let airPort = "CAN"
  50. if (this.$storage.get("airportName")) {
  51. airPort = this.$storage.get("airportName")
  52. }
  53. let data = {
  54. "serviceId": 3021,
  55. "page": 1,
  56. "pageSize": 9999,
  57. "dataContent": [{
  58. "outAirport": airPort
  59. }]
  60. }
  61. this.$http.httpPost('/openApi/query', data).then(res => {
  62. if (res.code == "0") {
  63. this.$storage.setJson('msgList', res.returnData)
  64. this.msgList = res.returnData
  65. this.msgList.map(item => {
  66. if (item.abnormalState == "DLY") {
  67. // 2023-07-06,航班(MU2948,CAN-->CZX),发生(延误或者取消)
  68. item['msg'] = item.carrierFlightsDate + ",航班:" + item.carrierFlights +
  69. "(" + item.outAirport + "-" + item.landAirport + "),延误"
  70. }
  71. if (item.abnormalState == "CAN") {
  72. // 2023-07-06,航班(MU2948,CAN-->CZX),发生(延误或者取消)
  73. item['msg'] = item.carrierFlightsDate + ",航班:" + item.carrierFlights +
  74. "(" + item.outAirport + "-" + item.landAirport + "),取消"
  75. }
  76. })
  77. } else {
  78. uni.showToast({
  79. icon: 'none',
  80. title: "查询信息失败",
  81. duration: 5000
  82. });
  83. }
  84. })
  85. },
  86. scan() {
  87. uni.scanCode({
  88. onlyFromCamera: true,
  89. success: function(res) {
  90. if (res.result.length > 9) {
  91. uni.navigateTo({
  92. url: "/pages/detail/index?luggageNum=" + res.result
  93. })
  94. }
  95. }
  96. });
  97. },
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .app-content {
  103. position: relative;
  104. background: rgb(49, 85, 99);
  105. padding-top: 3.6rem;
  106. box-sizing: border-box;
  107. height: 100vh;
  108. >.title-box {
  109. width: 100%;
  110. height: 2.375rem;
  111. display: flex;
  112. justify-content: center;
  113. align-items: center;
  114. padding-top: 1.25rem;
  115. color: rgb(255, 255, 255);
  116. font-family: Noto Sans SC;
  117. font-size: 1rem;
  118. position: fixed;
  119. top: 0;
  120. left: 0;
  121. z-index: 1000;
  122. }
  123. >.box{
  124. width: 100%;
  125. height:calc(100vh - 3rem);
  126. overflow-x: hidden;
  127. overflow-y: auto;
  128. // >.messageList {
  129. // width: 100%;
  130. // height:calc(100% - 1rem);
  131. // overflow-x: hidden;
  132. // overflow-y: auto;
  133. // }
  134. }
  135. }
  136. </style>