ScrollNotice copy.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div class="notice">
  3. <div class="title"><u-icon name="volume-up" size="46"></u-icon>恭喜</div>
  4. <!-- <scrollList :list="noticeList" :min="minScrollNum" :height="minScrollNum * 56" :time="4000">
  5. <template #default="{rows}">
  6. <div class="list">
  7. <div class="item" v-for="(item,index) in noticeList" :key="index">
  8. 【{{item.time}}】{{item.nickname}}获得{{item.xuefen}}学分
  9. </div>
  10. </div>
  11. </template>
  12. </scrollList> -->
  13. <view class="view_box">
  14. <view :style="transitionStyle">
  15. <template v-for="item in noticeList">
  16. <view class="item">
  17. <text class="item_time">{{item.time}}</text> {{item.nickname}}获得{{item.xuefen}}学分
  18. </view>
  19. </template>
  20. </view>
  21. </view>
  22. <image @click.stop="handleScreen" src="@/static/images/index/screen.png" mode="" class="amplify">
  23. </image>
  24. </div>
  25. </template>
  26. <script>
  27. import scrollList from '../components/zh-scrollList/scrollList/scrollList.vue'
  28. export default {
  29. components: {
  30. scrollList,
  31. },
  32. name: "ScrollNotice",
  33. props: {
  34. noticeList: {
  35. type: Array,
  36. default: []
  37. }
  38. },
  39. data() {
  40. return {
  41. minScrollNum: 10,
  42. };
  43. },
  44. created() {
  45. init()
  46. },
  47. onHide() {
  48. transitionStyle.value = ''
  49. clearInterval(timr.value)
  50. timr.value = null
  51. },
  52. methods: {
  53. init() {
  54. // 主要通过 transition 的过度时间 控制 滚动速度
  55. setTimeout(() => {
  56. transitionStyle.value = 'transition: all 8s linear 0s;transform: translateY(-50%);'
  57. if (timr.value) return
  58. timr.value = setInterval(() => {
  59. transitionStyle.value = ''
  60. setTimeout(() => {
  61. transitionStyle.value =
  62. 'transition: all 8s linear 0s;transform: translateY(-50%);'
  63. }, 20)
  64. }, 8000)
  65. }, 20)
  66. },
  67. handleScreen() {
  68. console.log(this.minScrollNum)
  69. if (this.minScrollNum == 3) {
  70. this.minScrollNum = 10
  71. } else if (this.minScrollNum == 10) {
  72. this.minScrollNum = 3
  73. }
  74. },
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .notice {
  80. border-radius: 5px;
  81. border: 1px solid #CAC1C1;
  82. overflow: hidden;
  83. margin-top: 10px;
  84. position: relative;
  85. .amplify {
  86. position: absolute;
  87. bottom: 10px;
  88. right: 10px;
  89. width: 16px;
  90. height: 16px;
  91. }
  92. .title {
  93. border-radius: 5px 5px 0px 0px;
  94. padding: 6px 0;
  95. font-size: 18px;
  96. display: flex;
  97. justify-content: center;
  98. align-items: center;
  99. background: linear-gradient(90deg, #FB7B58 0%, #F5222D 97%);
  100. color: #fff;
  101. text-align: center;
  102. .u-icon {
  103. margin-right: 4px;
  104. }
  105. }
  106. .list {
  107. padding: 4px 16px;
  108. .item {
  109. height: 26px;
  110. overflow: hidden;
  111. white-space: nowrap;
  112. text-overflow: ellipsis;
  113. line-height: 26px;
  114. .item_time {
  115. display: inline-block;
  116. margin-right: 4px;
  117. }
  118. }
  119. }
  120. }
  121. </style>