list.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="mychart-page">
  3. <view class="flex top-wrap">
  4. <searchBox
  5. placeholder="关键字搜索"
  6. :focus="focus"
  7. @change="onChange"
  8. @search="onSearch"
  9. style="flex:1"
  10. />
  11. </view>
  12. <view class="report-empty-box" v-if="list.length==0&&finished">
  13. <image
  14. :src="globalImgUrls.chartEmpty"
  15. mode="widthFix"
  16. />
  17. <view>暂无图表收藏的信息</view>
  18. </view>
  19. <view class="flex list-wrap" v-else>
  20. <view class="item" v-for="item in list" :key="item.chart_info_id">
  21. <view class="van-multi-ellipsis--l2 title">{{item.chart_name}}</view>
  22. <image class="img" :src="item.chart_image" mode="widthFix" lazy-load="true"/>
  23. </view>
  24. <view style="height:0;width: 47%;"></view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import searchBox from '@/components/searchBox/searchBox.vue'
  30. import {apiMyChartList} from '@/api/myChart'
  31. export default {
  32. components:{
  33. searchBox
  34. },
  35. data() {
  36. return {
  37. focus:false,
  38. list:[],
  39. page:1,
  40. pageSize:20,
  41. finished:false,
  42. keyword:'',
  43. classify_id:''
  44. }
  45. },
  46. onLoad(opt){
  47. this.classify_id=opt.classifyId||''
  48. const title=decodeURIComponent(opt.classifyName)||''
  49. if(title=='搜索'){
  50. this.focus=true
  51. }else{
  52. this.getList()
  53. }
  54. uni.setNavigationBarTitle({
  55. title: title,
  56. success: (result) => {},
  57. fail: () => {},
  58. complete: () => {}
  59. });
  60. },
  61. onReachBottom() {
  62. if(this.finished) return
  63. this.page++
  64. this.getList()
  65. },
  66. methods: {
  67. onChange(e){
  68. this.keyword=e
  69. },
  70. onSearch(){
  71. this.page=1
  72. this.list=[]
  73. this.finished=false
  74. this.getList()
  75. },
  76. async getList(){
  77. const res=await apiMyChartList({
  78. classify_id:this.classify_id,
  79. keyword:this.keyword,
  80. curr_page:this.page,
  81. page_size:this.pageSize
  82. })
  83. if(res.code===200){
  84. const arr=res.data.list||[]
  85. this.list=[...this.list,...arr]
  86. this.finished=res.data.paging.is_end
  87. }
  88. },
  89. },
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .mychart-page{
  94. padding-top: 132rpx;
  95. }
  96. .top-wrap{
  97. position: fixed;
  98. left: 0;
  99. top: 0;
  100. right: 0;
  101. background-color: #fff;
  102. z-index: 99;
  103. padding: 30rpx 34rpx;
  104. border-bottom: 1px solid rgba(0,0,0,0.1);
  105. align-items: center;
  106. }
  107. .list-wrap{
  108. justify-content: space-around;
  109. flex-wrap: wrap;
  110. padding: 20rpx 0;
  111. .item{
  112. padding: 20rpx;
  113. margin-bottom: 20rpx;
  114. background: #FFFFFF;
  115. border: 1px solid #EBEBEB;
  116. box-shadow: 0px 0px 12rpx rgba(204, 204, 204, 0.25);
  117. border-radius: 8rpx;
  118. width: 47%;
  119. display: flex;
  120. flex-direction: column;
  121. justify-content: space-between;
  122. align-items: center;
  123. .title{
  124. margin-bottom: 20rpx;
  125. width: 100%;
  126. }
  127. .img{
  128. width: 300rpx;
  129. height: 261rpx;
  130. background-color: #f5f5f5;
  131. }
  132. }
  133. }
  134. </style>