news.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <!-- 新闻播报 -->
  3. <view :style="[newsStyle]" v-if="newsList.length">
  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="heightFix" class="image"></image>
  8. <view v-if="!dataConfig.buttonConfig.tabVal" class="more"
  9. @click="moreTab(linkConfig)" :style="[moreStyle]">{{ $t(`更多`) }}<text
  10. class="iconfont icon-ic_rightarrow"></text></view>
  11. </view>
  12. <view class="news-bottom">
  13. <view v-for="(item, index) in newsList" :key="index" class="acea-row row-middle item" :style="[itemStyle]" @click="moreTab(item.chiild[1].val)">
  14. <view class="number">{{ index + 1 }}</view>
  15. <view class="text line1">{{ 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="heightFix" v-else></image>
  23. </view>
  24. <view class="news-center" :style="[itemStyle]">
  25. <view v-if="dataConfig.rollConfig.tabVal" @click="moreTab(newsList[0].chiild[1].val)">
  26. <uniNoticeBar scrollable single showGetMore background-color="transparent" :color="dataConfig.newsColor.color[0].item" :speed="50"
  27. :text="newsList[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" @change='changeIndex'>
  30. <swiper-item v-for="(item,index) in newsList" :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]" @click="moreTab(newsList[swiperIndex].chiild[1].val)"></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. newsList: [],
  58. swiperIndex: 0
  59. };
  60. },
  61. computed: {
  62. newsStyle() {
  63. return {
  64. padding: `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  65. marginTop: `${this.dataConfig.mbConfig.val * 2}rpx`,
  66. background: this.dataConfig.bottomBgColor.color[0].item,
  67. };
  68. },
  69. newsWrapperStyle() {
  70. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  71. if (this.dataConfig.fillet.type) {
  72. borderRadius =
  73. `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx`;
  74. }
  75. return {
  76. borderRadius,
  77. background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  78. };
  79. },
  80. moreStyle() {
  81. return {
  82. color: this.dataConfig.bntColor.color[0].item,
  83. };
  84. },
  85. titleStyle() {
  86. return {
  87. color: this.dataConfig.titleColor.color[0].item,
  88. };
  89. },
  90. leftStyle(){
  91. return {
  92. 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)',
  93. color: this.dataConfig.toneConfig.tabVal ? this.dataConfig.titleColor.color[0].item : '#ffffff'
  94. }
  95. },
  96. itemStyle() {
  97. return {
  98. color: this.dataConfig.newsColor.color[0].item,
  99. };
  100. },
  101. linkConfig(){
  102. return this.dataConfig.linkConfig.value ? this.dataConfig.linkConfig.value : '/pages/extension/news_list/index'
  103. }
  104. },
  105. mounted(){
  106. let list = this.dataConfig.listConfig.list;
  107. let newsList = [];
  108. list.forEach(item=>{
  109. if(item.show){
  110. newsList.push(item);
  111. }
  112. })
  113. this.newsList = newsList;
  114. },
  115. methods: {
  116. changeIndex(event){
  117. this.swiperIndex = event.detail.current;
  118. },
  119. moreTab(url) {
  120. this.$util.JumpPath(url);
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .news-scroll {
  127. height: 88rpx;
  128. padding: 0 20rpx;
  129. background: #FFFFFF;
  130. }
  131. .news-left {
  132. margin-right: 16rpx;
  133. .text {
  134. height: 40rpx;
  135. padding: 0 12rpx;
  136. border-radius: 8rpx;
  137. // background: #FCEAE9;
  138. font-weight: 500;
  139. font-size: 26rpx;
  140. line-height: 40rpx;
  141. // color: #E93323;
  142. }
  143. .image {
  144. display: block;
  145. // width: 48rpx;
  146. height: 48rpx;
  147. }
  148. }
  149. .news-scroll .news-center {
  150. flex: 1;
  151. min-width: 0;
  152. height: 36rpx;
  153. font-size: 26rpx;
  154. line-height: 36rpx;
  155. color: #333333;
  156. }
  157. .news-scroll .swiper {
  158. height: 36rpx;
  159. }
  160. .news-scroll .iconfont {
  161. margin-left: 16rpx;
  162. font-size: 24rpx;
  163. }
  164. .news {
  165. padding: 32rpx 24rpx;
  166. background: #FFFFFF;
  167. }
  168. .news-top {
  169. font-weight: 500;
  170. font-size: 32rpx;
  171. line-height: 36rpx;
  172. color: #333333;
  173. .image {
  174. display: block;
  175. // width: 140rpx;
  176. height: 36rpx;
  177. }
  178. .more {
  179. font-weight: 400;
  180. font-size: 24rpx;
  181. color: #999999;
  182. }
  183. .iconfont {
  184. font-size: 24rpx;
  185. }
  186. }
  187. .news-bottom {
  188. margin-top: 32rpx;
  189. .item {
  190. font-size: 28rpx;
  191. line-height: 40rpx;
  192. color: #282828;
  193. +.item {
  194. margin-top: 24rpx;
  195. }
  196. &:nth-child(1) {
  197. .number {
  198. color: #E93323;
  199. }
  200. }
  201. &:nth-child(2) {
  202. .number {
  203. color: #FF7300;
  204. }
  205. }
  206. &:nth-child(3) {
  207. .number {
  208. color: #FFC300;
  209. }
  210. }
  211. }
  212. .number {
  213. width: 30rpx;
  214. font-family: SemiBold;
  215. font-size: 30rpx;
  216. color: #999999;
  217. }
  218. .text {
  219. flex: 1;
  220. overflow: hidden;
  221. white-space: nowrap;
  222. text-overflow: ellipsis;
  223. }
  224. }
  225. </style>