index.vue 7.0 KB

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