search.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view style="position: fixed;top: 44px; z-index: 100;height: 80rpx;background-color: #FFFFFF;padding-top: 10px;">
  5. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回"></uni-nav-bar>
  6. <view class="search_bot_input">
  7. <input type="text" value="" placeholder="请输入设备ID" v-model="imports" @input="searchinput" />
  8. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  9. </view>
  10. </view>
  11. <view class="list">
  12. <view class="list_item" v-for="(item,index) in eqlistdata" :key="index" @click="historys(item)">
  13. <view class="list_item_top">
  14. <p class="p1">
  15. <image :src="'http://static.yfpyx.com/bigdata_app'+ imgpath[0].path" mode=""></image>
  16. {{item.device_name==''?"--":item.device_name}}
  17. </p>
  18. <p :class="[item.is_online?'p2':'p_out']">{{item.is_online?"在线":"离线"}}</p>
  19. </view>
  20. <view class="list_item_text">
  21. <p>设备ID:{{item.imei}}</p>
  22. <p>适配用户:{{item.device_user==''?"无":item.device_user}}</p>
  23. <p>添加设备时间:{{item.addtime|timeFormat()}}</p>
  24. <p>添加设备时间:{{item.uptime|timeFormat()}}</p>
  25. <p>设备已运行:{{item.days}}天</p>
  26. </view>
  27. <view class="list_item_btn" v-if="infoalter" @click.stop="modification(item)">
  28. 修改名称
  29. </view>
  30. </view>
  31. <view class="none" v-if="eqlistdatatf">
  32. 暂无数据
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. Debounce,
  40. Throttle
  41. } from "../../util/anitthro.js"
  42. export default {
  43. data() {
  44. return {
  45. imports: '',
  46. eqlistdata: [],
  47. images: [{
  48. name: "杀虫灯",
  49. path: "/image/fourMoodBase/3.png", //
  50. id: 2
  51. },
  52. {
  53. name: "测报灯",
  54. path: "/image/fourMoodBase/1.png",
  55. id: 3
  56. }, {
  57. name: "性诱测报",
  58. path: "/image/fourMoodBase/6.png",
  59. id: 4
  60. }, {
  61. name: "环境监测",
  62. path: "/image/fourMoodBase/5.png",
  63. id: 5
  64. }, {
  65. name: "监控设备",
  66. path: "/image/fourMoodBase/2.png",
  67. id: 6
  68. }, {
  69. name: "孢子仪",
  70. path: "/image/fourMoodBase/4.png",
  71. id: 7
  72. },
  73. {
  74. name: "性诱2.0",
  75. path: "/image/fourMoodBase/10.png",
  76. id: 10
  77. }
  78. ],
  79. eqlistdatatf: false, //暂无数据
  80. indexs: 2, //设备id
  81. page: 1,
  82. size: 10,
  83. infoalter:false,
  84. imgpath:[]
  85. }
  86. },
  87. methods: {
  88. async eqlist() { //设备列表
  89. const res = await this.$myRequest({
  90. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  91. data: {
  92. device_type_id: this.indexs,
  93. device_id: this.imports,
  94. page: this.page,
  95. page_size: this.size,
  96. }
  97. })
  98. this.eqlistdata = this.eqlistdata.concat(res.data)
  99. var newtime = +new Date()/1000
  100. for(var i=0;i<this.eqlistdata.length;i++){
  101. var days = (newtime-this.eqlistdata[i].uptime)/60/60/24
  102. this.eqlistdata[i].days = Math.round(days)
  103. }
  104. console.log(this.eqlistdata)
  105. if (this.eqlistdata.length == 0) {
  106. this.eqlistdatatf = true
  107. } else {
  108. this.eqlistdatatf = false
  109. }
  110. },
  111. clickLeft() { //返回
  112. uni.switchTab({
  113. url: "./index"
  114. })
  115. },
  116. search() { //搜索
  117. this.eqlistdata = []
  118. this.page = 1
  119. this.eqlist()
  120. },
  121. searchinput() {
  122. Debounce(() => {
  123. this.eqlistdata = []
  124. this.page = 1
  125. this.eqlist()
  126. }, 1000)()
  127. },
  128. modification(item) {
  129. uni.navigateTo({
  130. url: "./modification?data=" + JSON.stringify(item) + "&id=" + (this.indexs)
  131. })
  132. },
  133. historys(item) {
  134. switch (this.type_id) {
  135. case 2:
  136. uni.navigateTo({
  137. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  138. })
  139. break;
  140. case 5:
  141. console.log(item)
  142. var obj = {}
  143. obj.d_id = item.d_id
  144. obj.equip_id = item.imei
  145. obj.is_online = item.is_online
  146. obj.lat = item.lat
  147. obj.lng = item.lng
  148. obj.equip_name = item.device_name
  149. obj.uptime = item.addtime
  150. uni.navigateTo({
  151. url: "../environment/equipment?shebei=" + JSON.stringify(obj)
  152. })
  153. break;
  154. case 6:
  155. uni.navigateTo({
  156. url: "/pages/webview?device_id=" + item.imei + "&accessToken=" + this.accessToken
  157. })
  158. break;
  159. case 3:
  160. item.type = this.type_id
  161. uni.navigateTo({
  162. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  163. })
  164. break;
  165. case 4:
  166. item.type = this.type_id
  167. uni.navigateTo({
  168. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  169. })
  170. break;
  171. case 7:
  172. item.type = this.type_id
  173. uni.navigateTo({
  174. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  175. })
  176. break;
  177. case 8:
  178. // item.type = this.type_id;
  179. uni.navigateTo({
  180. url: "../cb/thxydetail/thxydetail?imei=" + item.imei
  181. });
  182. break;
  183. case 12:
  184. console.log(item);
  185. uni.navigateTo({
  186. url: "../cb/xctdetail/xctdetail?info=" + JSON.stringify(item),
  187. });
  188. break;
  189. case 13:
  190. console.log(item)
  191. var obj = {}
  192. obj.d_id = item.d_id
  193. obj.device_id = item.imei
  194. obj.is_online = item.is_online
  195. obj.lat = item.lat
  196. obj.lng = item.lng
  197. obj.equip_name = item.device_name
  198. obj.uptime = item.addtime
  199. uni.navigateTo({
  200. url: "../waterandfer/datails?shebei=" + JSON.stringify(obj)
  201. })
  202. break;
  203. case 15:
  204. console.log(item)
  205. var obj = {}
  206. obj.d_id = item.d_id
  207. obj.device_id = item.imei
  208. obj.is_online = item.is_online
  209. obj.lat = item.lat
  210. obj.lng = item.lng
  211. obj.equip_name = item.device_name
  212. obj.uptime = item.addtime
  213. uni.navigateTo({
  214. url: "../environment/gsequipment?shebei=" + JSON.stringify(obj)
  215. })
  216. break;
  217. case 17:
  218. break;
  219. case 18:
  220. break;
  221. default:
  222. item.type = this.type_id
  223. uni.navigateTo({
  224. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item)
  225. })
  226. break;
  227. }
  228. }
  229. },
  230. onLoad(option) {
  231. this.indexs = option.id
  232. this.imgpath = this.images.filter((item)=>{
  233. return item.id == option.id
  234. })
  235. console.log(this.imgpath)
  236. uni.getStorage({
  237. key:"jurisdiction",
  238. success:(res)=>{
  239. console.log(JSON.parse(res.data))
  240. let items = JSON.parse(res.data).filter((item)=>{
  241. return item.purview_name == "设备管理"
  242. })
  243. let items2 = items[0].children.filter((item)=>{
  244. return item.purview_name == "设备列表"
  245. })
  246. this.infoalter = items2[0].children.some((item)=>{
  247. return item.purview_name == "修改名称" || item.purview_name == "添加位置"
  248. })
  249. },
  250. })
  251. },
  252. onReachBottom() {
  253. this.page++
  254. this.eqlist()
  255. },
  256. onBackPress(options) {
  257. if (options.from === 'navigateBack') {
  258. return false;
  259. }
  260. this.clickLeft();
  261. return true;
  262. },
  263. }
  264. </script>
  265. <style lang="scss">
  266. .search_top_input {
  267. width: 80%;
  268. height: 54rpx;
  269. background-color: #E4E4E4;
  270. border-radius: 27rpx;
  271. position: absolute;
  272. top: 18rpx;
  273. right: 18rpx;
  274. padding-top: 8rpx;
  275. box-sizing: border-box;
  276. input {
  277. width: 85%;
  278. text-indent: 1rem;
  279. font-size: 26rpx;
  280. }
  281. .icon {
  282. position: absolute;
  283. top: 18rpx;
  284. right: 32rpx;
  285. }
  286. }
  287. .search_bot_input {
  288. width: 80%;
  289. height: 54rpx;
  290. background-color: #E4E4E4;
  291. border-radius: 27rpx;
  292. position: absolute;
  293. top: 18px;
  294. right: 18rpx;
  295. box-sizing: border-box;
  296. padding-top: 8rpx;
  297. input {
  298. width: 85%;
  299. text-indent: 1rem;
  300. font-size: 26rpx;
  301. }
  302. .icon {
  303. position: absolute;
  304. top: 8rpx;
  305. right: 26rpx;
  306. }
  307. }
  308. .list {
  309. width: 100%;
  310. background-color: #FDFDFD;
  311. position: absolute;
  312. top: 100px;
  313. .list_item {
  314. width: 95%;
  315. margin: 20rpx auto;
  316. padding: 10rpx 20rpx;
  317. position: relative;
  318. background-color: #FFFFFF;
  319. box-sizing: border-box;
  320. box-shadow: 0 0 10rpx #bcb9ca;
  321. .list_item_top {
  322. display: flex;
  323. justify-content: space-between;
  324. .p1 {
  325. height: 60rpx;
  326. line-height: 60rpx;
  327. font-size: 28rpx;
  328. image {
  329. width: 40rpx;
  330. height: 40rpx;
  331. vertical-align: text-top;
  332. margin-right: 20rpx;
  333. }
  334. }
  335. .p2 {
  336. height: 60rpx;
  337. line-height: 60rpx;
  338. font-size: 28rpx;
  339. color: #42b983;
  340. }
  341. .p_out {
  342. height: 60rpx;
  343. line-height: 60rpx;
  344. font-size: 28rpx;
  345. color: red;
  346. }
  347. }
  348. .list_item_text {
  349. margin-top: 20rpx;
  350. p {
  351. font-size: 24rpx;
  352. color: #636363;
  353. margin-top: 10rpx;
  354. }
  355. p:first-child {
  356. font-size: 28rpx;
  357. font-weight: 700;
  358. }
  359. }
  360. .list_item_btn {
  361. width: 126rpx;
  362. color: #42b983;
  363. height: 40rpx;
  364. text-align: center;
  365. border: 1rpx solid #42b983;
  366. border-radius: 25rpx;
  367. font-size: 24rpx;
  368. line-height: 35rpx;
  369. position: absolute;
  370. top: 136rpx;
  371. right: 20rpx;
  372. }
  373. }
  374. .none {
  375. width: 100%;
  376. height: 100rpx;
  377. line-height: 100rpx;
  378. font-size: 32rpx;
  379. text-align: center;
  380. }
  381. }
  382. </style>