templateA.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="live-container">
  3. <view class="cm-tabs">
  4. <view
  5. class="cm-tab-item"
  6. :class="{ on: index === currentTab }"
  7. v-for="(tab, index) in tablist"
  8. :key="index"
  9. @click="handleTabChange(index)"
  10. >{{ tab.title | dateFormat }}</view
  11. >
  12. </view>
  13. <!-- 轮播图区域 -->
  14. <view class="cm-swiper-list">
  15. <swiper-temp
  16. :displayDate="pageData.floorContent.displayDate1"
  17. :floorImageList="pageData.floorImageList"
  18. v-show="currentTab === 0"
  19. ></swiper-temp>
  20. <swiper-temp
  21. :displayDate="pageData.floorContent.displayDate2"
  22. :floorImageList="pageData.floorImageList2"
  23. v-show="currentTab === 1"
  24. ></swiper-temp>
  25. <swiper-temp
  26. :displayDate="pageData.floorContent.displayDate3"
  27. :floorImageList="pageData.floorImageList3"
  28. v-show="currentTab === 2"
  29. ></swiper-temp>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import SwiperTemp from './components/swiper-temp1.vue'
  35. export default {
  36. components: { SwiperTemp },
  37. props: {
  38. pageData: {
  39. type: Object
  40. },
  41. userIdentity: {
  42. type: Number
  43. }
  44. },
  45. data() {
  46. return {
  47. tablist: [],
  48. currentTab: 0
  49. }
  50. },
  51. filters: {
  52. dateFormat(val) {
  53. // 2021-08-16 00:00:00
  54. const str = val.split(' ')[0].split('-')
  55. return str[1] + '-' + str[2]
  56. }
  57. },
  58. created() {
  59. this.initTabs()
  60. },
  61. methods: {
  62. // 初始化tab列表
  63. initTabs() {
  64. for (let i = 1; i < 4; i++) {
  65. this.tablist.push({ title: this.pageData.floorContent['displayDate' + i] })
  66. }
  67. },
  68. // tab点击事件
  69. handleTabChange(index) {
  70. this.currentTab = index
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped lang="scss">
  76. .live-container {
  77. position: relative;
  78. }
  79. .cm-tabs {
  80. position: absolute;
  81. border-radius: 18rpx;
  82. overflow: hidden;
  83. display: flex;
  84. justify-content: space-between;
  85. align-items: center;
  86. width: 250rpx;
  87. top: -80rpx;
  88. right: 0;
  89. .cm-tab-item {
  90. width: 80rpx;
  91. font-size: 20rpx;
  92. line-height: 36rpx;
  93. text-align: center;
  94. background: #fff;
  95. &.on {
  96. color: #fff;
  97. background: rgb(255, 92, 0);
  98. }
  99. }
  100. }
  101. </style>