UpgradeGuideModal.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="upgrade-guide-mask" v-if="visible" @click="handleMaskClick" :style="{ '--font-scale': fontScale }">
  3. <view class="upgrade-guide-content" :class="{ 'hard-modal': type === 'hard' }" @click.stop>
  4. <view class="upgrade-guide-icon">{{ icon }}</view>
  5. <view class="upgrade-guide-title">{{ title }}</view>
  6. <view class="upgrade-guide-desc">{{ desc }}</view>
  7. <view class="upgrade-guide-actions">
  8. <view v-if="type === 'soft'" class="btn-know" @click="handleKnow">知道了</view>
  9. <view v-if="type === 'soft'" class="btn-learn" @click="handleLearn">了解详情</view>
  10. <view v-if="type === 'hard'" class="btn-upgrade" @click="handleUpgrade">升级 FAMILY</view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import fontScaleMixin from '@/mixins/font-scale.js'
  17. export default {
  18. mixins: [fontScaleMixin],
  19. name: 'UpgradeGuideModal',
  20. data() {
  21. return { visible: false }
  22. },
  23. props: {
  24. type: { type: String, default: 'soft' },
  25. quotaType: { type: String, default: '' },
  26. remaining: { type: Number, default: 0 },
  27. total: { type: Number, default: 0 }
  28. },
  29. computed: {
  30. icon() {
  31. return this.type === 'hard' ? '🔒' : 'ℹ️'
  32. },
  33. title() {
  34. if (this.quotaType === 'REPORT_READING') return '本月额度已用完'
  35. return '今日额度已用完'
  36. },
  37. desc() {
  38. if (this.type === 'hard') return '该功能为 FAMILY 会员专属权益,升级后即可使用'
  39. if (this.quotaType === 'AI_CHAT') return '您今日 AI 对话已用完(' + this.total + '/' + this.total + '),升级 FAMILY 享不限次畅聊'
  40. if (this.quotaType === 'FOOD_RECOGNIZE') return '今日饮食识别额度已用完(' + this.total + '/' + this.total + '),升级 FAMILY 享不限次识别'
  41. if (this.quotaType === 'REPORT_READING') return '本月报告解读额度已用完,升级 FAMILY 解锁不限次深度解读'
  42. return '额度已用完,升级 FAMILY 解锁更多权益'
  43. }
  44. },
  45. methods: {
  46. show() {
  47. this.visible = true
  48. },
  49. hide() {
  50. this.visible = false
  51. },
  52. handleKnow() {
  53. this.hide()
  54. this.$emit('know')
  55. },
  56. handleLearn() {
  57. this.hide()
  58. uni.navigateTo({ url: '/pages/membership/benefits' })
  59. this.$emit('learn')
  60. },
  61. handleUpgrade() {
  62. this.hide()
  63. uni.navigateTo({ url: '/pages/membership/upgrade' })
  64. this.$emit('upgrade')
  65. },
  66. handleMaskClick() {
  67. if (this.type === 'soft') {
  68. this.hide()
  69. }
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .upgrade-guide-mask {
  76. position: fixed;
  77. top: 0; left: 0; right: 0; bottom: 0;
  78. background: rgba(0,0,0,0.5);
  79. display: flex;
  80. align-items: center;
  81. justify-content: center;
  82. z-index: 999;
  83. }
  84. .upgrade-guide-content {
  85. width: 600rpx;
  86. background: $app-surface;
  87. border-radius: 24rpx;
  88. padding: 48rpx 36rpx 36rpx;
  89. text-align: center;
  90. }
  91. .upgrade-guide-icon {
  92. font-size: calc(72rpx * var(--font-scale, 1));
  93. margin-bottom: 24rpx;
  94. }
  95. .upgrade-guide-title {
  96. font-size: calc(32rpx * var(--font-scale, 1));
  97. font-weight: 600;
  98. color: $facade-text-strong;
  99. margin-bottom: 16rpx;
  100. }
  101. .upgrade-guide-desc {
  102. font-size: calc(26rpx * var(--font-scale, 1));
  103. color: $facade-text-body;
  104. line-height: 1.6;
  105. margin-bottom: 36rpx;
  106. }
  107. .upgrade-guide-actions {
  108. display: flex;
  109. flex-direction: column;
  110. gap: 16rpx;
  111. }
  112. .btn-know, .btn-learn, .btn-upgrade {
  113. height: 80rpx;
  114. line-height: 80rpx;
  115. border-radius: 24rpx;
  116. font-size: calc(28rpx * var(--font-scale, 1));
  117. }
  118. .btn-know {
  119. background: $facade-fill-2;
  120. color: $facade-text-body;
  121. }
  122. .btn-learn {
  123. background: transparent;
  124. color: $brand-primary;
  125. border: 2rpx solid $brand-primary;
  126. }
  127. .btn-upgrade {
  128. background: $brand-primary;
  129. color: $app-surface;
  130. }
  131. </style>