search.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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="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. </view>
  25. <view class="list_item_btn" @click.stop="modification(item)">
  26. 修改名称
  27. </view>
  28. </view>
  29. <view class="none" v-if="eqlistdatatf">
  30. 暂无数据
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. Debounce,
  38. Throttle
  39. } from "../../util/anitthro.js"
  40. export default {
  41. data() {
  42. return {
  43. imports: '',
  44. eqlistdata: [],
  45. images: [{
  46. path: "../../static/image/fourMoodBase/scd.png",
  47. id: 2
  48. },
  49. {
  50. path: "../../static/image/fourMoodBase/cbd.png",
  51. id: 3
  52. }, {
  53. path: "../../static/image/fourMoodBase/xycb.png",
  54. id: 4
  55. }, {
  56. path: "../../static/image/fourMoodBase/qxz.png",
  57. id: 5
  58. }, {
  59. path: "../../static/image/fourMoodBase/jk.png",
  60. id: 6
  61. }, {
  62. path: "../../static/image/fourMoodBase/bzy.png",
  63. id: 7
  64. }
  65. ],
  66. eqlistdatatf: false, //暂无数据
  67. indexs: 2, //设备id
  68. page: 1,
  69. size: 10
  70. }
  71. },
  72. methods: {
  73. async eqlist() { //设备列表
  74. const res = await this.$myRequest({
  75. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  76. data: {
  77. device_type_id: this.indexs,
  78. device_id: this.imports,
  79. page: this.page,
  80. page_size: this.size,
  81. }
  82. })
  83. this.eqlistdata = this.eqlistdata.concat(res.data)
  84. console.log(this.eqlistdata)
  85. if (this.eqlistdata.length == 0) {
  86. this.eqlistdatatf = true
  87. } else {
  88. this.eqlistdatatf = false
  89. }
  90. },
  91. clickLeft() { //返回
  92. uni.switchTab({
  93. url: "./index"
  94. })
  95. },
  96. search() { //搜索
  97. this.eqlistdata = []
  98. this.page = 1
  99. this.eqlist()
  100. },
  101. searchinput() {
  102. Debounce(() => {
  103. this.eqlistdata = []
  104. this.page = 1
  105. this.eqlist()
  106. }, 1000)()
  107. },
  108. modification(item) {
  109. uni.navigateTo({
  110. url: "./modification?data=" + JSON.stringify(item) + "&id=" + (this.indexs)
  111. })
  112. },
  113. historys(item) {
  114. switch (Number(this.indexs)) {
  115. case 2:
  116. uni.navigateTo({
  117. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  118. })
  119. break;
  120. case 5:
  121. console.log(item)
  122. var obj = {}
  123. obj.d_id = item.d_id
  124. obj.equip_id = item.imei
  125. obj.is_online = item.is_online
  126. obj.lat = item.lat
  127. obj.lng = item.lng
  128. obj.equip_name = item.device_name
  129. obj.uptime = item.addtime
  130. uni.navigateTo({
  131. url: "../environment/equipment?shebei=" + JSON.stringify(obj)
  132. })
  133. break;
  134. case 6:
  135. uni.navigateTo({
  136. url: "/pages/webview?device_id=" + item.imei + "&accessToken=" + this.accessToken
  137. })
  138. break;
  139. default:
  140. item.type = this.indexs
  141. uni.navigateTo({
  142. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  143. })
  144. break;
  145. }
  146. }
  147. },
  148. onLoad(option) {
  149. this.indexs = option.id
  150. console.log(this.indexs)
  151. },
  152. onReachBottom() {
  153. this.page++
  154. this.eqlist()
  155. },
  156. onBackPress(options) {
  157. if (options.from === 'navigateBack') {
  158. return false;
  159. }
  160. this.clickLeft();
  161. return true;
  162. },
  163. }
  164. </script>
  165. <style lang="scss">
  166. .search_top_input {
  167. width: 80%;
  168. height: 54rpx;
  169. background-color: #E4E4E4;
  170. border-radius: 27rpx;
  171. position: absolute;
  172. top: 18rpx;
  173. right: 18rpx;
  174. padding-top: 8rpx;
  175. box-sizing: border-box;
  176. input {
  177. width: 85%;
  178. text-indent: 1rem;
  179. font-size: 26rpx;
  180. }
  181. .icon {
  182. position: absolute;
  183. top: 18rpx;
  184. right: 32rpx;
  185. }
  186. }
  187. .search_bot_input {
  188. width: 80%;
  189. height: 54rpx;
  190. background-color: #E4E4E4;
  191. border-radius: 27rpx;
  192. position: absolute;
  193. top: 18px;
  194. right: 18rpx;
  195. box-sizing: border-box;
  196. padding-top: 8rpx;
  197. input {
  198. width: 85%;
  199. text-indent: 1rem;
  200. font-size: 26rpx;
  201. }
  202. .icon {
  203. position: absolute;
  204. top: 8rpx;
  205. right: 26rpx;
  206. }
  207. }
  208. .list {
  209. width: 100%;
  210. background-color: #FDFDFD;
  211. position: absolute;
  212. top: 100px;
  213. .list_item {
  214. width: 95%;
  215. margin: 20rpx auto;
  216. padding: 10rpx 20rpx;
  217. position: relative;
  218. background-color: #FFFFFF;
  219. box-sizing: border-box;
  220. box-shadow: 0 0 10rpx #bcb9ca;
  221. .list_item_top {
  222. display: flex;
  223. justify-content: space-between;
  224. .p1 {
  225. height: 60rpx;
  226. line-height: 60rpx;
  227. font-size: 28rpx;
  228. image {
  229. width: 40rpx;
  230. height: 40rpx;
  231. vertical-align: text-top;
  232. margin-right: 20rpx;
  233. }
  234. }
  235. .p2 {
  236. height: 60rpx;
  237. line-height: 60rpx;
  238. font-size: 28rpx;
  239. color: #42b983;
  240. }
  241. .p_out {
  242. height: 60rpx;
  243. line-height: 60rpx;
  244. font-size: 28rpx;
  245. color: red;
  246. }
  247. }
  248. .list_item_text {
  249. margin-top: 20rpx;
  250. p {
  251. font-size: 24rpx;
  252. color: #636363;
  253. margin-top: 10rpx;
  254. }
  255. p:first-child {
  256. font-size: 28rpx;
  257. font-weight: 700;
  258. }
  259. }
  260. .list_item_btn {
  261. width: 126rpx;
  262. color: #42b983;
  263. height: 40rpx;
  264. text-align: center;
  265. border: 1rpx solid #42b983;
  266. border-radius: 25rpx;
  267. font-size: 24rpx;
  268. line-height: 35rpx;
  269. position: absolute;
  270. top: 136rpx;
  271. right: 20rpx;
  272. }
  273. }
  274. .none {
  275. width: 100%;
  276. height: 100rpx;
  277. line-height: 100rpx;
  278. font-size: 32rpx;
  279. text-align: center;
  280. }
  281. }
  282. </style>