index.vue 7.9 KB

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