index.vue 8.7 KB

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