index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="mychart-page">
  3. <view class="flex top-wrap">
  4. <view style="flex:1" @click="handleGoSearch">
  5. <searchBox
  6. placeholder="关键字搜索"
  7. :hasRightBtn="false"
  8. :disabled="true"
  9. />
  10. </view>
  11. <view class="icon-box filter-box" @click="showFilter=true">
  12. <image src="@/static/question/select.png" mode="widthFix" lazy-load="false" binderror="" bindload="" />
  13. <text>筛选</text>
  14. </view>
  15. <view class="icon-box filter-box" @click="goClassifyPage">
  16. <image src="@/static/classify-icon.png" mode="widthFix" lazy-load="false" binderror="" bindload="" />
  17. <text>分类</text>
  18. </view>
  19. </view>
  20. <view class="report-empty-box" v-if="list.length==0&&finished">
  21. <image
  22. :src="globalImgUrls.chartEmpty"
  23. mode="widthFix"
  24. />
  25. <view>暂无图表收藏的信息</view>
  26. </view>
  27. <view class="flex list-wrap" v-else>
  28. <view class="item" v-for="item in list" :key="item.chart_info_id" @click="goDetail(item)">
  29. <view class="van-multi-ellipsis--l2 title">{{item.chart_name}}</view>
  30. <image class="img" :src="item.chart_image" mode="widthFix" lazy-load="true"/>
  31. </view>
  32. <view style="height:0;width: 47%;"></view>
  33. </view>
  34. <!-- 筛选弹窗 -->
  35. <van-popup
  36. :show="showFilter"
  37. @close="showFilter=false"
  38. position="bottom"
  39. closeable
  40. z-index="99999"
  41. >
  42. <view class="filter-wrap">
  43. <view class="title">筛选分类</view>
  44. <view class="filter-list">
  45. <view
  46. v-for="item in filterOpts"
  47. :key="item.my_chart_classify_id"
  48. :class="['item',item.my_chart_classify_id==classify_id?'active':'']"
  49. @click="handleFilter(item)"
  50. >{{item.my_chart_classify_name}}</view>
  51. <view v-if="filterOpts.length==0">
  52. <view style="text-align:center;padding-top:200rpx">暂无分类,请先添加图表</view>
  53. </view>
  54. </view>
  55. </view>
  56. </van-popup>
  57. </view>
  58. </template>
  59. <script>
  60. import searchBox from '@/components/searchBox/searchBox.vue'
  61. import {apiMyChartList,apiMyChartClassifyList} from '@/api/myChart'
  62. export default {
  63. components:{
  64. searchBox
  65. },
  66. data() {
  67. return {
  68. showFilter:false,
  69. filterOpts:[],
  70. classify_id:'',
  71. list:[],
  72. page:1,
  73. pageSize:20,
  74. finished:false,
  75. }
  76. },
  77. onLoad(){
  78. this.getList()
  79. },
  80. onShow(){
  81. this.getClassifyList()
  82. },
  83. onPullDownRefresh() {
  84. this.page=1
  85. this.finished=false
  86. this.classify_id=''
  87. this.list=[]
  88. this.getList()
  89. this.getClassifyList()
  90. setTimeout(() => {
  91. uni.stopPullDownRefresh()
  92. }, 1500);
  93. },
  94. onReachBottom() {
  95. if(this.finished) return
  96. this.page++
  97. this.getList()
  98. },
  99. methods: {
  100. async getList(){
  101. const res=await apiMyChartList({
  102. classify_id:this.classify_id,
  103. curr_page:this.page,
  104. page_size:this.pageSize
  105. })
  106. if(res.code===200){
  107. const arr=res.data.list||[]
  108. this.list=[...this.list,...arr]
  109. this.finished=res.data.paging.is_end
  110. }
  111. },
  112. // 获取分类数据
  113. async getClassifyList(){
  114. const res=await apiMyChartClassifyList()
  115. if(res.code===200){
  116. this.filterOpts=res.data||[]
  117. }
  118. },
  119. //点击筛选
  120. handleFilter(item){
  121. if(item.my_chart_classify_id==this.classify_id){
  122. this.classify_id=''
  123. }else{
  124. this.classify_id=item.my_chart_classify_id
  125. }
  126. this.page=1
  127. this.list=[]
  128. this.finished=false
  129. this.getList()
  130. this.showFilter=false
  131. },
  132. goClassifyPage(){
  133. uni.navigateTo({
  134. url: '/pages-myChart/classify',
  135. success: (result) => {},
  136. fail: () => {},
  137. complete: () => {}
  138. });
  139. },
  140. handleGoSearch(){
  141. uni.navigateTo({
  142. url: `/pages-myChart/list?classifyName=搜索`,
  143. });
  144. },
  145. goDetail(item){
  146. uni.navigateTo({
  147. url: `/pages-myChart/detail?chartInfoId=${item.chart_info_id}`,
  148. });
  149. }
  150. },
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .mychart-page{
  155. padding-top: 132rpx;
  156. }
  157. .top-wrap{
  158. position: fixed;
  159. left: 0;
  160. top: 0;
  161. right: 0;
  162. background-color: #fff;
  163. z-index: 99;
  164. padding: 30rpx 34rpx;
  165. border-bottom: 1px solid rgba(0,0,0,0.1);
  166. align-items: center;
  167. .icon-box{
  168. margin-left: 42rpx;
  169. image{
  170. width: 40rpx;
  171. vertical-align: middle;
  172. margin-right: 5rpx;
  173. }
  174. text{
  175. color: #E3B377;
  176. vertical-align: middle;
  177. font-size: 28rpx;
  178. }
  179. }
  180. }
  181. .list-wrap{
  182. justify-content: space-around;
  183. flex-wrap: wrap;
  184. padding: 20rpx 0;
  185. .item{
  186. padding: 20rpx;
  187. margin-bottom: 20rpx;
  188. background: #FFFFFF;
  189. border: 1px solid #EBEBEB;
  190. box-shadow: 0px 0px 12rpx rgba(204, 204, 204, 0.25);
  191. border-radius: 8rpx;
  192. width: 47%;
  193. display: flex;
  194. flex-direction: column;
  195. justify-content: space-between;
  196. align-items: center;
  197. .title{
  198. margin-bottom: 20rpx;
  199. width: 100%;
  200. }
  201. .img{
  202. width: 300rpx;
  203. height: 261rpx;
  204. background-color: #f5f5f5;
  205. }
  206. }
  207. }
  208. .filter-wrap{
  209. padding-top: 27rpx;
  210. .title{
  211. text-align: center;
  212. font-size: 32rpx;
  213. font-weight: 500;
  214. padding-bottom: 40rpx;
  215. }
  216. .filter-list{
  217. height: 40vh;
  218. overflow-y: auto;
  219. padding: 0 34rpx;
  220. .item{
  221. padding: 24rpx;
  222. border-bottom: 1px solid #ededed;
  223. }
  224. .active{
  225. color: #E3B377;
  226. }
  227. }
  228. }
  229. </style>