news.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <!-- 新闻播报 -->
  3. <common-wrapper :config="configData" v-if="newsList.length">
  4. <view
  5. class="news"
  6. v-if="dataConfig.styleConfig.tabVal"
  7. :style="[newsWrapperStyle]"
  8. >
  9. <view class="acea-row row-between-wrapper news-top">
  10. <view v-if="dataConfig.titleConfig.tabVal" :style="[titleStyle]">{{
  11. dataConfig.titleTxtConfig.value
  12. }}</view>
  13. <image
  14. v-else
  15. :src="dataConfig.imgConfig.url"
  16. mode="heightFix"
  17. class="image"
  18. ></image>
  19. <view
  20. v-if="!dataConfig.buttonConfig.tabVal"
  21. class="more"
  22. @click="moreTab(linkConfig)"
  23. :style="[moreStyle]"
  24. >{{ $t(`更多`) }}<text class="iconfont icon-ic_rightarrow"></text
  25. ></view>
  26. </view>
  27. <view class="news-bottom">
  28. <view
  29. v-for="(item, index) in newsList"
  30. :key="index"
  31. class="acea-row row-middle item"
  32. :style="[itemStyle]"
  33. @click="moreTab(item.chiild[1].val)"
  34. >
  35. <view class="number">{{ index + 1 }}</view>
  36. <view class="text line1">{{ item.chiild[0].val }}</view>
  37. </view>
  38. </view>
  39. </view>
  40. <view
  41. class="news-scroll acea-row row-middle"
  42. :style="[newsWrapperStyle]"
  43. v-else
  44. >
  45. <view class="news-left">
  46. <view
  47. class="text"
  48. v-if="dataConfig.titleConfig.tabVal"
  49. :style="[leftStyle]"
  50. >{{ dataConfig.titleTxtConfig.value }}</view
  51. >
  52. <image
  53. class="image"
  54. :src="dataConfig.imgConfig.url"
  55. mode="heightFix"
  56. v-else
  57. ></image>
  58. </view>
  59. <view class="news-center" :style="[itemStyle]">
  60. <view
  61. v-if="dataConfig.rollConfig.tabVal"
  62. @click="moreTab(newsList[0].chiild[1].val)"
  63. >
  64. <uniNoticeBar
  65. scrollable
  66. single
  67. showGetMore
  68. background-color="transparent"
  69. :color="dataConfig.newsColor.color[0].item"
  70. :speed="50"
  71. :text="newsList[0].chiild[0].val"
  72. ></uniNoticeBar>
  73. </view>
  74. <swiper
  75. v-else
  76. class="swiper"
  77. :indicator-dots="indicatorDots"
  78. :autoplay="autoplay"
  79. interval="2500"
  80. :duration="duration"
  81. vertical="true"
  82. circular="true"
  83. @change="changeIndex"
  84. >
  85. <swiper-item v-for="(item, index) in newsList" :key="index">
  86. <view @click="moreTab(item.chiild[1].val)">{{
  87. item.chiild[0].val
  88. }}</view>
  89. </swiper-item>
  90. </swiper>
  91. </view>
  92. <view
  93. v-if="!dataConfig.buttonConfig.tabVal"
  94. class="iconfont icon-ic_rightarrow"
  95. :style="[moreStyle]"
  96. @click="moreTab(newsList[swiperIndex].chiild[1].val)"
  97. ></view>
  98. </view>
  99. </common-wrapper>
  100. </template>
  101. <script>
  102. import commonWrapper from "./commonWrapper.vue";
  103. import uniNoticeBar from "@/components/uniNoticeBar/uni-notice-bar.vue";
  104. export default {
  105. components: {
  106. uniNoticeBar,
  107. commonWrapper,
  108. },
  109. name: "news",
  110. props: {
  111. dataConfig: {
  112. type: Object,
  113. default: () => {},
  114. },
  115. },
  116. data() {
  117. return {
  118. indicatorDots: false,
  119. autoplay: true,
  120. duration: 500,
  121. newsList: [],
  122. swiperIndex: 0,
  123. };
  124. },
  125. computed: {
  126. configData() {
  127. return {
  128. ...this.dataConfig,
  129. };
  130. },
  131. newsWrapperStyle() {
  132. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  133. if (this.dataConfig.fillet.type) {
  134. borderRadius = `${this.dataConfig.fillet.valList[0].val * 2}rpx ${
  135. this.dataConfig.fillet.valList[1].val * 2
  136. }rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx ${
  137. this.dataConfig.fillet.valList[2].val * 2
  138. }rpx`;
  139. }
  140. return {
  141. borderRadius,
  142. background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  143. };
  144. },
  145. moreStyle() {
  146. return {
  147. color: this.dataConfig.bntColor.color[0].item,
  148. };
  149. },
  150. titleStyle() {
  151. return {
  152. color: this.dataConfig.titleColor.color[0].item,
  153. };
  154. },
  155. leftStyle() {
  156. return {
  157. background: this.dataConfig.toneConfig.tabVal
  158. ? `linear-gradient(90deg, ${this.dataConfig.titleBgColor.color[0].item} 0%, ${this.dataConfig.titleBgColor.color[1].item} 100%)`
  159. : "var(--view-theme)",
  160. color: this.dataConfig.toneConfig.tabVal
  161. ? this.dataConfig.titleColor.color[0].item
  162. : "#ffffff",
  163. };
  164. },
  165. itemStyle() {
  166. return {
  167. color: this.dataConfig.newsColor.color[0].item,
  168. };
  169. },
  170. linkConfig() {
  171. return this.dataConfig.linkConfig.value
  172. ? this.dataConfig.linkConfig.value
  173. : "/pages/extension/news_list/index";
  174. },
  175. },
  176. mounted() {
  177. let list = this.dataConfig.listConfig.list;
  178. let newsList = [];
  179. list.forEach((item) => {
  180. if (item.show) {
  181. newsList.push(item);
  182. }
  183. });
  184. this.newsList = newsList;
  185. },
  186. methods: {
  187. changeIndex(event) {
  188. this.swiperIndex = event.detail.current;
  189. },
  190. moreTab(url) {
  191. this.$util.JumpPath(url);
  192. },
  193. },
  194. };
  195. </script>
  196. <style lang="scss">
  197. .news-scroll {
  198. height: 88rpx;
  199. padding: 0 20rpx;
  200. background: #ffffff;
  201. }
  202. .news-left {
  203. margin-right: 16rpx;
  204. .text {
  205. height: 40rpx;
  206. padding: 0 12rpx;
  207. border-radius: 8rpx;
  208. // background: #FCEAE9;
  209. font-weight: 500;
  210. font-size: 26rpx;
  211. line-height: 40rpx;
  212. // color: #E93323;
  213. }
  214. .image {
  215. display: block;
  216. // width: 48rpx;
  217. height: 48rpx;
  218. }
  219. }
  220. .news-scroll .news-center {
  221. flex: 1;
  222. min-width: 0;
  223. height: 36rpx;
  224. font-size: 26rpx;
  225. line-height: 36rpx;
  226. color: #333333;
  227. }
  228. .news-scroll .swiper {
  229. height: 36rpx;
  230. }
  231. .news-scroll .iconfont {
  232. margin-left: 16rpx;
  233. font-size: 24rpx;
  234. }
  235. .news {
  236. padding: 32rpx 24rpx;
  237. background: #ffffff;
  238. }
  239. .news-top {
  240. font-weight: 500;
  241. font-size: 32rpx;
  242. line-height: 36rpx;
  243. color: #333333;
  244. .image {
  245. display: block;
  246. // width: 140rpx;
  247. height: 36rpx;
  248. }
  249. .more {
  250. font-weight: 400;
  251. font-size: 24rpx;
  252. color: #999999;
  253. }
  254. .iconfont {
  255. font-size: 24rpx;
  256. }
  257. }
  258. .news-bottom {
  259. margin-top: 32rpx;
  260. .item {
  261. font-size: 28rpx;
  262. line-height: 40rpx;
  263. color: #282828;
  264. + .item {
  265. margin-top: 24rpx;
  266. }
  267. &:nth-child(1) {
  268. .number {
  269. color: #e93323;
  270. }
  271. }
  272. &:nth-child(2) {
  273. .number {
  274. color: #ff7300;
  275. }
  276. }
  277. &:nth-child(3) {
  278. .number {
  279. color: #ffc300;
  280. }
  281. }
  282. }
  283. .number {
  284. width: 30rpx;
  285. font-family: SemiBold;
  286. font-size: 30rpx;
  287. color: #999999;
  288. }
  289. .text {
  290. flex: 1;
  291. overflow: hidden;
  292. white-space: nowrap;
  293. text-overflow: ellipsis;
  294. }
  295. }
  296. </style>