msgWarn.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. onLoad(() => {
  37. let token = uni.getStorageSync('token')
  38. if (token) {
  39. getData()
  40. } else {
  41. uni.reLaunch({
  42. url: '/pages/index/index'
  43. })
  44. }
  45. })
  46. onReachBottom(() => {
  47. if (list.value.length < total.value) {
  48. currentPage.value++
  49. getData()
  50. } else {
  51. uni.showToast({
  52. title: '没有更多数据了',
  53. icon: 'none'
  54. })
  55. }
  56. })
  57. // 当前页
  58. const currentPage = ref(1)
  59. // 一页多少条数据
  60. const pageCount = ref(5)
  61. // 总条数
  62. const total = ref(0)
  63. // 筛选框当前索引
  64. const currentIndex = ref(0)
  65. // 筛选框类型数组
  66. const array = ref(['全部通知', '预警推送', '学生轨迹'])
  67. // 信息列表
  68. const list = ref([])
  69. // 获取消息提醒列表数据
  70. const getData = async () => {
  71. const res = await myRequest({
  72. url: '/wanzai/api/smart-notification/remindingList',
  73. data: {
  74. id: uni.getStorageSync('userInfo').id,
  75. currentPage: currentPage.value,
  76. pageCount: pageCount.value,
  77. type: currentIndex.value == 0 ? '' : currentIndex.value
  78. }
  79. })
  80. // console.log(res)
  81. if (res.code == 200) {
  82. list.value = [...list.value, ...res.data.list]
  83. total.value = res.data.totalCount
  84. }
  85. }
  86. // 切换筛选框回调
  87. const bindPickerChange = (e) => {
  88. currentIndex.value = e.detail.value
  89. list.value = []
  90. currentPage.value = 1
  91. getData()
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .container {
  96. display: flex;
  97. flex-direction: column;
  98. padding: 0 20rpx 20rpx 20rpx;
  99. min-height: 100vh;
  100. background-color: #f1f6fe;
  101. // 顶部筛选框区域样式
  102. .search {
  103. display: flex;
  104. justify-content: center;
  105. align-items: center;
  106. margin-top: 30rpx;
  107. width: 230rpx;
  108. height: 80rpx;
  109. font-size: 28rpx;
  110. border-radius: 56rpx;
  111. background-color: #fff;
  112. .search_icon {
  113. margin-left: 10rpx;
  114. width: 28rpx;
  115. height: 28rpx;
  116. }
  117. }
  118. .box {
  119. .box_time {
  120. display: flex;
  121. justify-content: center;
  122. align-items: center;
  123. height: 80rpx;
  124. color: #a6a6a6;
  125. font-size: 24rpx;
  126. }
  127. .box_card {
  128. display: flex;
  129. flex-direction: column;
  130. justify-content: space-evenly;
  131. box-sizing: border-box;
  132. padding: 25rpx 30rpx;
  133. line-height: 52rpx;
  134. color: #808080;
  135. font-size: 24rpx;
  136. border-radius: 8rpx;
  137. background-color: #fff;
  138. .card_title {
  139. display: flex;
  140. align-items: center;
  141. font-size: 28rpx;
  142. font-weight: bold;
  143. color: #000;
  144. .title_read {
  145. margin-right: 10rpx;
  146. width: 12rpx;
  147. height: 12rpx;
  148. border-radius: 50%;
  149. background-color: #d43030;
  150. }
  151. }
  152. .card_msg {
  153. display: flex;
  154. .img {
  155. margin-top: 10rpx;
  156. width: 100rpx;
  157. height: 160rpx;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. </style>