list.vue 4.2 KB

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