gate-guide-bar.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="gate-guide-bar" v-if="showGuide" @click="goGates" :style="{ '--font-scale': fontScale }">
  3. <text class="guide-icon">🔓</text>
  4. <text class="guide-text">解锁进度 {{ unlockedCount }}/{{ totalCount }} · {{ guideText }}</text>
  5. <text class="guide-arrow">→</text>
  6. </view>
  7. </template>
  8. <script>
  9. /**
  10. * 首页引导进度条
  11. * 数据源:从父组件传入 unlockStatus(/api/unlock/status 返回)
  12. * 主线全解锁后自动隐藏
  13. */
  14. import fontScaleMixin from '@/mixins/font-scale.js'
  15. export default {
  16. mixins: [fontScaleMixin],
  17. props: {
  18. unlockStatus: {
  19. type: Object,
  20. default: function() { return null }
  21. }
  22. },
  23. computed: {
  24. gates: function() {
  25. var s = this.unlockStatus
  26. if (!s || !s.gates) return []
  27. return s.gates
  28. },
  29. mainGates: function() {
  30. return this.gates.filter(function(g) { return g.isRequired === 1 })
  31. },
  32. totalCount: function() {
  33. return this.mainGates.length
  34. },
  35. unlockedCount: function() {
  36. return this.mainGates.filter(function(g) { return g.status === 'UNLOCKED' }).length
  37. },
  38. showGuide: function() {
  39. if (!this.unlockStatus) return false
  40. if (this.totalCount === 0) return false
  41. // 全部解锁后隐藏
  42. return this.unlockedCount < this.totalCount
  43. },
  44. currentGate: function() {
  45. var gates = this.mainGates
  46. for (var i = 0; i < gates.length; i++) {
  47. var g = gates[i]
  48. if (g.status === 'CURRENT' || g.status === 'LOCKED') return g
  49. }
  50. return null
  51. },
  52. guideText: function() {
  53. if (this.currentGate) {
  54. return '完成「' + (this.currentGate.name || '') + '」→'
  55. }
  56. return '查看全部关卡 →'
  57. }
  58. },
  59. methods: {
  60. goGates: function() {
  61. uni.navigateTo({ url: '/pages/profile-extra/gates' })
  62. }
  63. }
  64. }
  65. </script>
  66. <style scoped lang="scss">
  67. .gate-guide-bar {
  68. display: flex;
  69. align-items: center;
  70. padding: 16rpx 24rpx;
  71. margin: 16rpx $uni-space-lg;
  72. background: linear-gradient(135deg, $facade-ink-navy, $accent-navy);
  73. border-radius: 16rpx;
  74. cursor: pointer;
  75. }
  76. .guide-icon {
  77. font-size: calc(28rpx * var(--font-scale, 1));
  78. margin-right: 12rpx;
  79. }
  80. .guide-text {
  81. flex: 1;
  82. font-size: calc(24rpx * var(--font-scale, 1));
  83. color: #8FC5E8;
  84. }
  85. .guide-arrow {
  86. font-size: calc(28rpx * var(--font-scale, 1));
  87. color: rgba(143,197,232,0.5);
  88. margin-left: 8rpx;
  89. }
  90. </style>