index.vue 3.7 KB

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