roll-message.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="noticeBar">
  3. <image class="notice-icon" :src="noticeIcon" mode="aspectFit"></image>
  4. <template v-if="!skeletonLoading">
  5. <swiper class="notice-list" circular="true" vertical="true" autoplay interval="3000" duration="1000">
  6. <swiper-item class="notice-item-box" v-for="item in noticeEven.length" :key="item.id"
  7. @click="handleInfo(item.id)">
  8. <view class="notice-item">
  9. <text class="zw-one-row" v-if="noticeEven && noticeEven[item - 1]"
  10. @click.stop="openNewsDetail(noticeEven[item - 1])">
  11. {{ noticeEven[item - 1].title }}
  12. </text>
  13. <text class="zw-one-row" v-if="noticeOdd && noticeOdd[item - 1]"
  14. @click.stop="openNewsDetail(noticeOdd[item - 1])">
  15. {{ noticeOdd[item - 1].title }}
  16. </text>
  17. </view>
  18. <text class="theme-look iconfont_yige">&#xe65f;</text>
  19. </swiper-item>
  20. </swiper>
  21. </template>
  22. <template v-else>
  23. <view class="notice-item notice-skeleton skeleton-box">
  24. <text class="skeleton-fillet"></text>
  25. </view>
  26. </template>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. getYiChangNews,
  32. openYiChangNews
  33. } from "../../government/conmon.js"
  34. export default {
  35. data() {
  36. return {
  37. skeletonLoading: true,
  38. noticeIcon: require('./roll-message.png'),
  39. noticeList: [],
  40. noticeEven: [],
  41. noticeOdd: [],
  42. noticeNum: 0
  43. }
  44. },
  45. created() {
  46. // this.init()
  47. },
  48. methods: {
  49. init() {
  50. getYiChangNews(4).then(res => {
  51. setTimeout(() => {
  52. const list = res || []
  53. this.noticeEven = [];
  54. this.noticeOdd = [];
  55. list.forEach((el, index) => {
  56. if (index % 2 === 0) {
  57. this.noticeEven.push(el)
  58. } else {
  59. this.noticeOdd.push(el)
  60. }
  61. })
  62. this.skeletonLoading = false
  63. }, 200)
  64. })
  65. },
  66. openNewsDetail(row) {
  67. openYiChangNews(row)
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang='scss' scoped>
  73. // 公告栏样式
  74. .noticeBar {
  75. width: 100%;
  76. height: 122rpx;
  77. background-color: #fff;
  78. display: flex;
  79. flex-direction: row;
  80. align-items: center;
  81. padding: 0 30rpx;
  82. box-shadow: 0 2rpx 12rpx 0 rgba(0, 0, 0, 0.1);
  83. .notice-icon {
  84. width: 67rpx;
  85. height: 67rpx;
  86. }
  87. .notice-list {
  88. width: calc(100% - 50rpx);
  89. height: 74rpx;
  90. padding-left: 20rpx;
  91. .notice-item-box {
  92. width: 100%;
  93. height: 100%;
  94. display: flex;
  95. justify-content: space-between;
  96. align-items: center;
  97. .theme-look {
  98. text-align: right;
  99. width: 50rpx;
  100. height: 100%;
  101. font-size: 35rpx;
  102. line-height: 74rpx;
  103. }
  104. }
  105. }
  106. }
  107. .notice-item {
  108. width: calc(100% - 74rpx);
  109. display: flex;
  110. flex-direction: column;
  111. /* justify-content: space-between;
  112. align-items: center; */
  113. text {
  114. display: inline-block;
  115. width: 100%;
  116. height: 37rpx;
  117. font-size: 26rpx;
  118. font-weight: 300;
  119. text-align: left;
  120. color: #333333;
  121. line-height: 37rpx;
  122. }
  123. }
  124. .notice-skeleton {
  125. flex: 1;
  126. padding-left: 20rpx;
  127. text {
  128. height: 74rpx;
  129. }
  130. }
  131. </style>