index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 64px;">
  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="'http://static.yfpyx.com/bigdata_app'+'/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" v-if="item.tf" @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. <p>设备名称:{{item.device_name==""?"无":item.device_name}}</p>
  24. <p>最新上报时间:{{item.addtime|timeFormat}}</p>
  25. </view>
  26. </equipItem>
  27. </template>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="top" v-if="isTop" @click="top">
  32. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import equipItem from "../../../components/equip-item/equip-item"
  38. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
  39. export default {
  40. data() {
  41. return {
  42. active: 0, //默认选中虫情测报
  43. equipArr: [{
  44. name: '虫情测报',
  45. type: 3, //3虫情测报灯 7孢子仪 4智能性诱
  46. list: [],
  47. pageIndex: 1,
  48. tf:false,
  49. }, {
  50. name: '孢子仪',
  51. type: 7, //3虫情测报灯 7孢子仪 4智能性诱
  52. list: [],
  53. pageIndex: 1,
  54. tf:false,
  55. }, {
  56. name: '性诱测报',
  57. type: 4, //3虫情测报灯 7孢子仪 4智能性诱
  58. list: [],
  59. pageIndex: 1,
  60. tf:false,
  61. },
  62. {
  63. name: '性诱2.0',
  64. type: 10, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
  65. list: [],
  66. pageIndex: 1,
  67. tf:false
  68. }
  69. ],
  70. device_id: '3', //筛选的设备id
  71. isTop: false,
  72. }
  73. },
  74. onLoad() {
  75. uni.getStorage({
  76. key:"jurisdiction",
  77. success:(res)=>{
  78. let items = JSON.parse(res.data).filter((item)=>{
  79. return item.purview_name == "测报系统"
  80. })
  81. var arr = items[0].children
  82. for(var i =0;i<arr.length;i++){
  83. switch (arr[i].purview_name){
  84. case "虫情测报灯":
  85. this.equipArr[0].tf = true
  86. this.getEquipList(0)
  87. break
  88. case "性诱测报":
  89. this.equipArr[2].tf = true
  90. this.getEquipList(2)
  91. break
  92. case "孢子仪":
  93. this.equipArr[1].tf = true
  94. this.getEquipList(1)
  95. break
  96. case "性诱2.0":
  97. this.equipArr[3].tf = true
  98. this.getxyEquipList(3)
  99. break
  100. }
  101. }
  102. }
  103. })
  104. },
  105. onShow() {
  106. },
  107. onHide() {
  108. },
  109. onUnload() {
  110. },
  111. onPullDownRefresh() {
  112. this.equipArr[this.active].pageIndex = 1
  113. this.equipArr[this.active].list = []
  114. if(this.active==3){
  115. this.getxyEquipList(3)
  116. }else{
  117. this.getEquipList(this.active)
  118. }
  119. setTimeout(() => {
  120. uni.stopPullDownRefresh()
  121. }, 1000)
  122. },
  123. onReachBottom() {
  124. let act = this.active
  125. if (this.equipArr[act].list.length < this.equipArr[act].pageIndex * 10) { //判断是否数据请求完
  126. return false
  127. }
  128. this.equipArr[act].pageIndex++;
  129. if(this.active==3){
  130. this.getxyEquipList(3)
  131. }else{
  132. this.getEquipList(act)
  133. }
  134. },
  135. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  136. if (e.scrollTop > 200) { //距离大于200时显示
  137. this.isTop = true
  138. } else { //距离小于200时隐藏
  139. this.isTop = false
  140. }
  141. },
  142. onBackPress(options) {
  143. if (options.from === 'navigateBack') {
  144. return false;
  145. }
  146. this.clickLeft();
  147. return true;
  148. },
  149. methods: {
  150. async getEquipList(act) {
  151. const res = await this.$myRequest({
  152. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  153. data: {
  154. device_type_id: this.equipArr[act].type,
  155. page: this.equipArr[act].pageIndex,
  156. page_size: 10,
  157. }
  158. })
  159. console.log(res)
  160. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  161. console.log(this.equipArr[act].list)
  162. },
  163. async getxyEquipList(act) {
  164. const res = await this.$myRequest({
  165. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  166. data: {
  167. device_type_id: this.equipArr[act].type,
  168. page: this.equipArr[act].pageIndex,
  169. page_size: 10,
  170. }
  171. })
  172. console.log(res)
  173. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  174. console.log(this.equipArr[act].list)
  175. },
  176. tabClick(index) {
  177. this.active = index;
  178. this.device_id = this.equipArr[index].type
  179. },
  180. clickRight() {
  181. uni.navigateTo({
  182. url: "./search?device_id=" + this.device_id
  183. })
  184. },
  185. itemClick(item) {
  186. item.type = this.equipArr[this.active].type
  187. let data = JSON.stringify(item)
  188. if (item.type == 10) {
  189. uni.navigateTo({
  190. url: '/pages/cb/xy2.0/particulars?info=' + data
  191. });
  192. } else {
  193. uni.navigateTo({
  194. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  195. });
  196. }
  197. },
  198. clickLeft() {
  199. uni.switchTab({
  200. url: "../../index/index"
  201. })
  202. },
  203. top() {
  204. uni.pageScrollTo({
  205. scrollTop: 0,
  206. duration: 500
  207. })
  208. }
  209. },
  210. components: {
  211. equipItem,
  212. uniNavBar
  213. }
  214. }
  215. </script>
  216. <style lang="scss">
  217. page {
  218. background: $uni-bg-color-grey;
  219. .content {
  220. padding: 0 20rpx 20rpx 20rpx;
  221. box-sizing: border-box;
  222. }
  223. }
  224. image {
  225. width: 100%;
  226. }
  227. .tab-box {
  228. display: flex;
  229. justify-content: space-around;
  230. font-size: 30rpx;
  231. line-height: 80rpx;
  232. background-color: #FFFFFF;
  233. margin-top: -10rpx;
  234. .tab-item {
  235. cursor: pointer;
  236. position: relative;
  237. }
  238. ;
  239. .tab-item.active {
  240. .bottom-line {
  241. bottom: 0;
  242. position: absolute;
  243. display: inline-block;
  244. width: 90rpx;
  245. height: 6rpx;
  246. left: 0;
  247. right: 0;
  248. margin: auto;
  249. background: $uni-color-success;
  250. }
  251. }
  252. }
  253. .top {
  254. position: fixed;
  255. right: 30px;
  256. bottom: 100px;
  257. z-index: 100;
  258. image {
  259. width: 100rpx;
  260. height: 100rpx;
  261. }
  262. }
  263. </style>