search.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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[current].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. current: 0,
  46. images: [{
  47. path: "../../static/image/fourMoodBase/scd.png",
  48. id: 2
  49. },
  50. {
  51. path: "../../static/image/fourMoodBase/cbd.png",
  52. id: 3
  53. }, {
  54. path: "../../static/image/fourMoodBase/xycb.png",
  55. id: 4
  56. }, {
  57. path: "../../static/image/fourMoodBase/qxz.png",
  58. id: 5
  59. }, {
  60. path: "../../static/image/fourMoodBase/jk.png",
  61. id: 6
  62. }, {
  63. path: "../../static/image/fourMoodBase/bzy.png",
  64. id: 7
  65. }
  66. ],
  67. eqlistdatatf: false, //暂无数据
  68. indexs: 2, //设备id
  69. page: 1,
  70. size: 10
  71. }
  72. },
  73. methods: {
  74. async eqlist() { //设备列表
  75. const res = await this.$myRequest({
  76. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  77. data: {
  78. device_type_id: this.indexs,
  79. device_id: this.imports,
  80. page: this.page,
  81. page_size: this.size,
  82. }
  83. })
  84. this.eqlistdata = this.eqlistdata.concat(res.data)
  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 (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. },
  151. onReachBottom() {
  152. this.page++
  153. this.eqlist()
  154. },
  155. onBackPress(options) {
  156. if (options.from === 'navigateBack') {
  157. return false;
  158. }
  159. this.clickLeft();
  160. return true;
  161. },
  162. }
  163. </script>
  164. <style lang="scss">
  165. .search_top_input {
  166. width: 80%;
  167. height: 54rpx;
  168. background-color: #E4E4E4;
  169. border-radius: 27rpx;
  170. position: absolute;
  171. top: 18rpx;
  172. right: 18rpx;
  173. padding-top: 8rpx;
  174. box-sizing: border-box;
  175. input {
  176. width: 85%;
  177. text-indent: 1rem;
  178. font-size: 26rpx;
  179. }
  180. .icon {
  181. position: absolute;
  182. top: 18rpx;
  183. right: 32rpx;
  184. }
  185. }
  186. .search_bot_input {
  187. width: 80%;
  188. height: 54rpx;
  189. background-color: #E4E4E4;
  190. border-radius: 27rpx;
  191. position: absolute;
  192. top: 18px;
  193. right: 18rpx;
  194. box-sizing: border-box;
  195. padding-top: 8rpx;
  196. input {
  197. width: 85%;
  198. text-indent: 1rem;
  199. font-size: 26rpx;
  200. }
  201. .icon {
  202. position: absolute;
  203. top: 8rpx;
  204. right: 26rpx;
  205. }
  206. }
  207. .list {
  208. width: 100%;
  209. background-color: #FDFDFD;
  210. position: absolute;
  211. top: 100px;
  212. .list_item {
  213. width: 95%;
  214. margin: 20rpx auto;
  215. padding: 10rpx 20rpx;
  216. position: relative;
  217. background-color: #FFFFFF;
  218. box-sizing: border-box;
  219. box-shadow: 0 0 10rpx #bcb9ca;
  220. .list_item_top {
  221. display: flex;
  222. justify-content: space-between;
  223. .p1 {
  224. height: 60rpx;
  225. line-height: 60rpx;
  226. font-size: 28rpx;
  227. image {
  228. width: 40rpx;
  229. height: 40rpx;
  230. vertical-align: text-top;
  231. margin-right: 20rpx;
  232. }
  233. }
  234. .p2 {
  235. height: 60rpx;
  236. line-height: 60rpx;
  237. font-size: 28rpx;
  238. color: #42b983;
  239. }
  240. .p_out {
  241. height: 60rpx;
  242. line-height: 60rpx;
  243. font-size: 28rpx;
  244. color: red;
  245. }
  246. }
  247. .list_item_text {
  248. margin-top: 20rpx;
  249. p {
  250. font-size: 24rpx;
  251. color: #636363;
  252. margin-top: 10rpx;
  253. }
  254. p:first-child {
  255. font-size: 28rpx;
  256. font-weight: 700;
  257. }
  258. }
  259. .list_item_btn {
  260. width: 126rpx;
  261. color: #42b983;
  262. height: 40rpx;
  263. text-align: center;
  264. border: 1rpx solid #42b983;
  265. border-radius: 25rpx;
  266. font-size: 24rpx;
  267. line-height: 35rpx;
  268. position: absolute;
  269. top: 136rpx;
  270. right: 20rpx;
  271. }
  272. }
  273. .none {
  274. width: 100%;
  275. height: 100rpx;
  276. line-height: 100rpx;
  277. font-size: 32rpx;
  278. text-align: center;
  279. }
  280. }
  281. </style>