top.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="marginX14 wrapper flex-align">
  3. <view class="flex-shrink0 left flex-column-align-center">
  4. <image :src="resource.award_horn" style="width: 36rpx; height: 36rpx" />
  5. </view>
  6. <view class="flex1 paddingR20" v-if="data">
  7. <swiper class="swiper" circular="true" :interval="4000" duration="400" autoplay vertical @change="change">
  8. <swiper-item v-for="(item, index) in data" :key="index">
  9. <view class="item paddingL15 paddingY6 flex-column-align " @click="showNext(item)">
  10. <view class="font2 bold color-white flex-align-between">
  11. {{item.title}}
  12. <image v-if="item.extend" :src="resource.arrow_right" style="width: 24rpx; height: 24rpx" />
  13. </view>
  14. <view class="content font0 color-white paddingT5" style="opacity: 0.8">{{item.content}}</view>
  15. </view>
  16. </swiper-item>
  17. </swiper>
  18. </view>
  19. <view class="line translateY"></view>
  20. <view class="dots flex-column-align-center" v-if="data.length > 1">
  21. <view v-for="(_, index) in data.length" :key="index" class="dot" :class="[index === indicator && 'active' ]"></view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import resource from '@/utils/resource'
  27. export default {
  28. props: {
  29. data: Array
  30. },
  31. data() {
  32. return {
  33. resource,
  34. indicator: 0
  35. }
  36. },
  37. methods: {
  38. change(e) {
  39. this.indicator = e.detail.current
  40. },
  41. showNext(item) {
  42. if (!item.extend) {
  43. this.$router.push('message')
  44. return
  45. }
  46. if (item.extend.indexOf('http') > -1) {
  47. this.$router.web(item.extend, item.title)
  48. return
  49. }
  50. if (item.extend.indexOf('method:') > -1) {
  51. let array = item.extend.split('method:')
  52. if (array.length === 2) {
  53. let method = this.$common[array[1]]
  54. method()
  55. }
  56. return
  57. }
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. .wrapper {
  64. position: relative;
  65. height: 124rpx;
  66. background: linear-gradient(134deg, #3158ba 0%, #d070ff 100%);
  67. border-radius: 8px;
  68. opacity: 0.9;
  69. .left {
  70. width: 96rpx;
  71. }
  72. .line {
  73. position: absolute;
  74. left: 96rpx;
  75. width: 2rpx;
  76. height: 96rpx;
  77. background: linear-gradient(
  78. 180deg,
  79. rgba(255, 255, 255, 0) 0%,
  80. #ffffff 52%,
  81. rgba(255, 255, 255, 0) 100%
  82. );
  83. border-radius: 2rpx;
  84. opacity: 0.8;
  85. }
  86. .swiper {
  87. height: 124rpx;
  88. .item {
  89. height: 124rpx;
  90. .content {
  91. overflow: hidden;
  92. text-overflow: ellipsis; /* 超出部分省略号 */
  93. word-break: break-all; /* break-all(允许在单词内换行。) */
  94. display: -webkit-box; /* 对象作为伸缩盒子模型显示 */
  95. -webkit-box-orient: vertical; /* 设置或检索伸缩盒对象的子元素的排列方式 */
  96. -webkit-line-clamp: 2; /* 显示的行数 */
  97. }
  98. }
  99. }
  100. }
  101. .dots {
  102. position: absolute;
  103. right: 20rpx;
  104. top: 0;
  105. bottom: 0;
  106. width: 6rpx;
  107. .dot {
  108. width: 6rpx;
  109. height: 6rpx;
  110. border-radius: 3rpx;
  111. background: #ffffff;
  112. opacity: 0.5;
  113. margin: 6rpx 0;
  114. &.active {
  115. opacity: 1;
  116. }
  117. }
  118. }
  119. </style>