index.vue 4.2 KB

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