index.vue 9.3 KB

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