search.vue 7.4 KB

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