index.vue 8.6 KB

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