search.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view style="position: fixed;z-index: 100;background-color: #FFFFFF;height: 80px;top: 40px;">
  5. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备搜索"></uni-nav-bar>
  6. <view class="search_top_input">
  7. <input type="text" value="" placeholder="请输入设备ID" v-model="imports" />
  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="$imageURL+'/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. // console.log(1)
  121. this.system(this.imports)
  122. },
  123. system(str){
  124. var arr = str.split(",")
  125. console.log(arr)
  126. },
  127. searchinput() {
  128. Debounce(() => {
  129. this.eqlistdata = []
  130. this.page = 1
  131. this.eqlist()
  132. }, 1000)()
  133. },
  134. modification(item) {
  135. uni.navigateTo({
  136. url: "./modification?data=" + JSON.stringify(item) + "&id=" + (this.indexs)
  137. })
  138. },
  139. historys(item) {
  140. switch (Number(this.indexs)) {
  141. case 2:
  142. uni.navigateTo({
  143. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  144. })
  145. break;
  146. case 5:
  147. console.log(item)
  148. var obj = {}
  149. obj.d_id = item.d_id
  150. obj.equip_id = item.imei
  151. obj.is_online = item.is_online
  152. obj.lat = item.lat
  153. obj.lng = item.lng
  154. obj.equip_name = item.device_name
  155. obj.uptime = item.addtime
  156. uni.navigateTo({
  157. url: "../environment/equipment?shebei=" + JSON.stringify(obj)
  158. })
  159. break;
  160. case 6:
  161. uni.navigateTo({
  162. url: "/pages/webview/webview?device_id=" + item.imei + "&accessToken=" + this.accessToken
  163. })
  164. break;
  165. case 44:
  166. uni.navigateTo({
  167. url: "/pages/webview?device_id=" + item.device_id + "&accessToken=" + uni
  168. .getStorageSync('session_key') +
  169. '&type=dgp'
  170. })
  171. break;
  172. default:
  173. item.type = this.indexs
  174. uni.navigateTo({
  175. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  176. })
  177. break;
  178. }
  179. }
  180. },
  181. onLoad(option) {
  182. this.indexs = option.id
  183. this.imgpath = this.images.filter((item)=>{
  184. return item.id == option.id
  185. })
  186. console.log(this.imgpath)
  187. uni.getStorage({
  188. key:"jurisdiction",
  189. success:(res)=>{
  190. console.log(JSON.parse(res.data))
  191. let items = JSON.parse(res.data).filter((item)=>{
  192. return item.purview_name == "设备管理"
  193. })
  194. let items2 = items[0].children.filter((item)=>{
  195. return item.purview_name == "设备列表"
  196. })
  197. this.infoalter = items2[0].children.some((item)=>{
  198. return item.purview_name == "修改名称" || item.purview_name == "添加位置"
  199. })
  200. },
  201. })
  202. },
  203. onReachBottom() {
  204. this.page++
  205. this.eqlist()
  206. },
  207. onBackPress(options) {
  208. if (options.from === 'navigateBack') {
  209. return false;
  210. }
  211. this.clickLeft();
  212. return true;
  213. },
  214. }
  215. </script>
  216. <style lang="scss">
  217. .search_top_input {
  218. width: 90%;
  219. height: 54rpx;
  220. background-color: #E4E4E4;
  221. border-radius: 27rpx;
  222. position: absolute;
  223. top: 100rpx;
  224. right: 5%;
  225. padding-top: 8rpx;
  226. box-sizing: border-box;
  227. input {
  228. width: 80%;
  229. // text-indent: 1rem;
  230. font-size: 26rpx;
  231. padding-left: 20px;
  232. }
  233. .icon{
  234. position: absolute;
  235. top: 8rpx;
  236. right: 26rpx;
  237. }
  238. }
  239. .search_bot_input {
  240. width: 80%;
  241. height: 54rpx;
  242. background-color: #E4E4E4;
  243. border-radius: 27rpx;
  244. position: absolute;
  245. top: 18px;
  246. right: 18rpx;
  247. box-sizing: border-box;
  248. padding-top: 8rpx;
  249. input {
  250. width: 85%;
  251. text-indent: 1rem;
  252. font-size: 26rpx;
  253. }
  254. .icon {
  255. position: absolute;
  256. top: 8rpx;
  257. right: 26rpx;
  258. }
  259. }
  260. .list {
  261. width: 100%;
  262. background-color: #FDFDFD;
  263. position: absolute;
  264. top: 120px;
  265. .list_item {
  266. width: 90%;
  267. margin: 20rpx auto;
  268. padding: 10rpx 20rpx;
  269. position: relative;
  270. background-color: #FFFFFF;
  271. box-sizing: border-box;
  272. box-shadow: 0 0 10rpx #bcb9ca;
  273. .list_item_top {
  274. display: flex;
  275. justify-content: space-between;
  276. .p1 {
  277. height: 60rpx;
  278. line-height: 60rpx;
  279. font-size: 28rpx;
  280. image {
  281. width: 40rpx;
  282. height: 40rpx;
  283. vertical-align: text-top;
  284. margin-right: 20rpx;
  285. }
  286. }
  287. .p2 {
  288. height: 60rpx;
  289. line-height: 60rpx;
  290. font-size: 28rpx;
  291. color: #42b983;
  292. }
  293. .p_out {
  294. height: 60rpx;
  295. line-height: 60rpx;
  296. font-size: 28rpx;
  297. color: red;
  298. }
  299. }
  300. .list_item_text {
  301. margin-top: 20rpx;
  302. p {
  303. font-size: 24rpx;
  304. color: #636363;
  305. margin-top: 10rpx;
  306. }
  307. p:first-child {
  308. font-size: 28rpx;
  309. font-weight: 700;
  310. }
  311. }
  312. .list_item_btn {
  313. width: 126rpx;
  314. color: #42b983;
  315. height: 40rpx;
  316. text-align: center;
  317. border: 1rpx solid #42b983;
  318. border-radius: 25rpx;
  319. font-size: 24rpx;
  320. line-height: 35rpx;
  321. position: absolute;
  322. top: 136rpx;
  323. right: 20rpx;
  324. }
  325. }
  326. .none {
  327. width: 100%;
  328. height: 100rpx;
  329. line-height: 100rpx;
  330. font-size: 32rpx;
  331. text-align: center;
  332. }
  333. }
  334. </style>