index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="page-wrap">
  3. <view class="head">
  4. <uni-card padding="0" margin="5px 0">
  5. <uni-search-bar @confirm="search" v-model="keywords" @clear="search"></uni-search-bar>
  6. </uni-card>
  7. </view>
  8. <view class="pageMain">
  9. <view class="camerasbox">
  10. <view class="item" v-for="item in items" :key="item.cameraId">
  11. <view class="item-card">
  12. <uni-icons type="videocam-filled" size="40" color="#999" @click="showCamera(item)"></uni-icons>
  13. <view class="title" v-if="item.cameraTitle">{{item.cameraTitle}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import cameraApi from '@/api/camera.js'
  23. export default {
  24. data() {
  25. return {
  26. items:[],
  27. page:1,
  28. limit:20,
  29. total:0,
  30. keywords: ""
  31. }
  32. },
  33. onShow() {
  34. this.getData();
  35. },
  36. methods: {
  37. search(){
  38. this.resetFilter();
  39. this.getData()
  40. },
  41. getData(){
  42. cameraApi.getByPage({
  43. page:this.page,
  44. limit:this.limit,
  45. keywords:this.keywords
  46. }).then((res)=>{
  47. this.items=this.items.concat(res.data)
  48. this.total=res.total
  49. })
  50. },
  51. resetFilter(){
  52. this.page = 1
  53. this.limit = 20
  54. this.total = 0
  55. this.items=[]
  56. },
  57. showCamera(item){
  58. uni.navigateTo({
  59. url:`/pages/webview/webview?id=${item.cameraId}&title=${item.cameraTitle}`
  60. })
  61. },
  62. },
  63. onReachBottom() {
  64. if(this.total>this.limit*this.page){
  65. this.page++
  66. this.getData()
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .page-wrap{
  73. padding:0 20rpx;
  74. .head{
  75. position: fixed;
  76. width: 750rpx;
  77. height: 60px;
  78. left: 0;
  79. top: 0;
  80. background-color: #fff;
  81. }
  82. .pageMain{
  83. margin-top: 70px;
  84. background-color: #f5f5f5;
  85. padding-bottom: 50rpx;
  86. .camerasbox{
  87. width:100%;
  88. display: flex;
  89. align-items: center;
  90. flex-wrap: wrap;
  91. background-color: #fff;
  92. .item{
  93. width: 50%;
  94. padding: 20rpx;
  95. background-color: #fff;
  96. box-sizing: border-box;
  97. .item-card{
  98. display: flex;
  99. justify-content: center;
  100. align-items: center;
  101. flex-direction: column;
  102. box-shadow: 0 0 1px rgba(0,0,0,0.6);
  103. padding: 20rpx;
  104. .title{
  105. width: 100%;
  106. font-size: 24rpx;
  107. color: #424242;
  108. line-height: 1.4;
  109. padding-bottom: 15rpx;
  110. overflow:hidden;
  111. text-overflow:ellipsis;
  112. white-space:nowrap;
  113. text-align: center;
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. </style>