index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 64px;">
  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/monitor/detail?device_id="+item.device_id+"&accessToken="+this.accessToken
  107. // })
  108. // uni.setStorage({
  109. // key: 'obj',
  110. // data: JSON.stringify({
  111. // device_id: item.device_id,
  112. // accessToken: this.accessToken
  113. // })
  114. // })
  115. uni.navigateTo({
  116. url: "/pages/webview?device_id=" + item.device_id + "&accessToken=" + this.accessToken
  117. })
  118. },
  119. top() {
  120. uni.pageScrollTo({
  121. scrollTop: 0,
  122. duration: 500
  123. })
  124. }
  125. },
  126. components: {
  127. equipItem
  128. }
  129. }
  130. </script>
  131. <style lang="scss">
  132. image {
  133. width: 100%;
  134. }
  135. .type-name {
  136. color: #999;
  137. display: flex;
  138. justify-content: flex-start;
  139. font-size: 12px;
  140. text {
  141. margin-left: 10px;
  142. }
  143. }
  144. .contenttf{
  145. position: absolute;
  146. top: 170px;
  147. width: 95%;
  148. left: 2.5%;
  149. text-align: center;
  150. font-size: 20px;
  151. }
  152. .content{
  153. position: absolute;
  154. top: 130px;
  155. width: 95%;
  156. left: 2.5%;
  157. }
  158. .top {
  159. position: fixed;
  160. right: 30px;
  161. bottom: 100px;
  162. z-index: 100;
  163. image{
  164. width: 100rpx;
  165. height: 100rpx;
  166. }
  167. }
  168. </style>