index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view style="position: fixed;top:44px;z-index: 100;width: 100%;">
  5. <uni-nav-bar right-icon="search" title="设备列表" @clickRight="clickRight"></uni-nav-bar>
  6. </view>
  7. <view class="utabs_box">
  8. <view class="utabs">
  9. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change" item-width="140" font-size="24" gutter="20"
  10. bar-width="60" active-color="#42b983"></u-tabs>
  11. </view>
  12. </view>
  13. <view class="list">
  14. <view class="list_item" v-for="(item,index) in eqlistdata" :key="index" @click="historys(item)">
  15. <view class="list_item_top">
  16. <p class="p1">
  17. <image :src="images[current].path" mode=""></image>
  18. {{item.device_name==''?"--":item.device_name}}
  19. </p>
  20. <p :class="[item.is_online?'p2':'p_out']">{{item.is_online?"在线":"离线"}}</p>
  21. </view>
  22. <view class="list_item_text">
  23. <p>设备ID:{{item.imei}}</p>
  24. <p>适配用户:{{item.device_user==''?"无":item.device_user}}</p>
  25. <p>添加设备时间:{{item.addtime|timeFormat()}}</p>
  26. </view>
  27. <view class="list_item_btn" @click.stop="modification(item)">
  28. 信息修改
  29. </view>
  30. </view>
  31. </view>
  32. <view class="top" v-if="isTop" @click="top">
  33. <image src="../../static/image/6209a98f0cb3b5086f2ca36152c9269.png" mode=""></image>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. list: [{
  42. name: "杀虫灯"
  43. }, {
  44. name: "测报灯"
  45. }, {
  46. name: "智能性诱"
  47. }, {
  48. name: "环境检测"
  49. }, {
  50. name: "监控设备"
  51. }, {
  52. name: "孢子仪"
  53. }],
  54. current: 0,
  55. page: 1,
  56. size: 10,
  57. images: [{
  58. path: "../../static/image/fourMoodBase/3.png", //
  59. id: 2
  60. },
  61. {
  62. path: "../../static/image/fourMoodBase/1.png",
  63. id: 3
  64. }, {
  65. path: "../../static/image/fourMoodBase/6.png",
  66. id: 4
  67. }, {
  68. path: "../../static/image/fourMoodBase/5.png",
  69. id: 5
  70. }, {
  71. path: "../../static/image/fourMoodBase/2.png",
  72. id: 6
  73. }, {
  74. path: "../../static/image/fourMoodBase/4.png",
  75. id: 7
  76. }
  77. ],
  78. eqlistdata: [],
  79. isTop: false
  80. }
  81. },
  82. methods: {
  83. async eqlist() { //设备列表
  84. const res = await this.$myRequest({
  85. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  86. data: {
  87. device_type_id: this.current + 2,
  88. page: this.page,
  89. page_size: this.size,
  90. }
  91. })
  92. this.eqlistdata = this.eqlistdata.concat(res.data)
  93. console.log(res)
  94. },
  95. //camera.camera_manage.list_camera
  96. async camera() { //设备列表
  97. const res = await this.$myRequest({
  98. url: '/api/api_gateway?method=camera.camera_manage.list_camera',
  99. data: {
  100. page_size: 1,
  101. }
  102. })
  103. this.accessToken = res.accessToken
  104. },
  105. change(index) { //头部导航栏的点击
  106. console.log(index)
  107. this.page = 1
  108. this.eqlistdata = []
  109. this.current = index
  110. this.eqlist()
  111. },
  112. clickRight() { //搜索
  113. uni.navigateTo({
  114. url: "./search?id=" + (this.current + 2)
  115. })
  116. },
  117. modification(item) {
  118. uni.navigateTo({
  119. url: "./modification?data=" + JSON.stringify(item) + "&id=" + (this.current + 2)
  120. })
  121. },
  122. top() {
  123. uni.pageScrollTo({
  124. scrollTop: 0,
  125. duration: 500
  126. })
  127. },
  128. historys(item) {
  129. switch (this.current + 2) {
  130. case 2:
  131. uni.navigateTo({
  132. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  133. })
  134. break;
  135. case 5:
  136. console.log(item)
  137. var obj = {}
  138. obj.d_id = item.d_id
  139. obj.equip_id = item.imei
  140. obj.is_online = item.is_online
  141. obj.lat = item.lat
  142. obj.lng = item.lng
  143. obj.equip_name = item.device_name
  144. obj.uptime = item.addtime
  145. uni.navigateTo({
  146. url: "../environment/equipment?shebei=" + JSON.stringify(obj)
  147. })
  148. break;
  149. case 6:
  150. uni.navigateTo({
  151. url: "/pages/webview?device_id=" + item.imei + "&accessToken=" + this.accessToken
  152. })
  153. break;
  154. default:
  155. item.type = this.current + 2
  156. uni.navigateTo({
  157. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  158. })
  159. break;
  160. }
  161. }
  162. },
  163. onLoad() {
  164. this.eqlist()
  165. this.camera()
  166. },
  167. onReachBottom() {
  168. this.page++
  169. this.eqlist()
  170. },
  171. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  172. if (e.scrollTop > 200) { //距离大于200时显示
  173. this.isTop = true
  174. } else { //距离小于200时隐藏
  175. this.isTop = false
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss">
  181. /deep/.uni-icons {
  182. font-size: 40rpx !important;
  183. }
  184. .utabs_box {
  185. width: 100%;
  186. position: fixed;
  187. top: 88px;
  188. background-color: #FFFFFF;
  189. z-index: 100;
  190. .utabs {
  191. width: 95%;
  192. margin: 0 auto;
  193. }
  194. }
  195. .list {
  196. width: 100%;
  197. background-color: #FDFDFD;
  198. margin-top: 280rpx;
  199. margin-bottom: 100rpx;
  200. .list_item {
  201. width: 90%;
  202. margin: 20rpx auto;
  203. padding: 20rpx 20rpx;
  204. box-sizing: border-box;
  205. position: relative;
  206. background-color: #FFFFFF;
  207. box-shadow: 0 0 10rpx #bcb9ca;
  208. .list_item_top {
  209. display: flex;
  210. justify-content: space-between;
  211. .p1 {
  212. height: 60rpx;
  213. line-height: 60rpx;
  214. font-size: 28rpx;
  215. image {
  216. width: 40rpx;
  217. height: 40rpx;
  218. vertical-align: text-top;
  219. margin-right: 20rpx;
  220. }
  221. }
  222. .p2 {
  223. height: 60rpx;
  224. line-height: 60rpx;
  225. font-size: 28rpx;
  226. color: #42b983;
  227. }
  228. .p_out {
  229. height: 60rpx;
  230. line-height: 60rpx;
  231. font-size: 28rpx;
  232. color: red;
  233. }
  234. }
  235. .list_item_text {
  236. margin-top: 20rpx;
  237. p {
  238. font-size: 24rpx;
  239. color: #636363;
  240. margin-top: 10rpx;
  241. }
  242. p:first-child {
  243. font-size: 28rpx;
  244. font-weight: 700;
  245. }
  246. }
  247. .list_item_btn {
  248. width: 126rpx;
  249. color: #42b983;
  250. height: 40rpx;
  251. text-align: center;
  252. border: 1rpx solid #42b983;
  253. border-radius: 25rpx;
  254. font-size: 24rpx;
  255. line-height: 35rpx;
  256. position: absolute;
  257. top: 136rpx;
  258. right: 20rpx;
  259. }
  260. }
  261. }
  262. .top {
  263. position: fixed;
  264. right: 30px;
  265. bottom: 100px;
  266. z-index: 100;
  267. image {
  268. width: 100rpx;
  269. height: 100rpx;
  270. }
  271. }
  272. </style>