news.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class="new" :style="colorStyle">
  3. <view class="news default" v-if="isIframe && !itemNew.length">{{$t(`暂无新闻,请上传新闻`)}}</view>
  4. <view class='news acea-row row-between-wrapper skeleton-rect' v-if="isShow && itemNew.length">
  5. <view class='pictrue'>
  6. <image :src='img'></image>
  7. </view>
  8. <view class='swiperTxt'>
  9. <swiper :indicator-dots="indicatorDots" :autoplay="autoplay" interval="2500" :duration="duration"
  10. vertical="true" circular="true" disable-touch="true">
  11. <block v-for="(item,index) in itemNew" :key='index'>
  12. <swiper-item catchtouchmove='catchTouchMove'>
  13. <view class='acea-row row-between-wrapper' hover-class='none'
  14. @click="gopage(item.chiild[1].val)">
  15. <view class='text acea-row row-between-wrapper'>
  16. <view class='newsTitle line1'>{{item.chiild[0].val}}</view>
  17. </view>
  18. <view class='iconfont icon-xiangyou'></view>
  19. </view>
  20. </swiper-item>
  21. </block>
  22. </swiper>
  23. </view>
  24. </view>
  25. <view class='news acea-row row-between-wrapper' v-if="!isShow && isIframe && itemNew.length">
  26. <view class='pictrue'>
  27. <image :src='img'></image>
  28. </view>
  29. <view class='swiperTxt'>
  30. <swiper :indicator-dots="indicatorDots" :autoplay="autoplay" interval="2500" :duration="duration"
  31. vertical="true" circular="true">
  32. <block v-for="(item,index) in itemNew" :key='index'>
  33. <swiper-item catchtouchmove='catchTouchMove'>
  34. <view class='acea-row row-between-wrapper' hover-class='none'
  35. @click="gopage(item.chiild[1].val)">
  36. <view class='text acea-row row-between-wrapper'>
  37. <view class='newsTitle line1'>{{item.chiild[0].val}}</view>
  38. </view>
  39. <view class='iconfont icon-xiangyou'></view>
  40. </view>
  41. </swiper-item>
  42. </block>
  43. </swiper>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. let app = getApp()
  50. import colors from '@/mixins/color.js';
  51. import {
  52. goPage
  53. } from '@/libs/order.js'
  54. export default {
  55. name: 'news',
  56. props: {
  57. dataConfig: {
  58. type: Object,
  59. default: () => {}
  60. },
  61. },
  62. mixins:[colors],
  63. watch: {
  64. dataConfig: {
  65. immediate: true,
  66. handler(nVal, oVal) {
  67. if (nVal) {
  68. this.img = nVal.imgUrl.url;
  69. this.itemNew = nVal.newList.list;
  70. this.isShow = nVal.isShow.val;
  71. }
  72. }
  73. }
  74. },
  75. data() {
  76. return {
  77. indicatorDots: false,
  78. autoplay: true,
  79. duration: 500,
  80. img: '',
  81. itemNew: [],
  82. name: this.$options.name,
  83. isIframe: false,
  84. isShow: true
  85. };
  86. },
  87. created() {
  88. this.isIframe = app.globalData.isIframe;
  89. },
  90. mounted() {},
  91. methods: {
  92. gopage(url) {
  93. goPage().then(res => {
  94. if (url.indexOf("http") != -1) {
  95. // #ifdef H5
  96. location.href = url
  97. // #endif
  98. } else {
  99. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart',
  100. '/pages/user/index'
  101. ].indexOf(url) ==
  102. -1) {
  103. uni.navigateTo({
  104. url: url
  105. })
  106. } else {
  107. uni.navigateTo({
  108. url: url
  109. })
  110. }
  111. }
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. .new{
  119. background-color: #fff;
  120. padding: 20rpx 0;
  121. }
  122. .news {
  123. height: 60rpx;
  124. padding: 0 26rpx;
  125. // box-shadow: 0 10rpx 30rpx #f5f5f5;
  126. background-color: var(--view-op-point-four);
  127. margin: 0 $uni-index-margin-col;
  128. border-radius: 60rpx;
  129. // box-shadow: $uni-index-box-shadow;
  130. &.default {
  131. text-align: center;
  132. line-height: 77rpx;
  133. }
  134. }
  135. .news .pictrue {
  136. width: 116rpx;
  137. height: 28rpx;
  138. line-height: 28rpx;
  139. border-right: 1rpx solid #ddd;
  140. padding-right: 23rpx;
  141. box-sizing: content-box;
  142. }
  143. .news .pictrue image {
  144. width: 100%;
  145. height: 100%;
  146. }
  147. .news .swiperTxt {
  148. width: 470rpx;
  149. height: 100%;
  150. line-height: 60rpx;
  151. overflow: hidden;
  152. }
  153. .news .swiperTxt .text {
  154. line-height: 28rpx;
  155. margin-bottom: 4rpx;
  156. }
  157. .news .swiperTxt .text .label {
  158. font-size: 20rpx;
  159. color: #ff4c48;
  160. width: 64rpx;
  161. height: 30rpx;
  162. border-radius: 40rpx;
  163. text-align: center;
  164. line-height: 28rpx;
  165. border: 2rpx solid #ff4947;
  166. }
  167. .news .swiperTxt .text .newsTitle {
  168. width: 400rpx;
  169. font-size: 24rpx;
  170. line-height: 28rpx;
  171. color: #666;
  172. }
  173. .news .swiperTxt .iconfont {
  174. font-size: 28rpx;
  175. color: #888;
  176. }
  177. .news .swiperTxt swiper {
  178. height: 100%;
  179. }
  180. </style>