index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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="$imageURL+'/bigdata_app/image/waterandfer/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?$imageURL+ '/bigdata_app/image/prevention/6.png':$imageURL+ '/bigdata_app/image/prevention/7.png'"
  23. mode="" class="prevents_item_img"></image> 在线离线区分-->
  24. <image :src="$imageURL+ '/bigdata_app/image/prevention/6.png'" mode="" class="prevents_item_img"></image>
  25. <view class="prevents_item_top">
  26. <p>设备名称:{{item.device_name==""?"无":item.device_name}}</p>
  27. <!-- <p :class="item.is_online==1?'green':'red'" v-text="item.is_online==1?'在线':'离线'"></p> -->
  28. </view>
  29. <view class="prevents_item_bot">
  30. <p>设备 ID:{{item.device_id}}</p>
  31. <p>最新上报时间:{{item.uptime|timeFormat()}}</p>
  32. <view class="" style="display: flex;justify-content: space-between;" v-if="$QueryPermission(325)">
  33. <p>设备到期情况:<span
  34. :class="'prevents_item_bot_sapn'+item.device_expire">{{item.device_expiretext}}</span>
  35. </p>
  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. import {
  70. Debounce
  71. } from "../../util/anitthro.js"
  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. width: 0,
  82. imports: "", //搜索内容
  83. loadingtf: false, //loading
  84. show: false,
  85. title: "",
  86. content: ""
  87. }
  88. },
  89. methods: {
  90. async eqlist() { //设备列表
  91. this.loadingtf = true
  92. const res = await this.$myRequest({
  93. url: '/api/api_gateway?method=weather.weather.sf_page',
  94. data: {
  95. page: this.page,
  96. page_size: "10",
  97. device_id: this.imports,
  98. }
  99. })
  100. this.loadingtf = false
  101. this.eqlistdata = this.eqlistdata.concat(res.ids)
  102. console.log(this.eqlistdata)
  103. },
  104. clickLeft() {
  105. uni.switchTab({
  106. url: "../index/index"
  107. })
  108. },
  109. clickRight() {
  110. // uni.navigateTo({
  111. // url: "./search"
  112. // })
  113. this.width = 600
  114. this.page = 1
  115. },
  116. eqdetails(data) {
  117. uni.navigateTo({
  118. url: "./datails?shebei=" + JSON.stringify(data)
  119. })
  120. },
  121. filtrate() {
  122. this.filtrateTF = !this.filtrateTF
  123. },
  124. top() {
  125. uni.pageScrollTo({
  126. scrollTop: 0,
  127. duration: 500
  128. })
  129. },
  130. online() {
  131. this.eqlistdata = []
  132. this.page = 1
  133. this.device_status = 1
  134. this.eqlist()
  135. this.filtrateTF = !this.filtrateTF
  136. },
  137. offline() {
  138. this.eqlistdata = []
  139. this.page = 1
  140. this.device_status = 0
  141. this.eqlist()
  142. this.filtrateTF = !this.filtrateTF
  143. },
  144. complete() {
  145. this.eqlistdata = []
  146. this.page = 1
  147. this.device_status = ""
  148. this.eqlist()
  149. this.filtrateTF = !this.filtrateTF
  150. },
  151. search() { //搜索按钮搜索
  152. // this.eqlistdata = []
  153. this.searchinp()
  154. },
  155. searchinp() { //自动搜索
  156. Debounce(() => {
  157. this.page = 1
  158. this.eqlistdata = []
  159. this.eqlist()
  160. }, 1000)()
  161. },
  162. examine(e) {
  163. // console.log(this)
  164. this.show = true
  165. this.title = e.device_expiretext
  166. this.content = `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  167. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  168. },
  169. timezhuan(time) {
  170. function fun(a) {
  171. return String(a).length == 1 ? '0' + a : a
  172. }
  173. let date = new Date(time * 1000)
  174. let y = date.getFullYear()
  175. let m = date.getMonth() + 1
  176. let d = date.getDate()
  177. let h = date.getHours()
  178. let min = date.getMinutes()
  179. let sec = date.getSeconds()
  180. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  181. },
  182. },
  183. onLoad() {
  184. this.eqlist()
  185. },
  186. onReachBottom() {
  187. this.page++
  188. this.eqlist()
  189. },
  190. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  191. if (e.scrollTop > 200) { //距离大于200时显示
  192. this.isTop = true
  193. } else { //距离小于200时隐藏
  194. this.isTop = false
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. .inputs {
  201. height: 54rpx;
  202. background-color: #E4E4E4;
  203. border-radius: 27rpx;
  204. position: absolute;
  205. right: 20rpx;
  206. top: 24rpx;
  207. transition: width 0.5s;
  208. overflow: hidden;
  209. padding-top: 8rpx;
  210. box-sizing: border-box;
  211. .inputbox {
  212. width: 85%;
  213. text-indent: 1rem;
  214. font-size: 26rpx;
  215. }
  216. .icon {
  217. position: absolute;
  218. top: 8rpx;
  219. right: 26rpx;
  220. }
  221. }
  222. /deep/.uni-icons {
  223. font-size: 40rpx !important;
  224. }
  225. .image {
  226. position: fixed;
  227. top: 88px;
  228. width: 100%;
  229. height: 160rpx;
  230. z-index: 555;
  231. }
  232. .loading {
  233. position: fixed;
  234. top: 440px;
  235. width: 95%;
  236. left: 2.5%;
  237. text-align: center;
  238. .img {
  239. width: 300rpx;
  240. height: 40rpx;
  241. }
  242. }
  243. .prevents {
  244. width: 100%;
  245. position: absolute;
  246. top: 140px;
  247. .prevents_item {
  248. width: 95%;
  249. margin: 0 auto 30rpx;
  250. border-radius: 10rpx;
  251. box-shadow: 0 0 10rpx #bcb9ca;
  252. padding: 20rpx 40rpx 20rpx 80rpx;
  253. position: relative;
  254. box-sizing: border-box;
  255. .prevents_item_img {
  256. width: 30rpx;
  257. height: 50rpx;
  258. position: absolute;
  259. top: -4rpx;
  260. left: 30rpx;
  261. }
  262. .prevents_item_top {
  263. display: flex;
  264. justify-content: space-between;
  265. height: 60rpx;
  266. border-bottom: 2rpx solid #F4F4F4;
  267. line-height: 60rpx;
  268. font-size: 26rpx;
  269. .red {
  270. color: #FF4747;
  271. }
  272. .green {
  273. color: #00B075;
  274. }
  275. }
  276. .prevents_item_bot {
  277. margin-top: 20rpx;
  278. font-size: 26rpx;
  279. color: #BDBDBD;
  280. .prevents_item_bot_sapn0 {
  281. color: #00B075;
  282. }
  283. .prevents_item_bot_sapn1 {
  284. color: #FF4747;
  285. }
  286. .prevents_item_bot_sapn2 {
  287. color: #FFAB00;
  288. }
  289. }
  290. }
  291. }
  292. .top {
  293. position: fixed;
  294. right: 10px;
  295. bottom: 40px;
  296. z-index: 100;
  297. image {
  298. width: 100rpx;
  299. height: 100rpx;
  300. }
  301. .backtop {
  302. display: flex;
  303. justify-content: flex-end;
  304. margin-bottom: 10rpx;
  305. }
  306. .more {
  307. display: flex;
  308. }
  309. .box {
  310. width: 80rpx;
  311. height: 80rpx;
  312. background-color: rgba(161, 161, 161, 0.45);
  313. border-radius: 50%;
  314. text-align: center;
  315. line-height: 80rpx;
  316. box-sizing: border-box;
  317. margin: 14rpx 10rpx 0 0;
  318. color: #fff;
  319. }
  320. }
  321. </style>