search.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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://www.hnyfwlw.com:8006/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 (Number(this.indexs)) {
  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. default:
  160. item.type = this.indexs
  161. uni.navigateTo({
  162. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  163. })
  164. break;
  165. }
  166. }
  167. },
  168. onLoad(option) {
  169. this.indexs = option.id
  170. this.imgpath = this.images.filter((item)=>{
  171. return item.id == option.id
  172. })
  173. console.log(this.imgpath)
  174. uni.getStorage({
  175. key:"jurisdiction",
  176. success:(res)=>{
  177. console.log(JSON.parse(res.data))
  178. let items = JSON.parse(res.data).filter((item)=>{
  179. return item.purview_name == "设备管理"
  180. })
  181. let items2 = items[0].children.filter((item)=>{
  182. return item.purview_name == "设备列表"
  183. })
  184. this.infoalter = items2[0].children.some((item)=>{
  185. return item.purview_name == "修改名称" || item.purview_name == "添加位置"
  186. })
  187. },
  188. })
  189. },
  190. onReachBottom() {
  191. this.page++
  192. this.eqlist()
  193. },
  194. onBackPress(options) {
  195. if (options.from === 'navigateBack') {
  196. return false;
  197. }
  198. this.clickLeft();
  199. return true;
  200. },
  201. }
  202. </script>
  203. <style lang="scss">
  204. .search_top_input {
  205. width: 80%;
  206. height: 54rpx;
  207. background-color: #E4E4E4;
  208. border-radius: 27rpx;
  209. position: absolute;
  210. top: 18rpx;
  211. right: 18rpx;
  212. padding-top: 8rpx;
  213. box-sizing: border-box;
  214. input {
  215. width: 85%;
  216. text-indent: 1rem;
  217. font-size: 26rpx;
  218. }
  219. .icon {
  220. position: absolute;
  221. top: 18rpx;
  222. right: 32rpx;
  223. }
  224. }
  225. .search_bot_input {
  226. width: 80%;
  227. height: 54rpx;
  228. background-color: #E4E4E4;
  229. border-radius: 27rpx;
  230. position: absolute;
  231. top: 18px;
  232. right: 18rpx;
  233. box-sizing: border-box;
  234. padding-top: 8rpx;
  235. input {
  236. width: 85%;
  237. text-indent: 1rem;
  238. font-size: 26rpx;
  239. }
  240. .icon {
  241. position: absolute;
  242. top: 8rpx;
  243. right: 26rpx;
  244. }
  245. }
  246. .list {
  247. width: 100%;
  248. background-color: #FDFDFD;
  249. position: absolute;
  250. top: 100px;
  251. .list_item {
  252. width: 95%;
  253. margin: 20rpx auto;
  254. padding: 10rpx 20rpx;
  255. position: relative;
  256. background-color: #FFFFFF;
  257. box-sizing: border-box;
  258. box-shadow: 0 0 10rpx #bcb9ca;
  259. .list_item_top {
  260. display: flex;
  261. justify-content: space-between;
  262. .p1 {
  263. height: 60rpx;
  264. line-height: 60rpx;
  265. font-size: 28rpx;
  266. image {
  267. width: 40rpx;
  268. height: 40rpx;
  269. vertical-align: text-top;
  270. margin-right: 20rpx;
  271. }
  272. }
  273. .p2 {
  274. height: 60rpx;
  275. line-height: 60rpx;
  276. font-size: 28rpx;
  277. color: #42b983;
  278. }
  279. .p_out {
  280. height: 60rpx;
  281. line-height: 60rpx;
  282. font-size: 28rpx;
  283. color: red;
  284. }
  285. }
  286. .list_item_text {
  287. margin-top: 20rpx;
  288. p {
  289. font-size: 24rpx;
  290. color: #636363;
  291. margin-top: 10rpx;
  292. }
  293. p:first-child {
  294. font-size: 28rpx;
  295. font-weight: 700;
  296. }
  297. }
  298. .list_item_btn {
  299. width: 126rpx;
  300. color: #42b983;
  301. height: 40rpx;
  302. text-align: center;
  303. border: 1rpx solid #42b983;
  304. border-radius: 25rpx;
  305. font-size: 24rpx;
  306. line-height: 35rpx;
  307. position: absolute;
  308. top: 136rpx;
  309. right: 20rpx;
  310. }
  311. }
  312. .none {
  313. width: 100%;
  314. height: 100rpx;
  315. line-height: 100rpx;
  316. font-size: 32rpx;
  317. text-align: center;
  318. }
  319. }
  320. </style>