search.vue 8.6 KB

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