index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickRight="clickRight" @clickLeft="clickLeft" left-icon="back" left-text="返回" right-icon="search"
  7. title="测报灯系统"></uni-nav-bar>
  8. <view>
  9. <image src="../../../static/image/cb/banner.jpg" mode="widthFix"></image>
  10. </view>
  11. <view class="tab-box">
  12. <view v-for="(item,index) in equipArr" :key="item.type" @click="tabClick(index)" :class="['tab-item',active==index?'active':'']">
  13. <text>{{item.name}}</text>
  14. <text class="bottom-line"></text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="" style="position: absolute;top: 180px;width: 100%;">
  19. <view class="content">
  20. <template v-for="(item,index) in equipArr[active].list">
  21. <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index">
  22. <view class="date">
  23. 最新上报时间:{{item.addtime|timeFormat}}
  24. </view>
  25. </equipItem>
  26. </template>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="top" v-if="isTop" @click="top">
  31. <image src="../../../static/image/6209a98f0cb3b5086f2ca36152c9269.png" mode=""></image>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import equipItem from "../../../components/equip-item/equip-item"
  37. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
  38. export default {
  39. data() {
  40. return {
  41. active: 0, //默认选中虫情测报
  42. equipArr: [{
  43. name: '虫情测报',
  44. type: 3, //3虫情测报灯 7孢子仪 4智能性诱
  45. list: [],
  46. pageIndex: 1,
  47. }, {
  48. name: '孢子仪',
  49. type: 7, //3虫情测报灯 7孢子仪 4智能性诱
  50. list: [],
  51. pageIndex: 1,
  52. }, {
  53. name: '性诱测报',
  54. type: 4, //3虫情测报灯 7孢子仪 4智能性诱
  55. list: [],
  56. pageIndex: 1,
  57. }],
  58. device_id: '3', //筛选的设备id
  59. isTop: false
  60. }
  61. },
  62. onLoad() {
  63. this.getEquipList(0)
  64. this.getEquipList(1)
  65. this.getEquipList(2)
  66. },
  67. onShow() {
  68. },
  69. onHide() {
  70. },
  71. onUnload() {
  72. },
  73. onPullDownRefresh() {
  74. this.equipArr[this.active].pageIndex = 1
  75. this.equipArr[this.active].list = []
  76. this.getEquipList(this.active)
  77. setTimeout(() => {
  78. uni.stopPullDownRefresh()
  79. }, 1000)
  80. },
  81. onReachBottom() {
  82. let act = this.active
  83. if (this.equipArr[act].list.length < this.equipArr[act].pageIndex * 10) { //判断是否数据请求完
  84. return false
  85. }
  86. this.equipArr[act].pageIndex++;
  87. this.getEquipList(act)
  88. },
  89. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  90. if (e.scrollTop > 200) { //距离大于200时显示
  91. this.isTop = true
  92. } else { //距离小于200时隐藏
  93. this.isTop = false
  94. }
  95. },
  96. onBackPress(options) {
  97. if (options.from === 'navigateBack') {
  98. return false;
  99. }
  100. this.clickLeft();
  101. return true;
  102. },
  103. methods: {
  104. async getEquipList(act) {
  105. const res = await this.$myRequest({
  106. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  107. data: {
  108. device_type_id: this.equipArr[act].type,
  109. page: this.equipArr[act].pageIndex,
  110. page_size: 10,
  111. }
  112. })
  113. console.log(res)
  114. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  115. console.log(this.equipArr[act].list)
  116. },
  117. tabClick(index) {
  118. this.active = index;
  119. this.device_id = this.equipArr[index].type
  120. },
  121. clickRight() {
  122. uni.navigateTo({
  123. url: "./search?device_id="+this.device_id
  124. })
  125. },
  126. itemClick(item) {
  127. item.type = this.equipArr[this.active].type
  128. let data = JSON.stringify(item)
  129. uni.navigateTo({
  130. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  131. });
  132. },
  133. clickLeft() {
  134. uni.switchTab({
  135. url: "../../index/index"
  136. })
  137. },
  138. top() {
  139. uni.pageScrollTo({
  140. scrollTop: 0,
  141. duration: 500
  142. })
  143. }
  144. },
  145. components: {
  146. equipItem,
  147. uniNavBar
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. page {
  153. background: $uni-bg-color-grey;
  154. .content {
  155. padding: 0 20rpx 20rpx 20rpx;
  156. box-sizing: border-box;
  157. }
  158. }
  159. image {
  160. width: 100%;
  161. }
  162. .tab-box {
  163. display: flex;
  164. justify-content: space-around;
  165. font-size: 30rpx;
  166. line-height: 80rpx;
  167. background-color: #FFFFFF;
  168. margin-top: -10rpx;
  169. .tab-item {
  170. cursor: pointer;
  171. position: relative;
  172. }
  173. ;
  174. .tab-item.active {
  175. .bottom-line {
  176. bottom: 0;
  177. position: absolute;
  178. display: inline-block;
  179. width: 90rpx;
  180. height: 6rpx;
  181. left: 0;
  182. right: 0;
  183. margin: auto;
  184. background: $uni-color-success;
  185. }
  186. }
  187. }
  188. .top {
  189. position: fixed;
  190. right: 30px;
  191. bottom: 100px;
  192. z-index: 100;
  193. image {
  194. width: 100rpx;
  195. height: 100rpx;
  196. }
  197. }
  198. </style>