news.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <!-- 新闻播报 -->
  3. <view :style="[newsStyle]">
  4. <view class="news" v-if="dataConfig.styleConfig.tabVal" :style="[newsWrapperStyle]">
  5. <view class="acea-row row-between-wrapper news-top">
  6. <view v-if="dataConfig.titleConfig.tabVal" :style="[titleStyle]">{{ dataConfig.titleTxtConfig.value }}</view>
  7. <image v-else :src="dataConfig.imgConfig.url" mode="aspectFit" class="image"></image>
  8. <view v-if="!dataConfig.buttonConfig.tabVal" class="more"
  9. @click="moreTab(linkConfig)" :style="[moreStyle]">更多<text
  10. class="iconfont icon-ic_rightarrow"></text></view>
  11. </view>
  12. <view class="news-bottom">
  13. <view v-for="(item, index) in dataConfig.listConfig.list" :key="index" class="acea-row row-middle item" :style="[itemStyle]">
  14. <view class="number">{{ index + 1 }}</view>
  15. <view class="text">{{ item.chiild[0].val }}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="news-scroll acea-row row-middle" :style="[newsWrapperStyle]" v-else>
  20. <view class="news-left">
  21. <view class="text" v-if="dataConfig.titleConfig.tabVal" :style="[leftStyle]">{{ dataConfig.titleTxtConfig.value }}</view>
  22. <image class="image" :src="dataConfig.imgConfig.url" mode="aspectFit" v-else></image>
  23. </view>
  24. <view class="news-center" :style="[itemStyle]">
  25. <view v-if="dataConfig.rollConfig.tabVal" @click="moreTab(dataConfig.listConfig.list[0].chiild[0].val)">
  26. <uniNoticeBar scrollable single showGetMore background-color="transparent" :color="dataConfig.newsColor.color[0].item" :speed="50"
  27. :text="dataConfig.listConfig.list[0].chiild[0].val"></uniNoticeBar>
  28. </view>
  29. <swiper v-else class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" interval="2500" :duration="duration" vertical="true" circular="true">
  30. <swiper-item v-for="(item,index) in dataConfig.listConfig.list" :key="index">
  31. <view @click="moreTab(item.chiild[1].val)">{{ item.chiild[0].val }}</view>
  32. </swiper-item>
  33. </swiper>
  34. </view>
  35. <view v-if="!dataConfig.buttonConfig.tabVal" class="iconfont icon-ic_rightarrow" :style="[moreStyle]"></view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import uniNoticeBar from '@/components/uniNoticeBar/uni-notice-bar.vue';
  41. export default {
  42. components: {
  43. uniNoticeBar
  44. },
  45. name: 'news',
  46. props: {
  47. dataConfig: {
  48. type: Object,
  49. default: () => {}
  50. },
  51. },
  52. data() {
  53. return {
  54. indicatorDots: false,
  55. autoplay: true,
  56. duration: 500,
  57. };
  58. },
  59. computed: {
  60. newsStyle() {
  61. return {
  62. padding: `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  63. marginTop: `${this.dataConfig.mbConfig.val * 2}rpx`,
  64. background: this.dataConfig.bottomBgColor.color[0].item,
  65. };
  66. },
  67. newsWrapperStyle() {
  68. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  69. if (this.dataConfig.fillet.type) {
  70. borderRadius =
  71. `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx`;
  72. }
  73. return {
  74. borderRadius,
  75. background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  76. };
  77. },
  78. moreStyle() {
  79. return {
  80. color: this.dataConfig.bntColor.color[0].item,
  81. };
  82. },
  83. titleStyle() {
  84. return {
  85. color: this.dataConfig.titleColor.color[0].item,
  86. };
  87. },
  88. leftStyle(){
  89. return {
  90. background: this.dataConfig.toneConfig.tabVal ? `linear-gradient(90deg, ${this.dataConfig.titleBgColor.color[0].item} 0%, ${this.dataConfig.titleBgColor.color[1].item} 100%)` : 'var(--view-theme)',
  91. color: this.dataConfig.toneConfig.tabVal ? this.dataConfig.titleColor.color[0].item : '#ffffff'
  92. }
  93. },
  94. itemStyle() {
  95. return {
  96. color: this.dataConfig.newsColor.color[0].item,
  97. };
  98. },
  99. linkConfig(){
  100. return this.dataConfig.linkConfig.value ? this.dataConfig.linkConfig.value : '/pages/extension/news_list/index'
  101. }
  102. },
  103. methods: {
  104. moreTab(url) {
  105. this.$util.JumpPath(url);
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .news-scroll {
  112. height: 88rpx;
  113. padding: 0 20rpx;
  114. background: #FFFFFF;
  115. }
  116. .news-left {
  117. margin-right: 16rpx;
  118. .text {
  119. height: 40rpx;
  120. padding: 0 12rpx;
  121. border-radius: 8rpx;
  122. // background: #FCEAE9;
  123. font-weight: 500;
  124. font-size: 26rpx;
  125. line-height: 40rpx;
  126. // color: #E93323;
  127. }
  128. .image {
  129. display: block;
  130. width: 48rpx;
  131. height: 48rpx;
  132. }
  133. }
  134. .news-scroll .news-center {
  135. flex: 1;
  136. min-width: 0;
  137. height: 36rpx;
  138. font-size: 26rpx;
  139. line-height: 36rpx;
  140. color: #333333;
  141. }
  142. .news-scroll .swiper {
  143. height: 36rpx;
  144. }
  145. .news-scroll .iconfont {
  146. margin-left: 16rpx;
  147. font-size: 24rpx;
  148. }
  149. .news {
  150. padding: 32rpx 24rpx;
  151. background: #FFFFFF;
  152. }
  153. .news-top {
  154. font-weight: 500;
  155. font-size: 32rpx;
  156. line-height: 36rpx;
  157. color: #333333;
  158. .image {
  159. display: block;
  160. width: 140rpx;
  161. height: 36rpx;
  162. }
  163. .more {
  164. font-weight: 400;
  165. font-size: 24rpx;
  166. color: #999999;
  167. }
  168. .iconfont {
  169. font-size: 24rpx;
  170. }
  171. }
  172. .news-bottom {
  173. margin-top: 32rpx;
  174. .item {
  175. font-size: 28rpx;
  176. line-height: 40rpx;
  177. color: #282828;
  178. +.item {
  179. margin-top: 24rpx;
  180. }
  181. &:nth-child(1) {
  182. .number {
  183. color: #E93323;
  184. }
  185. }
  186. &:nth-child(2) {
  187. .number {
  188. color: #FF7300;
  189. }
  190. }
  191. &:nth-child(3) {
  192. .number {
  193. color: #FFC300;
  194. }
  195. }
  196. }
  197. .number {
  198. width: 30rpx;
  199. font-family: SemiBold;
  200. font-size: 30rpx;
  201. color: #999999;
  202. }
  203. .text {
  204. flex: 1;
  205. overflow: hidden;
  206. white-space: nowrap;
  207. text-overflow: ellipsis;
  208. }
  209. }
  210. </style>