index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view>
  3. <view style="position: fixed;z-index: 100;width: 100%;">
  4. <uni-nav-bar right-icon="search" title="设备列表" @clickRight="clickRight"></uni-nav-bar>
  5. </view>
  6. <view class="utabs">
  7. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change" item-width="140" font-size="24" gutter="20"
  8. bar-width="60" active-color="#42b983"></u-tabs>
  9. </view>
  10. <view class="list">
  11. <view class="list_item" v-for="(item,index) in eqlistdata" :key="index">
  12. <view class="list_item_top">
  13. <p class="p1">
  14. <image :src="images[current].path" mode=""></image>
  15. {{item.device_name}}
  16. </p>
  17. <p :class="[item.device_status?'p2':'p_out']">{{item.device_status?"在线":"离线"}}</p>
  18. </view>
  19. <view class="list_item_text">
  20. <p>设备ID:{{item.device_id}}</p>
  21. <p>适配用户:无</p>
  22. <p>添加设备时间:{{item.status_time|timeFormat()}}</p>
  23. </view>
  24. <view class="list_item_btn" @click="modification(item)">
  25. 修改名称
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. list: [{
  36. name: "杀虫灯"
  37. }, {
  38. name: "测报灯"
  39. }, {
  40. name: "智能性诱"
  41. }, {
  42. name: "环境检测"
  43. }, {
  44. name: "监控设备"
  45. }, {
  46. name: "孢子仪"
  47. }],
  48. current: 0,
  49. page:1,
  50. size:10,
  51. images: [{
  52. path: "../../static/image/fourMoodBase/杀虫灯.png",
  53. id: 2
  54. },
  55. {
  56. path: "../../static/image/fourMoodBase/测报灯.png",
  57. id: 3
  58. }, {
  59. path: "../../static/image/fourMoodBase/性诱测报.png",
  60. id: 4
  61. }, {
  62. path: "../../static/image/fourMoodBase/环境监测.png",
  63. id: 5
  64. }, {
  65. path: "../../static/image/fourMoodBase/监控.png",
  66. id: 6
  67. }, {
  68. path: "../../static/image/fourMoodBase/孢子仪.png",
  69. id: 7
  70. }
  71. ],
  72. eqlistdata:[]
  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.current+2,
  81. page:this.page,
  82. size:this.size,
  83. }
  84. })
  85. this.eqlistdata=this.eqlistdata.concat(res.data)
  86. console.log(this.eqlistdata)
  87. },
  88. change(index) { //头部导航栏的点击
  89. console.log(index)
  90. this.page=1
  91. this.eqlistdata=[]
  92. this.current = index
  93. this.eqlist()
  94. },
  95. clickRight(){//搜索
  96. uni.navigateTo({
  97. url:"./search"
  98. })
  99. },
  100. modification(item){
  101. uni.navigateTo({
  102. url:"./modification?data="+JSON.stringify(item)
  103. })
  104. }
  105. },
  106. onLoad(){
  107. this.eqlist()
  108. },
  109. onReachBottom() {
  110. this.page++
  111. this.eqlist()
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. .utabs {
  117. width: 95%;
  118. position: fixed;
  119. top: 44px;
  120. z-index: 100;
  121. }
  122. .list{
  123. width: 100%;
  124. background-color: #FDFDFD;
  125. position: absolute;
  126. top: 180rpx;
  127. margin-bottom: 100rpx;
  128. .list_item{
  129. width: 95%;
  130. margin: 20rpx auto;
  131. padding: 10rpx 20rpx;
  132. position: relative;
  133. background-color: #FFFFFF;
  134. .list_item_top{
  135. display: flex;
  136. justify-content: space-between;
  137. .p1{
  138. height: 60rpx;
  139. line-height: 60rpx;
  140. font-size: 28rpx;
  141. image{
  142. width: 40rpx;
  143. height: 40rpx;
  144. vertical-align:text-top;
  145. margin-right: 20rpx;
  146. }
  147. }
  148. .p2{
  149. height: 60rpx;
  150. line-height: 60rpx;
  151. font-size: 28rpx;
  152. color: #42b983;
  153. }
  154. .p_out{
  155. height: 60rpx;
  156. line-height: 60rpx;
  157. font-size: 28rpx;
  158. color: red;
  159. }
  160. }
  161. .list_item_text{
  162. margin-top: 20rpx;
  163. p{
  164. font-size: 24rpx;
  165. color: #636363;
  166. margin-top: 10rpx;
  167. }
  168. p:first-child{
  169. font-size: 28rpx;
  170. font-weight: 700;
  171. }
  172. }
  173. .list_item_btn{
  174. width: 126rpx;
  175. color: #42b983;
  176. height: 40rpx;
  177. text-align: center;
  178. border: 1rpx solid #42b983;
  179. border-radius: 25rpx;
  180. font-size: 24rpx;
  181. line-height: 35rpx;
  182. position: absolute;
  183. top: 136rpx;
  184. right: 20rpx;
  185. }
  186. }
  187. }
  188. </style>