鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
3.4 KiB

  1. <template>
  2. <view class="page__view highlight">
  3. <!-- 导航栏 -->
  4. <navbar title="我的成就" leftClick @leftClick="$utils.navigateBack" />
  5. <view class="main">
  6. <view class="flex summary">
  7. <view class="info">
  8. <view class="flex title">共获得<view class="highlight">{{ total }}</view>枚成就</view>
  9. <view class="tag">新获得</view>
  10. </view>
  11. <view class="icon">
  12. <image class="img" src="@/pages_order/static/temp-49.png" mode="widthFix"></image>
  13. </view>
  14. </view>
  15. <view class="list">
  16. <recordsView :list="list" @lighted="getData"></recordsView>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { mapState } from 'vuex'
  23. import mixinsList from '@/mixins/list.js'
  24. import recordsView from './recordsView.vue'
  25. export default {
  26. mixins: [mixinsList],
  27. components: {
  28. recordsView,
  29. },
  30. data() {
  31. return {
  32. keyword: '',
  33. mixinsListApi: 'queryMedalList',
  34. }
  35. },
  36. computed: {
  37. ...mapState(['userInfo', 'memberInfo']),
  38. },
  39. onLoad({ search }) {
  40. if (search) {
  41. this.keyword = search
  42. this.queryParams.title = search
  43. }
  44. this.queryParams.bindUserId = this.memberInfo?.id || this.userInfo.id
  45. this.getData()
  46. },
  47. methods: {
  48. getDataThen(records) {
  49. const list = records.reduce((arr, item) => {
  50. const { id, activityId, activityId_dictText, medalId, medal, lightDate, createTime, isLight: _isLight } = item
  51. const { title, icon1, icon2 } = medal
  52. const isLight = _isLight == '1'
  53. const obj = {
  54. medalId,
  55. icon: isLight ? icon1 : icon2,
  56. label: title,
  57. createTime: lightDate || createTime,
  58. isLight,
  59. }
  60. let index = arr.findIndex(activity => activity.id === activityId)
  61. if (index === -1) {
  62. arr.push({
  63. id: activityId,
  64. name: activityId_dictText,
  65. createTime,
  66. children: [obj]
  67. })
  68. } else {
  69. arr[index].children.push(obj)
  70. }
  71. return arr
  72. }, [])
  73. list.sort((a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime())
  74. list.forEach(item => {
  75. item.children.sort((a, b) => {
  76. if ((a.isLight && b.isLight) || (!a.isLight && !b.isLight)) {
  77. return new Date(a.createTime).getTime() - new Date(b.createTime).getTime()
  78. }
  79. if (a.isLight) {
  80. return -1
  81. }
  82. return 1
  83. })
  84. })
  85. this.list = list
  86. },
  87. },
  88. }
  89. </script>
  90. <style scoped lang="scss">
  91. .summary {
  92. padding: 16rpx 72rpx 32rpx 64rpx;
  93. justify-content: space-between;
  94. font-family: PingFang SC;
  95. font-weight: 400;
  96. line-height: 1.4;
  97. .info {
  98. .title {
  99. font-size: 32rpx;
  100. font-weight: 600;
  101. color: #000000;
  102. .highlight {
  103. margin: 0 8rpx;
  104. color: $uni-color;
  105. }
  106. }
  107. .tag {
  108. margin-top: 4rpx;
  109. display: inline-block;
  110. padding: 4rpx 16rpx;
  111. font-size: 26rpx;
  112. color: #21607D;
  113. background: #DBF4FF;
  114. border-radius: 22rpx;
  115. }
  116. }
  117. .icon {
  118. width: 160rpx;
  119. height: auto;
  120. .img {
  121. width: 100%;
  122. height: auto;
  123. }
  124. }
  125. }
  126. </style>