index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view>
  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 @clickLeft="clickLeft" left-icon="back" left-text="返回" title="防治系统" right-icon="search"
  7. @clickRight="clickRight" size="16"></uni-nav-bar>
  8. <view class="inputs" :style="{'width':width+'rpx'}">
  9. <input type="text" value="" placeholder="请输入设备ID或设备名称" v-model="imports" @input="searchinp"
  10. class="inputbox" :clearable="false" />
  11. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  12. </view>
  13. </view>
  14. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/prevention/1.png'" mode="" class="image">
  15. </image>
  16. <view class="loading" v-if="loadingtf">
  17. <image src="../../static/images/ajax-loader.gif" mode="" class="img"></image>
  18. </view>
  19. <view class="prevents">
  20. <view class="prevents_item" v-for="item,index in eqlistdata" :key="index" @click="eqdetails(item)">
  21. <image
  22. :src="item.is_online==1?'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/6.png':'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/7.png'"
  23. mode="" class="prevents_item_img"></image>
  24. <view class="prevents_item_top">
  25. <p>设备名称:{{item.device_name==""?"无":item.device_name}}</p>
  26. <p :class="item.is_online==1?'green':'red'" v-text="item.is_online==1?'在线':'离线'"></p>
  27. </view>
  28. <view class="prevents_item_bot">
  29. <p>设备 ID:{{item.imei}}</p>
  30. <p>最新上报时间:{{item.addtime|timeFormat()}}</p>
  31. <view class="" style="display: flex;justify-content: space-between;">
  32. <p>设备到期情况:<span
  33. :class="'prevents_item_bot_sapn'+item.device_expire">{{item.device_expiretext}}</span>
  34. </p>
  35. <p style="color: #3C84FE;" v-if="item.device_expire!=0" @click.stop="examine(item)">查看详情</p>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <u-modal v-model="show" :title="title" :showConfirmButton="false" :title-style="{'text-align':'left','padding-left':'10px','font-weight':700}" :mask-close-able="true">
  42. <view class="slot-content">
  43. <rich-text :nodes="content"></rich-text>
  44. </view>
  45. </u-modal>
  46. <view class="top">
  47. <view class="backtop" @click="top" v-if="isTop">
  48. <image src="../../static/images/1.png" mode="" class="img0"></image>
  49. </view>
  50. <view class="more">
  51. <view class="box" @click="online" v-show="filtrateTF">
  52. <p>在线</p>
  53. </view>
  54. <view class="box" @click="offline" v-show="filtrateTF">
  55. <p>离线</p>
  56. </view>
  57. <view class="box" @click="complete" v-show="filtrateTF">
  58. <p>全部</p>
  59. </view>
  60. <view @click="filtrate">
  61. <image src="../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png" mode="" class="img1"></image>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. Debounce
  70. } from "../../util/anitthro.js"
  71. export default {
  72. data() {
  73. return {
  74. page: 1,
  75. size: 10,
  76. eqlistdata: [],
  77. isTop: false,
  78. filtrateTF: false,
  79. device_status: "",
  80. width: 0,
  81. imports: "", //搜索内容
  82. loadingtf: false, //loading
  83. show: false,
  84. title: "",
  85. content: ""
  86. }
  87. },
  88. methods: {
  89. async eqlist() { //设备列表
  90. this.loadingtf = true
  91. const res = await this.$myRequest({
  92. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  93. data: {
  94. device_type_id: 2,
  95. page: this.page,
  96. page_size: "10",
  97. device_status: this.device_status,
  98. device_id: this.imports
  99. }
  100. })
  101. this.loadingtf = false
  102. this.eqlistdata = this.eqlistdata.concat(res.data)
  103. for (var i = 0; i < this.eqlistdata.length; i++) {
  104. if (this.eqlistdata[i].device_expire == 0) {
  105. this.eqlistdata[i]['device_expiretext'] = "未到期"
  106. } else if (this.eqlistdata[i].device_expire == 1) {
  107. this.eqlistdata[i]['device_expiretext'] = "已到期"
  108. } else if (this.eqlistdata[i].device_expire == 2) {
  109. this.eqlistdata[i]['device_expiretext'] = "即将到期"
  110. }
  111. }
  112. console.log(this.eqlistdata)
  113. },
  114. clickLeft() {
  115. uni.switchTab({
  116. url: "../index/index"
  117. })
  118. },
  119. clickRight() {
  120. // uni.navigateTo({
  121. // url: "./search"
  122. // })
  123. this.width = 600
  124. },
  125. eqdetails(data) {
  126. uni.navigateTo({
  127. url: "./equipmentdetails?shebei=" + JSON.stringify(data)
  128. })
  129. },
  130. filtrate() {
  131. this.filtrateTF = !this.filtrateTF
  132. },
  133. top() {
  134. uni.pageScrollTo({
  135. scrollTop: 0,
  136. duration: 500
  137. })
  138. },
  139. online() {
  140. this.eqlistdata = []
  141. this.page = 1
  142. this.device_status = 1
  143. this.eqlist()
  144. this.filtrateTF = !this.filtrateTF
  145. },
  146. offline() {
  147. this.eqlistdata = []
  148. this.page = 1
  149. this.device_status = 0
  150. this.eqlist()
  151. this.filtrateTF = !this.filtrateTF
  152. },
  153. complete() {
  154. this.eqlistdata = []
  155. this.page = 1
  156. this.device_status = ""
  157. this.eqlist()
  158. this.filtrateTF = !this.filtrateTF
  159. },
  160. search() { //搜索按钮搜索
  161. // this.eqlistdata = []
  162. this.searchinp()
  163. },
  164. searchinp() { //自动搜索
  165. Debounce(() => {
  166. this.page = 1
  167. this.eqlistdata = []
  168. this.eqlist()
  169. }, 1000)()
  170. },
  171. examine(e) {
  172. // console.log(this)
  173. this.show = true
  174. this.title = e.device_expiretext
  175. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  176. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  177. },
  178. timezhuan(time) {
  179. function fun(a) {
  180. return String(a).length == 1 ? '0' + a : a
  181. }
  182. let date = new Date(time * 1000)
  183. let y = date.getFullYear()
  184. let m = date.getMonth() + 1
  185. let d = date.getDate()
  186. let h = date.getHours()
  187. let min = date.getMinutes()
  188. let sec = date.getSeconds()
  189. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  190. },
  191. },
  192. onLoad() {
  193. this.eqlist()
  194. },
  195. onReachBottom() {
  196. this.page++
  197. this.eqlist()
  198. },
  199. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  200. if (e.scrollTop > 200) { //距离大于200时显示
  201. this.isTop = true
  202. } else { //距离小于200时隐藏
  203. this.isTop = false
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. .inputs {
  210. height: 54rpx;
  211. background-color: #E4E4E4;
  212. border-radius: 27rpx;
  213. position: absolute;
  214. right: 20rpx;
  215. top: 24rpx;
  216. transition: width 0.5s;
  217. overflow: hidden;
  218. padding-top: 8rpx;
  219. box-sizing: border-box;
  220. .inputbox {
  221. width: 85%;
  222. text-indent: 1rem;
  223. font-size: 26rpx;
  224. }
  225. .icon {
  226. position: absolute;
  227. top: 8rpx;
  228. right: 26rpx;
  229. }
  230. }
  231. /deep/.uni-icons {
  232. font-size: 40rpx !important;
  233. }
  234. .image {
  235. position: fixed;
  236. top: 88px;
  237. width: 100%;
  238. height: 160rpx;
  239. z-index: 555;
  240. }
  241. .loading {
  242. position: fixed;
  243. top: 440px;
  244. width: 95%;
  245. left: 2.5%;
  246. text-align: center;
  247. .img {
  248. width: 300rpx;
  249. height: 40rpx;
  250. }
  251. }
  252. .prevents {
  253. width: 100%;
  254. position: absolute;
  255. top: 140px;
  256. .prevents_item {
  257. width: 95%;
  258. margin: 0 auto 30rpx;
  259. border-radius: 10rpx;
  260. box-shadow: 0 0 10rpx #bcb9ca;
  261. padding: 20rpx 40rpx 20rpx 80rpx;
  262. position: relative;
  263. box-sizing: border-box;
  264. .prevents_item_img {
  265. width: 30rpx;
  266. height: 50rpx;
  267. position: absolute;
  268. top: -4rpx;
  269. left: 30rpx;
  270. }
  271. .prevents_item_top {
  272. display: flex;
  273. justify-content: space-between;
  274. height: 60rpx;
  275. border-bottom: 2rpx solid #F4F4F4;
  276. line-height: 60rpx;
  277. font-size: 26rpx;
  278. .red {
  279. color: #FF4747;
  280. }
  281. .green {
  282. color: #00B075;
  283. }
  284. }
  285. .prevents_item_bot {
  286. margin-top: 20rpx;
  287. font-size: 26rpx;
  288. color: #BDBDBD;
  289. .prevents_item_bot_sapn0 {
  290. color: #00B075;
  291. }
  292. .prevents_item_bot_sapn1 {
  293. color: #FF4747;
  294. }
  295. .prevents_item_bot_sapn2 {
  296. color: #FFAB00;
  297. }
  298. }
  299. }
  300. }
  301. .top {
  302. position: fixed;
  303. right: 10px;
  304. bottom: 40px;
  305. z-index: 100;
  306. image {
  307. width: 100rpx;
  308. height: 100rpx;
  309. }
  310. .backtop {
  311. display: flex;
  312. justify-content: flex-end;
  313. margin-bottom: 10rpx;
  314. }
  315. .more {
  316. display: flex;
  317. }
  318. .box {
  319. width: 80rpx;
  320. height: 80rpx;
  321. background-color: rgba(161, 161, 161, 0.45);
  322. border-radius: 50%;
  323. text-align: center;
  324. line-height: 80rpx;
  325. box-sizing: border-box;
  326. margin: 14rpx 10rpx 0 0;
  327. color: #fff;
  328. }
  329. }
  330. </style>