msgWarn.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="container">
  3. <!-- 顶部筛选框区域 -->
  4. <picker @change="bindPickerChange" :value="currentIndex" :range="array">
  5. <view class="search">
  6. {{ array[currentIndex] }}
  7. <img class="search_icon" src="../../static/images/bottom.png" />
  8. </view>
  9. </picker>
  10. <!-- 每一条信息区域 -->
  11. <view class="box" v-for="item in list" :key="item.id">
  12. <view class="box_time">{{ item.dateTime }}</view>
  13. <view class="box_card">
  14. <view class="card_title">
  15. <!-- <view class="title_read" v-if="item.isRead === 0"></view> -->
  16. {{ item.type == 1 ? '设备安防预警通知' : '学生出入消息提醒' }}
  17. </view>
  18. <view class="card_msg" v-if="item.userName">姓名:{{ item.userName }}</view>
  19. <view class="card_msg" v-if="item.typeName">类型:{{ item.typeName }}</view>
  20. <view class="card_msg" v-if="item.location">地点:{{ item.location }}</view>
  21. <view class="card_msg" v-if="item.image">
  22. 图片:
  23. <img mode="aspectFill" class="img" :src="item.image" @click="previewImage(item.image)" />
  24. </view>
  25. </view>
  26. </view>
  27. <NoData v-if="!list.length" />
  28. </view>
  29. </template>
  30. <script setup>
  31. import { ref } from 'vue'
  32. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  33. import NoData from '@/components/noData.vue'
  34. import { myRequest } from '@/utils/api.js'
  35. import { previewImage } from '@/utils/previewImage.js'
  36. import { decryptDes } from '@/utils/des.js'
  37. onLoad(() => {
  38. let token = uni.getStorageSync('token')
  39. if (token) {
  40. getData()
  41. } else {
  42. uni.reLaunch({
  43. url: '/pages/index/index'
  44. })
  45. }
  46. })
  47. onReachBottom(() => {
  48. if (list.value.length < total.value) {
  49. currentPage.value++
  50. getData()
  51. } else {
  52. uni.showToast({
  53. title: '没有更多数据了',
  54. icon: 'none'
  55. })
  56. }
  57. })
  58. // 当前页
  59. const currentPage = ref(1)
  60. // 一页多少条数据
  61. const pageCount = ref(5)
  62. // 总条数
  63. const total = ref(0)
  64. // 筛选框当前索引
  65. const currentIndex = ref(0)
  66. // 筛选框类型数组
  67. const array = ref(['全部通知', '设备安防预警通知', '学生出入消息提醒'])
  68. // 信息列表
  69. const list = ref([])
  70. // 获取消息提醒列表数据
  71. const getData = async () => {
  72. const res = await myRequest({
  73. url: '/wanzai/api/smart-notification/remindingList',
  74. data: {
  75. id: uni.getStorageSync('userInfo').id,
  76. currentPage: currentPage.value,
  77. pageCount: pageCount.value,
  78. type: currentIndex.value == 0 ? '' : currentIndex.value
  79. }
  80. })
  81. // console.log(res)
  82. if (res.code == 200) {
  83. const result = JSON.parse(decryptDes(res.data))
  84. // console.log(result)
  85. list.value = [...list.value, ...result.list]
  86. total.value = result.totalCount
  87. }
  88. }
  89. // 切换筛选框回调
  90. const bindPickerChange = (e) => {
  91. currentIndex.value = e.detail.value
  92. list.value = []
  93. currentPage.value = 1
  94. getData()
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .container {
  99. display: flex;
  100. flex-direction: column;
  101. padding: 0 20rpx 20rpx 20rpx;
  102. min-height: 100vh;
  103. background-color: #f1f6fe;
  104. // 顶部筛选框区域样式
  105. .search {
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. margin-top: 30rpx;
  110. width: 230rpx;
  111. height: 80rpx;
  112. font-size: 28rpx;
  113. border-radius: 56rpx;
  114. background-color: #fff;
  115. .search_icon {
  116. margin-left: 10rpx;
  117. width: 28rpx;
  118. height: 28rpx;
  119. }
  120. }
  121. .box {
  122. .box_time {
  123. display: flex;
  124. justify-content: center;
  125. align-items: center;
  126. height: 80rpx;
  127. color: #a6a6a6;
  128. font-size: 24rpx;
  129. }
  130. .box_card {
  131. display: flex;
  132. flex-direction: column;
  133. justify-content: space-evenly;
  134. box-sizing: border-box;
  135. padding: 25rpx 30rpx;
  136. line-height: 52rpx;
  137. color: #808080;
  138. font-size: 24rpx;
  139. border-radius: 8rpx;
  140. background-color: #fff;
  141. .card_title {
  142. display: flex;
  143. align-items: center;
  144. font-size: 28rpx;
  145. font-weight: bold;
  146. color: #000;
  147. .title_read {
  148. margin-right: 10rpx;
  149. width: 12rpx;
  150. height: 12rpx;
  151. border-radius: 50%;
  152. background-color: #d43030;
  153. }
  154. }
  155. .card_msg {
  156. display: flex;
  157. .img {
  158. margin-top: 10rpx;
  159. width: 100rpx;
  160. height: 160rpx;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. </style>