search.vue 7.0 KB

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