index.vue 8.1 KB

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