medal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="pages-content">
  3. <navbar :config="config"></navbar>
  4. <view class="medal-box">
  5. <swiper class="medal-swiper" :current="current" :previous-margin="marginNum" :next-margin="marginNum"
  6. @change="e => current = e.detail.current">
  7. <swiper-item :class="['medal-item' , index === current ? 'big-medal-item' :'min-medal-item' ]"
  8. v-for="(item , index) in MedalList">
  9. <image :class="['medal-item-img' , index > MedalIndex ? 'picture-ash' : '']"
  10. :src="item.medalPicture" mode="aspectFit"></image>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. <view class="userScore-box" v-if="MedalList && MedalList.length >= (current + 1)">
  15. <view class="userScore-level">{{MedalList[current].medalName}} Lv.{{ MedalList[current].medalLevel }}</view>
  16. <view class="userScore-num">
  17. 累计获得{{MedalList[current].userScore || 0}}积分({{ MedalList[current].userScore || 0 }}/{{ MedalList[current].medalScore || 0}})
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. getUserMedal_Api
  25. } from "@/api/task.js"
  26. export default {
  27. data() {
  28. return {
  29. config: {
  30. back: true,
  31. title: '我的勋章',
  32. // color: 'black',
  33. color: '#fff',
  34. backgroundColor: [1, 'transparent'],
  35. statusBarFontColor: 'transparent'
  36. },
  37. marginNum: '188rpx',
  38. current: 0,
  39. MedalList: [],
  40. MedalIndex: 0
  41. }
  42. },
  43. onLoad() {
  44. this.getUserMedal()
  45. },
  46. methods: {
  47. getUserMedal() {
  48. getUserMedal_Api().then(res => {
  49. const list = res.data || [];
  50. try {
  51. list.forEach((el, index) => {
  52. if (el.currentLevel) {
  53. this.current = index;
  54. this.MedalIndex = index;
  55. throw new Error(0)
  56. }
  57. })
  58. } catch (e) {
  59. //TODO handle the exception
  60. }
  61. this.MedalList = list;
  62. });
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .pages-content {
  69. width: 100%;
  70. height: 100vh;
  71. background: linear-gradient(180deg, #262626, #4c4940);
  72. .medal-box {
  73. width: 100%;
  74. // width: 362rpx;
  75. height: 417rpx;
  76. margin-top: 200rpx;
  77. .medal-swiper {
  78. // width: 100%;
  79. height: 417rpx;
  80. .medal-item {
  81. width: 362rpx;
  82. height: 417rpx;
  83. display: flex;
  84. justify-content: center;
  85. .medal-item-img {
  86. margin: 0 auto;
  87. width: 362rpx;
  88. height: 417rpx;
  89. transition: transform 0.6s;
  90. }
  91. }
  92. .big-medal-item {
  93. .medal-item-img {
  94. // transform: scale(0.5);
  95. }
  96. }
  97. .min-medal-item {
  98. .medal-item-img {
  99. transform: scale(0.7);
  100. }
  101. }
  102. }
  103. }
  104. .userScore-box {
  105. display: flex;
  106. flex-direction: column;
  107. justify-content: center;
  108. align-items: center;
  109. color: #fff;
  110. padding: 40rpx 20rpx;
  111. .userScore-level {
  112. font-size: 38rpx;
  113. font-weight: Light;
  114. text-align: center;
  115. color: #ffffff;
  116. padding: 10rpx 20rpx;
  117. }
  118. .userScore-num {
  119. font-size: 28rpx;
  120. font-weight: Light;
  121. text-align: center;
  122. color: #b3b3b3;
  123. }
  124. }
  125. }
  126. .picture-ash {
  127. filter: grayscale(100%);
  128. /* 设置灰度百分比 */
  129. }
  130. </style>