BrithChart.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div>
  3. <div class="text-container" :style="{height:height,width:width}">
  4. <ul class="allBirth">
  5. <li v-for="(item,index) in politicalBirthdayList" class="info">
  6. <svg-icon icon-class="dangao" class="dangao"></svg-icon>
  7. <span style="padding-left: 20px">{{item.partyEntryTime}}</span>
  8. <span style="padding-left: 20px">{{item.nickName}}</span>
  9. </li>
  10. </ul>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. import { listPoliticalBirthday } from "@/api/branch/member";
  16. const totalDuration = 2000;
  17. export default {
  18. name: "BrithChart",
  19. props: {
  20. width: {
  21. type: String,
  22. default: '100%'
  23. },
  24. height: {
  25. type: String,
  26. default: '210px'
  27. }
  28. },
  29. data() {
  30. return {
  31. // 查询参数
  32. queryParams: {},
  33. // 政治生日列表
  34. politicalBirthdayList: null,
  35. }
  36. },
  37. created() {
  38. this.listPoliticalBirthday();
  39. },
  40. methods: {
  41. /** 查询政治生日列表 */
  42. listPoliticalBirthday() {
  43. listPoliticalBirthday(this.queryParams).then(response => {
  44. this.politicalBirthdayList = response.data;
  45. //判断是否需要滚动
  46. if (this.politicalBirthdayList.length > 4) {
  47. //设置文字滚动一轮时间
  48. let elem = document.querySelector('.allBirth');
  49. let state = elem.style['animation'];
  50. let time = this.politicalBirthdayList.length * 2
  51. elem.style['animation'] = 'myMove ' + time + 's linear infinite';
  52. let state1 = elem.style['animation-fill-mode'];
  53. elem.style['animation-fill-mode'] = 'forwards';
  54. //设置文字无缝滚动高度
  55. let param = this.politicalBirthdayList.length * 50
  56. let myFirstkeyframes = "@keyframes myMove{0% {transform: translateY(200px);}100% {transform: translateY(-" + param +"px);}}";
  57. let style = document.createElement("style");
  58. style.setAttribute("type", "text/css");
  59. document.head.appendChild(style);
  60. const sheet = style.sheet;
  61. sheet.insertRule(myFirstkeyframes, 0);
  62. }
  63. });
  64. },
  65. }
  66. }
  67. </script>
  68. <style>
  69. .text-container {
  70. line-height: 30px;
  71. overflow: hidden;
  72. }
  73. .dangao {
  74. width: 40px !important;
  75. height: 40px !important;
  76. }
  77. .info {
  78. font-weight:bold;
  79. list-style: none;
  80. display: flex;
  81. margin: 10px 0 0 0;
  82. align-items: center; /* 垂直居中 */
  83. border-radius:5px 5px 5px 5px ;
  84. /*border: 2px solid rgba(41, 107, 155, 0.71);*/
  85. background-color: transparent;
  86. }
  87. .allBirth {
  88. margin: -10px 0 0 0;
  89. padding: 0 20px 0 20px;
  90. /*animation: myMove 10s linear infinite;
  91. animation-fill-mode: forwards;*/
  92. }
  93. /*文字无缝滚动*/
  94. /*@keyframes myMove {
  95. 0% {
  96. transform: translateY(200px);
  97. }
  98. 100% {
  99. transform: translateY(-300px);
  100. }
  101. }*/
  102. /*文字停顿滚动*/
  103. @keyframes myMove2 {
  104. 0% {
  105. transform: translateY(0);
  106. }
  107. 10% {
  108. transform: translateY(-30px);
  109. }
  110. 20% {
  111. transform: translateY(-30px);
  112. }
  113. 30% {
  114. transform: translateY(-60px);
  115. }
  116. 40% {
  117. transform: translateY(-60px);
  118. }
  119. 50% {
  120. transform: translateY(-90px);
  121. }
  122. 60% {
  123. transform: translateY(-90px);
  124. }
  125. 70% {
  126. transform: translateY(-120px);
  127. }
  128. 80% {
  129. transform: translateY(-120px);
  130. }
  131. 90% {
  132. transform: translateY(-150px);
  133. }
  134. 100% {
  135. transform: translateY(-150px);
  136. }
  137. }
  138. .info span {
  139. padding-top: 5px;
  140. }
  141. </style>