index.vue 8.6 KB

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