index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <scroll-view class="rights-container" scroll-y="true">
  3. <!-- #ifdef MP -->
  4. <NavBar titleText="会员权益" :iconColor="iconColor" :textColor="iconColor" :isScrolling="isScrolling" showBack></NavBar>
  5. <!-- #endif -->
  6. <view class="header acea-row">
  7. <view v-for="(item, index) in memberRights" :key="item.id" class="item acea-row row-column row-middle" :class="{ on: currentIndex == index }" @click="currentIndex = index">
  8. <view class="image-wrap acea-row row-center-wrapper">
  9. <image :src="item.pic" class="image"></image>
  10. </view>
  11. <view>{{ item.title }}</view>
  12. </view>
  13. </view>
  14. <swiper class="swiper" :current="currentIndex" :interval="3000" :duration="1000" previous-margin="58rpx" next-margin="58rpx" @change="swiperChange">
  15. <swiper-item v-for="(item, index) in memberRights" :key="item.id">
  16. <view class="swiper-item acea-row row-column" :class="{ on: currentIndex == index }">
  17. <view class="title">{{ item.explain }}</view>
  18. <scroll-view class="scroll-view" scroll-y="true">
  19. <view v-html="item.content || ''"></view>
  20. </scroll-view>
  21. </view>
  22. </swiper-item>
  23. </swiper>
  24. </scroll-view>
  25. </template>
  26. <script>
  27. import {
  28. memberCard,
  29. } from '@/api/user.js';
  30. import NavBar from '@/components/NavBar.vue';
  31. export default {
  32. components: {
  33. NavBar
  34. },
  35. data() {
  36. return {
  37. // #ifdef MP
  38. iconColor: '#FFFFFF',
  39. isScrolling: false,
  40. // #endif
  41. memberRights: [],
  42. currentIndex: 0,
  43. }
  44. },
  45. onLoad() {
  46. this.memberCard();
  47. },
  48. methods: {
  49. memberCard() {
  50. uni.showLoading({
  51. title: '正在加载…'
  52. });
  53. memberCard().then(res => {
  54. uni.hideLoading();
  55. const {
  56. member_rights,
  57. } = res.data;
  58. this.memberRights = member_rights;
  59. }).catch(err => {
  60. uni.showToast({
  61. title: err,
  62. icon: 'none'
  63. });
  64. });
  65. },
  66. swiperChange(e) {
  67. this.currentIndex = e.detail.current;
  68. },
  69. },
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .rights-container {
  74. position: absolute;
  75. top: 0;
  76. right: 0;
  77. bottom: 0;
  78. left: 0;
  79. background: linear-gradient(180deg, #312B23 0%, #19140E 100%);
  80. .header {
  81. .item {
  82. flex: 1;
  83. padding: 48rpx 0 56rpx;
  84. font-size: 24rpx;
  85. line-height: 34rpx;
  86. color: rgba(255, 255, 255, 0.4);
  87. &.on {
  88. color: rgba(255, 255, 255, 0.8);
  89. .image {
  90. opacity: 1;
  91. }
  92. }
  93. }
  94. .image-wrap {
  95. position: relative;
  96. width: 88rpx;
  97. height: 88rpx;
  98. border-radius: 50%;
  99. margin-bottom: 28rpx;
  100. background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 2%, rgba(255, 255, 255, 0) 100%);
  101. }
  102. .image {
  103. width: 100%;
  104. height: 100%;
  105. opacity: 0.3;
  106. }
  107. }
  108. .swiper {
  109. height: 1090rpx;
  110. }
  111. .swiper-item {
  112. height: 100%;
  113. transform: scale(0.9);
  114. transition: 0.3s;
  115. &.on {
  116. transform: scale(1);
  117. }
  118. .title {
  119. padding: 42rpx 0 40rpx;
  120. border-radius: 24rpx 24rpx 0 0;
  121. background-color: #FFEBC7;
  122. text-align: center;
  123. font-weight: 500;
  124. font-size: 30rpx;
  125. line-height: 42rpx;
  126. color: #333333;
  127. }
  128. }
  129. .scroll-view {
  130. flex: 1;
  131. min-height: 0;
  132. padding: 48rpx;
  133. border-radius: 0 0 24rpx 24rpx;
  134. background-color: #FFFFFF;
  135. box-sizing: border-box;
  136. }
  137. }
  138. </style>