index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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.page=1
  82. this.list=[]
  83. this.finished=false
  84. this.getList()
  85. this.getClassifyList()
  86. },
  87. onPullDownRefresh() {
  88. this.page=1
  89. this.finished=false
  90. this.classify_id=''
  91. this.list=[]
  92. this.getList()
  93. this.getClassifyList()
  94. setTimeout(() => {
  95. uni.stopPullDownRefresh()
  96. }, 1500);
  97. },
  98. onReachBottom() {
  99. if(this.finished) return
  100. this.page++
  101. this.getList()
  102. },
  103. methods: {
  104. async getList(){
  105. const res=await apiMyChartList({
  106. classify_id:this.classify_id,
  107. curr_page:this.page,
  108. page_size:this.pageSize
  109. })
  110. if(res.code===200){
  111. const arr=res.data.list||[]
  112. this.list=[...this.list,...arr]
  113. this.finished=res.data.paging.is_end
  114. }
  115. },
  116. // 获取分类数据
  117. async getClassifyList(){
  118. const res=await apiMyChartClassifyList()
  119. if(res.code===200){
  120. this.filterOpts=res.data||[]
  121. }
  122. },
  123. //点击筛选
  124. handleFilter(item){
  125. if(item.my_chart_classify_id==this.classify_id){
  126. this.classify_id=''
  127. }else{
  128. this.classify_id=item.my_chart_classify_id
  129. }
  130. this.page=1
  131. this.list=[]
  132. this.finished=false
  133. this.getList()
  134. this.showFilter=false
  135. },
  136. goClassifyPage(){
  137. uni.navigateTo({
  138. url: '/pages-myChart/classify',
  139. success: (result) => {},
  140. fail: () => {},
  141. complete: () => {}
  142. });
  143. },
  144. handleGoSearch(){
  145. uni.navigateTo({
  146. url: `/pages-myChart/list?classifyName=搜索`,
  147. });
  148. },
  149. goDetail(item){
  150. uni.navigateTo({
  151. url: `/pages-myChart/detail?chartInfoId=${item.chart_info_id}&chartCode=${item.unique_code}`,
  152. });
  153. }
  154. },
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .mychart-page{
  159. padding-top: 132rpx;
  160. }
  161. .top-wrap{
  162. position: fixed;
  163. left: 0;
  164. top: 0;
  165. right: 0;
  166. background-color: #fff;
  167. z-index: 99;
  168. padding: 30rpx 34rpx;
  169. border-bottom: 1px solid rgba(0,0,0,0.1);
  170. align-items: center;
  171. .icon-box{
  172. margin-left: 42rpx;
  173. image{
  174. width: 40rpx;
  175. vertical-align: middle;
  176. margin-right: 5rpx;
  177. }
  178. text{
  179. color: #E3B377;
  180. vertical-align: middle;
  181. font-size: 28rpx;
  182. }
  183. }
  184. }
  185. .list-wrap{
  186. justify-content: space-around;
  187. flex-wrap: wrap;
  188. padding: 20rpx 0;
  189. .item{
  190. padding: 20rpx;
  191. margin-bottom: 20rpx;
  192. background: #FFFFFF;
  193. border: 1px solid #EBEBEB;
  194. box-shadow: 0px 0px 12rpx rgba(204, 204, 204, 0.25);
  195. border-radius: 8rpx;
  196. width: 47%;
  197. display: flex;
  198. flex-direction: column;
  199. justify-content: space-between;
  200. align-items: center;
  201. .title{
  202. margin-bottom: 20rpx;
  203. width: 100%;
  204. }
  205. .img{
  206. width: 300rpx;
  207. height: 261rpx;
  208. background-color: #f5f5f5;
  209. }
  210. }
  211. }
  212. .filter-wrap{
  213. padding-top: 27rpx;
  214. .title{
  215. text-align: center;
  216. font-size: 32rpx;
  217. font-weight: 500;
  218. padding-bottom: 40rpx;
  219. }
  220. .filter-list{
  221. height: 40vh;
  222. overflow-y: auto;
  223. padding: 0 34rpx;
  224. .item{
  225. padding: 24rpx;
  226. border-bottom: 1px solid #ededed;
  227. }
  228. .active{
  229. color: #E3B377;
  230. }
  231. }
  232. }
  233. </style>