warnCard.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="warn-card" @click="handleClick">
  3. <view class="warn-card__title" :class="{active:!dataSource.is_read}">
  4. {{dataSource.alert_title}}
  5. </view>
  6. <view class="warn-card__content">
  7. <view class="warn-card__item">
  8. <view class="warn-card__label">预警类型:</view>
  9. <view class="warn-card__value">{{dataSource.alert_type}}</view>
  10. </view>
  11. <view class="warn-card__item">
  12. <view class="warn-card__label">设备ID:</view>
  13. <view class="warn-card__value">{{dataSource.device_id || '-'}}</view>
  14. </view>
  15. <view class="warn-card__item" @click="handleMapCheck">
  16. <view class="warn-card__label">设备位置:</view>
  17. <view class="warn-card__value map">查看位置</view>
  18. </view>
  19. <view class="warn-card__item blocked">
  20. <view class="warn-card__label">预警内容:</view>
  21. <view class="warn-card__value">{{dataSource.message || '-'}}</view>
  22. </view>
  23. </view>
  24. <view class="warn-card__footer">
  25. <view><text class="text">{{dataSource.create_time}}</text>
  26. <uni-icons :type="dataSource.is_read?'mail-open-filled':'email'" size="18"></uni-icons>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. dataSource: {
  35. type: Object,
  36. default: () => ({})
  37. }
  38. },
  39. data() {
  40. return {}
  41. },
  42. methods:{
  43. handleClick(){
  44. if(this.dataSource.is_read){
  45. return
  46. }
  47. this.$emit('click',this.dataSource.record_id);
  48. },
  49. handleMapCheck(){
  50. if(!this.dataSource.lat && !this.dataSource.lng){
  51. uni.$u.toast('当前位置不存在');
  52. return
  53. }
  54. console.log('map click')
  55. uni.openLocation({
  56. latitude:this.dataSource.lat,
  57. longitude:this.dataSource.lng,
  58. success() {
  59. console.log('sucess open location');
  60. },
  61. fail(res){
  62. console.warn(res);
  63. }
  64. })
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .warn-card {
  71. background-color: #fff;
  72. border-radius: 16rpx;
  73. padding: 16rpx;
  74. margin-bottom: 24rpx;
  75. &__title {
  76. position: relative;
  77. padding: 0 40rpx;
  78. font-size: 16px;
  79. color: #333;
  80. line-height: 40rpx;
  81. height: 40rpx;
  82. @include line;
  83. margin-bottom: 20rpx;
  84. &::before {
  85. position: absolute;
  86. content: '';
  87. width: 20rpx;
  88. height: 20rpx;
  89. border-radius: 50%;
  90. left: 0;
  91. top: 50%;
  92. transform: translateY(-50%);
  93. background-color: #999;
  94. }
  95. &.active {
  96. color: #1B76FF;
  97. &::before {
  98. background-color: #1B76FF;
  99. }
  100. }
  101. }
  102. &__content {
  103. display: flex;
  104. justify-content: space-between;
  105. align-items: center;
  106. flex-wrap: wrap;
  107. }
  108. &__item {
  109. width: 50%;
  110. display: flex;
  111. align-items: center;
  112. margin-bottom: 20rpx;
  113. color: #333;
  114. font-size: 12px;
  115. line-height: 28rpx;
  116. &.blocked {
  117. width: 100%;
  118. }
  119. }
  120. &__value {
  121. &.map {
  122. color: #1B76FF;
  123. text-decoration: underline;
  124. }
  125. }
  126. &__footer {
  127. display: flex;
  128. justify-content: flex-end;
  129. align-items: center;
  130. font-size: 14px;
  131. line-height: 32rpx;
  132. color: #333;
  133. .text {
  134. margin-right: 20rpx;
  135. }
  136. }
  137. }
  138. </style>