list-test.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 bindData"
  21. :key="index" :data-target="'move-box-' + index">
  22. <view class="cu-avatar round lg" v-bind:style="{ 'background-image': 'url(' + nowIcon+ ')' }"></view>
  23. <view class="content" v-if="nowType==1" @tap="goNowUrl" >
  24. <view class="text-grey site-tit">
  25. <text >{{item.siteName}}</text>
  26. <text >
  27. ({{nowNum}})
  28. </text>
  29. </view>
  30. </view>
  31. <view class="content" v-else @tap="goNowUrl" @longpress="showDetail(item)">
  32. <view class="text-grey site-tit">
  33. {{item.siteName}}
  34. <text>(共3个设备)</text>
  35. </view>
  36. <view class="showDetail" v-if="item.isShow" @tap.stop="goNowDetailUrl" >查看详情</view>
  37. </view>
  38. <view class="nav-right num">
  39. <view class="text-grey">
  40. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 站点列表end -->
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. // name: 'listTest',
  52. props:{
  53. bindType:{
  54. type:Number,
  55. default: ''
  56. },
  57. bindData:{
  58. type:Array,
  59. default: ''
  60. },
  61. bindUrl:{
  62. type:String,
  63. default: ''
  64. },
  65. bindDetailUrl:{
  66. type:String,
  67. default: ''
  68. },
  69. bindIcon:{
  70. type:String,
  71. default: ''
  72. },
  73. bindNum:{
  74. type:String,
  75. default: ''
  76. },
  77. },
  78. data() {
  79. return {
  80. modalName: null,
  81. nowData:this.bindData,
  82. nowUrl:this.bindUrl,
  83. nowDetailUrl:this.bindDetailUrl,
  84. nowIcon:this.bindIcon,
  85. nowNum:this.bindNum,
  86. nowType:this.bindType
  87. };
  88. },
  89. onPullDownRefresh() {
  90. console.log('refresh');
  91. setTimeout(function() {
  92. uni.stopPullDownRefresh();
  93. }, 1000);
  94. },
  95. computed: {
  96. newSiteListData() {
  97. return this.nowData.map(item => {
  98. this.$set(item, "isShow", false)
  99. return item
  100. })
  101. }
  102. },
  103. mounted() {
  104. document.addEventListener('click', (e) => {
  105. if (e.target.className != 'showDetail') {
  106. this.nowData.forEach(item => {
  107. item.isShow = false
  108. })
  109. }
  110. })
  111. },
  112. methods:{
  113. // 隐藏显示
  114. showDetail(e) {
  115. // alert(1);
  116. // 存储点击那一项的状态
  117. const nowStatu = e.isShow;
  118. // 将每一项列表的isShow设置为false,让所有的列表都隐藏
  119. this.nowData.forEach(item => {
  120. item.isShow = false
  121. })
  122. // 用于再次点击该项的取反
  123. e.isShow = !nowStatu
  124. },
  125. // 页面跳转
  126. goNowUrl() {
  127. uni.navigateTo({
  128. url: this.nowUrl,
  129. success: res => {},
  130. fail: () => {},
  131. complete: () => {}
  132. });
  133. },
  134. goNowDetailUrl() {
  135. uni.navigateTo({
  136. url: this.nowDetailUrl,
  137. success: res => {},
  138. fail: () => {},
  139. complete: () => {}
  140. });
  141. },
  142. InputFocus(e) {
  143. this.InputBottom = e.detail.height
  144. },
  145. InputBlur(e) {
  146. this.InputBottom = 0
  147. },
  148. }
  149. }
  150. </script>
  151. <style>
  152. .showDetail {
  153. position: absolute;
  154. background: #fff;
  155. box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
  156. padding: 0rpx 32rpx;
  157. border-radius: 10rpx;
  158. top: 42rpx;
  159. right: 0%;
  160. z-index: 3000000;
  161. font-size: 28rpx;
  162. }
  163. </style>