siteList.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="site-wrapper" ref="contentWrapper" >
  3. <!-- 筛选框start -->
  4. <view class="ding">
  5. <view class="cu-bar search bg-gray filter-section">
  6. <view class="search-form round bg-white">
  7. <text class="cuIcon-search"></text>
  8. <input class="" @focus="InputFocus" @blur="InputBlur" :adjust-position="false" type="text" placeholder="请输入站点名称"
  9. confirm-type="search"></input>
  10. </view>
  11. <view class="action">
  12. <button class="cu-btn bg-blue round">查询</button>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 筛选框end -->
  17. <!-- 站点列表start -->
  18. <view class="site-items">
  19. <view class="cu-list menu-avatar">
  20. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in newSiteListData"
  21. :key="index" :data-target="'move-box-' + index">
  22. <view class="cu-avatar round lg" v-if="type==1" style="background-image: url(../../static/site-icon-alarm.png);"></view>
  23. <view class="cu-avatar round lg" v-else style="background-image: url(../../static/site-icon.png);"></view>
  24. <view class="content" v-if="type==1" @tap="goAlarmingList">
  25. <view class="text-grey site-tit">
  26. {{item.siteName}}
  27. <text>(共3个未处理告警)</text>
  28. </view>
  29. </view>
  30. <view class="content" v-else @tap="goDeviceType" @longpress="showDetail(item)">
  31. <view class="text-grey site-tit">
  32. {{item.siteName}}
  33. <text>(共3个设备)</text>
  34. </view>
  35. <view class="showDetail" v-if="item.isShow" @tap.stop="goSiteDetail" >查看详情</view>
  36. </view>
  37. <view class="nav-right num">
  38. <view class="text-grey">
  39. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 站点列表end -->
  46. </view>
  47. </template>
  48. <script>
  49. import json from '../../data/json.js';
  50. export default {
  51. data() {
  52. return {
  53. type: '0',
  54. siteListData: json.siteListData,
  55. modalName: null,
  56. listTouchStart: 0,
  57. listTouchDirection: null,
  58. CustomBar: this.CustomBar,
  59. };
  60. },
  61. onPullDownRefresh() {
  62. console.log('refresh');
  63. setTimeout(function() {
  64. uni.stopPullDownRefresh();
  65. }, 1000);
  66. },
  67. computed: {
  68. newSiteListData() {
  69. return this.siteListData.map(item => {
  70. this.$set(item, "isShow", false)
  71. return item
  72. })
  73. }
  74. },
  75. mounted() {
  76. document.addEventListener('click', (e) => {
  77. if (e.target.className != 'showDetail') {
  78. this.siteListData.forEach(item => {
  79. item.isShow = false
  80. })
  81. }
  82. })
  83. },
  84. methods: {
  85. // 隐藏显示
  86. showDetail(e) {
  87. // 存储点击那一项的状态
  88. const nowStatu = e.isShow;
  89. // 将每一项列表的isShow设置为false,让所有的列表都隐藏
  90. this.siteListData.forEach(item => {
  91. item.isShow = false
  92. })
  93. // 用于再次点击该项的取反
  94. e.isShow = !nowStatu
  95. },
  96. InputFocus(e) {
  97. this.InputBottom = e.detail.height
  98. },
  99. InputBlur(e) {
  100. this.InputBottom = 0
  101. },
  102. // 页面跳转
  103. goAlarmingList() {
  104. uni.navigateTo({
  105. url: '/pages/alarmingList/alarmingList',
  106. success: res => {},
  107. fail: () => {},
  108. complete: () => {}
  109. });
  110. },
  111. goDeviceType() {
  112. uni.navigateTo({
  113. url: '/pages/deviceType/deviceType',
  114. success: res => {},
  115. fail: () => {},
  116. complete: () => {}
  117. });
  118. },
  119. goSiteDetail() {
  120. uni.navigateTo({
  121. url: '/pages/siteDetail/siteDetail',
  122. success: res => {},
  123. fail: () => {},
  124. complete: () => {}
  125. });
  126. },
  127. }
  128. }
  129. </script>
  130. <style>
  131. .showDetail {
  132. position: absolute;
  133. background: #fff;
  134. box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
  135. padding: 0rpx 32rpx;
  136. border-radius: 10rpx;
  137. top: 42rpx;
  138. right: 0%;
  139. z-index: 3000000;
  140. font-size: 28rpx;
  141. }
  142. </style>