index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="监控系统"></uni-nav-bar>
  7. <view class="" style="margin-top: -10rpx;">
  8. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/monitor/banner.png'" mode="widthFix"></image>
  9. </view>
  10. </view>
  11. <view class="contenttf" v-if="contenttf">
  12. 暂无数据
  13. </view>
  14. <view class="content" v-else>
  15. <template v-for="(item,index) in listArr">
  16. <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index">
  17. <view class="type-name">
  18. <view class="iconfont icon-jiankong"></view>
  19. <text>
  20. 监控
  21. </text>
  22. </view>
  23. </equipItem>
  24. </template>
  25. </view>
  26. </view>
  27. <view class="top" v-if="isTop" @click="top">
  28. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import equipItem from "../../components/equip-item/equip-item"
  34. export default {
  35. data() {
  36. return {
  37. listArr: [],
  38. page: 1,
  39. accessToken: '',
  40. counts: '',
  41. isTop:false,
  42. contenttf:false,
  43. }
  44. },
  45. onLoad() {
  46. this.getEquipList()
  47. },
  48. onPullDownRefresh() {
  49. this.page = 1
  50. this.listArr = []
  51. this.getEquipList()
  52. setTimeout(() => {
  53. uni.stopPullDownRefresh()
  54. }, 1000)
  55. },
  56. onReachBottom() {
  57. this.page++
  58. if (this.counts == this.listArr.length) {
  59. return false
  60. }
  61. this.getEquipList()
  62. },
  63. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  64. if (e.scrollTop > 200) { //距离大于200时显示
  65. this.isTop = true
  66. } else { //距离小于200时隐藏
  67. this.isTop = false
  68. }
  69. },
  70. methods: {
  71. async getEquipList() {
  72. const res = await this.$myRequest({
  73. url: '/api/api_gateway?method=camera.camera_manage.list_camera',
  74. data: {
  75. page: this.page
  76. }
  77. })
  78. console.log(res)
  79. if(res.counts==0){
  80. this.contenttf = true
  81. }else{
  82. this.contenttf = false
  83. }
  84. let data = res.data
  85. let arr = data.map(item => {
  86. item.imei=item.device_id
  87. item.is_online=item.status
  88. return {
  89. ...item,
  90. device_status: item.status
  91. }
  92. })
  93. console.log(res)
  94. console.log(this.listArr)
  95. this.listArr = [...this.listArr, ...arr]
  96. this.accessToken = res.accessToken
  97. this.counts = res.counts
  98. },
  99. clickLeft() {
  100. uni.switchTab({
  101. url: "../index/index"
  102. })
  103. },
  104. itemClick(item) {
  105. uni.navigateTo({
  106. url: "/pages/webview?device_id=" + item.device_id + "&accessToken=" + this.accessToken
  107. })
  108. },
  109. top() {
  110. uni.pageScrollTo({
  111. scrollTop: 0,
  112. duration: 500
  113. })
  114. }
  115. },
  116. components: {
  117. equipItem
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. image {
  123. width: 100%;
  124. }
  125. .type-name {
  126. color: #999;
  127. display: flex;
  128. justify-content: flex-start;
  129. font-size: 12px;
  130. text {
  131. margin-left: 10px;
  132. }
  133. }
  134. .contenttf{
  135. position: absolute;
  136. top: 170px;
  137. width: 95%;
  138. left: 2.5%;
  139. text-align: center;
  140. font-size: 20px;
  141. }
  142. .content{
  143. position: absolute;
  144. top: 130px;
  145. width: 95%;
  146. left: 2.5%;
  147. }
  148. .top {
  149. position: fixed;
  150. right: 30px;
  151. bottom: 100px;
  152. z-index: 100;
  153. image{
  154. width: 100rpx;
  155. height: 100rpx;
  156. }
  157. }
  158. </style>