vip.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="w-1200px">
  3. <ui-shadow-box class="bg-white mt-30px flex items-center nut-row-flex-wrap " style="flex-wrap: wrap">
  4. <div
  5. class="w-100px h-full bg-primary bg-opacity-26 rounded-3px flex justify-center items-center h-50px"
  6. >
  7. 年份
  8. </div>
  9. <div class="w-1100px flex pt-12px " style="flex-wrap: wrap">
  10. <div :class="`year-tag ${currentYear === item ? 'selected':''}`" @click="!currentYear && currentYear !== item ? currentYear=item : currentYear = ''" class="mb-12px" v-for="(item,index) in years" :key="index">{{item}}</div>
  11. <div v-if="years.length > 12" :class="`year-tag ${index === 0}`" class="!bg-white mb-12px " :key="index">
  12. <img @click="hideYear=!hideYear" src="/imgs/year-arrow-down.png" class="w-16px h-auto ml-20px cursor-pointer transform" :class="{'rotate-180':!hideYear}" style="object-fit: contain" />
  13. </div>
  14. </div>
  15. </ui-shadow-box>
  16. <div class="w-full flex flex-wrap justify-between">
  17. <ui-shadow-box
  18. v-for="item in showVipMagazines"
  19. :key="item"
  20. class="px-50px pt-30px mt-40px w-390px h-221px"
  21. >
  22. <ui-vip-article :item="item" class="transform scale-110"></ui-vip-article>
  23. </ui-shadow-box>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. data(){
  30. return {
  31. vipMagazines:[],
  32. hideYear:true,
  33. currentYear:''
  34. }
  35. },
  36. computed:{
  37. years(){
  38. let years = [];
  39. this.vipMagazines.forEach((e)=>{
  40. if(years.indexOf(parseInt(e.dateStr.substr(0,4))) === -1) years.push(parseInt(e.dateStr.substr(0,4)));
  41. })
  42. return years.length > 12 && this.hideYear ? years.splice(0,12) : years;
  43. },
  44. showVipMagazines(){
  45. return this.vipMagazines.filter(e=> (parseInt(e.dateStr.substr(0,4)) === this.currentYear || !this.currentYear));
  46. }
  47. },
  48. async created() {
  49. let resp = await this.$http.post(this.$api.cms.listVipMagazines);
  50. if(resp.data.status === 200){
  51. this.vipMagazines = resp.data.data.vipMagazines;
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. .year-tag {
  58. @apply w-60px h-24px bg-[#F7F7F7] flex items-center justify-center rounded-full ml-20px cursor-pointer;
  59. }
  60. .selected {
  61. @apply bg-primary ;
  62. color: #ffffff;
  63. }
  64. </style>