news.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view v-if="itemNew.length" :style="'margin-top:'+mbConfig+'rpx;'">
  3. <view class='news acea-row row-between-wrapper':style="'background:'+bgColor[0].item+';margin: 0 '+prConfig+'rpx;border-radius:'+bgStyle+'rpx'">
  4. <view class='pictrue'>
  5. <image :src='logoConfig'></image>
  6. </view>
  7. <view class='swiperTxt'>
  8. <swiper :indicator-dots="indicatorDots" :autoplay="autoplay" interval="2500" :duration="duration" vertical="true"
  9. circular="true">
  10. <block v-for="(item,index) in itemNew" :key='index'>
  11. <swiper-item catchtouchmove='catchTouchMove'>
  12. <view @click="goDetail(item.chiild[1].val)" class='acea-row row-between-wrapper'>
  13. <view class='text acea-row row-between-wrapper'>
  14. <view class='newsTitle line1' :style="'text-align:'+ (txtStyle==1?'center':txtStyle==2?'right':'left') +';color:'+txtColor">{{item.chiild[0].val}}</view>
  15. </view>
  16. <view class='iconfont icon-xiangyou'></view>
  17. </view>
  18. </swiper-item>
  19. </block>
  20. </swiper>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import {merPath} from "@/utils/index"
  27. export default {
  28. name: 'news',
  29. props: {
  30. dataConfig: {
  31. type: Object,
  32. default: () => {}
  33. },
  34. merId: {
  35. type: String || Number,
  36. default: ''
  37. }
  38. },
  39. data() {
  40. return {
  41. indicatorDots: false,
  42. autoplay: true,
  43. duration: 500,
  44. itemNew: this.dataConfig.listConfig.list,
  45. logoConfig: this.dataConfig.logoConfig.url,
  46. bgColor: this.dataConfig.bgColor.color,
  47. mbConfig: this.dataConfig.mbConfig.val*2,
  48. prConfig: this.dataConfig.prConfig.val*2,
  49. txtStyle: this.dataConfig.txtStyle.type,
  50. txtColor: this.dataConfig.txtColor.color[0].item,
  51. bgStyle: this.dataConfig.bgStyle.type ? 20 : 0,
  52. };
  53. },
  54. created() {},
  55. mounted() {
  56. console.log(this.dataConfig)
  57. },
  58. methods: {
  59. goDetail(url){
  60. let urls = merPath(url, this.merId)
  61. console.log(urls,'urls');
  62. if(urls.indexOf("http") != -1){
  63. // #ifdef H5
  64. location.href = urls
  65. // #endif
  66. }else{
  67. if(['/pages/goods_cate/goods_cate','/pages/order_addcart/order_addcart','/pages/user/index','/pages/plant_grass/index'].indexOf(urls) == -1){
  68. uni.navigateTo({
  69. url:urls
  70. })
  71. }else{
  72. uni.switchTab({
  73. url:urls
  74. })
  75. }
  76. }
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. .news {
  83. height: 77rpx;
  84. border-top: 1rpx solid #f4f4f4;
  85. padding: 0 20rpx;
  86. box-shadow: 0 10rpx 30rpx #f5f5f5;
  87. }
  88. .news .pictrue {
  89. width: 130rpx;
  90. height: 36rpx;
  91. border-right: 1rpx solid #ddd;
  92. padding-right: 23rpx;
  93. box-sizing: content-box;
  94. }
  95. .news .pictrue image {
  96. width: 100%;
  97. height: 100%;
  98. }
  99. .news .swiperTxt {
  100. width: 510rpx;
  101. height: 100%;
  102. line-height: 77rpx;
  103. overflow: hidden;
  104. }
  105. .news .swiperTxt .text {
  106. width: 480rpx;
  107. }
  108. .news .swiperTxt .text .label {
  109. font-size: 20rpx;
  110. color: #ff4c48;
  111. width: 64rpx;
  112. height: 30rpx;
  113. border-radius: 40rpx;
  114. text-align: center;
  115. line-height: 28rpx;
  116. border: 2rpx solid #ff4947;
  117. }
  118. .news .swiperTxt .text .newsTitle {
  119. width: 397rpx;
  120. font-size: 24rpx;
  121. color: #666;
  122. }
  123. .news .swiperTxt .iconfont {
  124. font-size: 28rpx;
  125. color: #888;
  126. }
  127. .news .swiperTxt swiper {
  128. height: 100%;
  129. }
  130. </style>