index.vue 9.0 KB

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