DimensionVisitorCard.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="dvc">
  3. <!-- 价值预览卡:维度浅底 + 维度色 CTA -->
  4. <view class="dvc-card" :style="{ background: softColor }">
  5. <view class="dvc-head">
  6. <text class="dvc-title">{{ cardTitle }}</text>
  7. <text class="dvc-sub">登录后即可解锁你的专属内容</text>
  8. </view>
  9. <view class="dvc-benefits">
  10. <view class="dvc-benefit" v-for="(b, i) in benefits" :key="i">
  11. <text class="dvc-dot" :style="{ background: mainColor }"></text>
  12. <text class="dvc-benefit-text">{{ b }}</text>
  13. </view>
  14. </view>
  15. <view class="dvc-actions">
  16. <button class="dvc-btn-primary" :style="{ background: mainColor }" @click="onLogin">{{ ctaText }}</button>
  17. <button
  18. v-if="secondaryText"
  19. class="dvc-btn-secondary"
  20. :style="{ color: mainColor, borderColor: mainColor }"
  21. @click="onSecondary">{{ secondaryText }}</button>
  22. </view>
  23. </view>
  24. <!-- 维度专属预览占位(登录后展示真实数据) -->
  25. <view class="dvc-preview" v-if="previewText">
  26. <text class="dvc-preview-icon">{{ previewIcon }}</text>
  27. <text class="dvc-preview-text">{{ previewText }}</text>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. /**
  33. * 维度游客价值卡 —— 五维主页面登录前统一复用
  34. *
  35. * 维度色严格对齐 uni.scss 五维令牌(v4.0):
  36. * 身 body #FF8C42 心 mind #FF6B9D
  37. * 智 wisdom #6366F1 行 action #10B981 富 wealth #F59E0B
  38. * 此处用显式 hex(与令牌值一致)而非 var(--x),确保 mp-weixin 运行时稳定渲染。
  39. *
  40. * 登录行为复用全局 mixin 的 openLoginSheet()(main.js 已全局注册)。
  41. */
  42. var DIM_TOKENS = {
  43. body: { main: '#FF8C42', soft: 'rgba(255, 140, 66, 0.15)', icon: '🌿' },
  44. mind: { main: '#FF6B9D', soft: 'rgba(255, 107, 157, 0.15)', icon: '🔥' },
  45. wisdom: { main: '#6366F1', soft: 'rgba(99, 102, 241, 0.15)', icon: '⚡' },
  46. action: { main: '#10B981', soft: 'rgba(16, 185, 129, 0.15)', icon: '🤝' },
  47. wealth: { main: '#F59E0B', soft: 'rgba(245, 158, 11, 0.15)', icon: '💧' }
  48. }
  49. export default {
  50. props: {
  51. /** 维度编码:body | mind | wisdom | action | wealth */
  52. dimCode: { type: String, default: 'body' },
  53. /** 卡片标题 */
  54. cardTitle: { type: String, default: '登录后查看专属内容' },
  55. /** 价值收益列表(2–3 条) */
  56. benefits: {
  57. type: Array,
  58. default: function() { return [] }
  59. },
  60. /** 主登录按钮文案 */
  61. ctaText: { type: String, default: '立即登录' },
  62. /** 次级动作文案(可选) */
  63. secondaryText: { type: String, default: '' },
  64. /** 次级动作跳转地址(可选);留空则 emit('secondary') */
  65. secondaryUrl: { type: String, default: '' },
  66. /** 维度专属预览占位文案(可选);留空则不渲染预览块 */
  67. previewText: { type: String, default: '' }
  68. },
  69. computed: {
  70. token: function() {
  71. return DIM_TOKENS[this.dimCode] || DIM_TOKENS.body
  72. },
  73. mainColor: function() { return this.token.main },
  74. softColor: function() { return this.token.soft },
  75. previewIcon: function() { return this.token.icon }
  76. },
  77. methods: {
  78. onLogin: function() {
  79. // 全局 mixin 提供 openLoginSheet;极端情况下回退整页登录
  80. if (typeof this.openLoginSheet === 'function') {
  81. this.openLoginSheet()
  82. } else {
  83. uni.navigateTo({ url: '/pages/login/login' })
  84. }
  85. },
  86. onSecondary: function() {
  87. if (this.secondaryUrl) {
  88. uni.navigateTo({ url: this.secondaryUrl })
  89. } else {
  90. this.$emit('secondary')
  91. }
  92. }
  93. }
  94. }
  95. </script>
  96. <stylescoped lang="scss">
  97. .dvc {
  98. margin: 12rpx 30rpx 0;
  99. }
  100. .dvc-card {
  101. border-radius: 24rpx;
  102. padding: 32rpx 28rpx;
  103. }
  104. .dvc-head {
  105. margin-bottom: 22rpx;
  106. }
  107. .dvc-title {
  108. font-size: 30rpx;
  109. font-weight: 600;
  110. color: $facade-text-gray-800;
  111. display: block;
  112. line-height: 1.4;
  113. }
  114. .dvc-sub {
  115. font-size: 22rpx;
  116. color: $facade-text-muted;
  117. margin-top: 6rpx;
  118. display: block;
  119. }
  120. .dvc-benefits {
  121. margin-bottom: 26rpx;
  122. }
  123. .dvc-benefit {
  124. display: flex;
  125. flex-direction: row;
  126. align-items: center;
  127. margin-bottom: 16rpx;
  128. }
  129. .dvc-dot {
  130. width: 12rpx;
  131. height: 12rpx;
  132. border-radius: 50%;
  133. margin-right: 16rpx;
  134. flex-shrink: 0;
  135. }
  136. .dvc-benefit-text {
  137. font-size: 26rpx;
  138. color: $facade-text-strong;
  139. line-height: 1.5;
  140. }
  141. .dvc-actions {
  142. display: flex;
  143. flex-direction: row;
  144. gap: 20rpx;
  145. }
  146. .dvc-btn-primary {
  147. flex: 1;
  148. height: 88rpx;
  149. line-height: 88rpx;
  150. border-radius: 44rpx;
  151. color: $app-surface;
  152. font-size: 28rpx;
  153. font-weight: 600;
  154. border: none;
  155. padding: 0;
  156. }
  157. .dvc-btn-primary:active { opacity: 0.85; }
  158. .dvc-btn-secondary {
  159. flex: 1;
  160. height: 88rpx;
  161. line-height: 88rpx;
  162. border-radius: 44rpx;
  163. background: $app-surface;
  164. font-size: 28rpx;
  165. font-weight: 500;
  166. border: 2rpx solid;
  167. padding: 0;
  168. }
  169. .dvc-btn-secondary:active { opacity: 0.7; }
  170. .dvc-preview {
  171. margin-top: 24rpx;
  172. background: $app-surface;
  173. border: 1rpx dashed $facade-gray-200;
  174. border-radius: 20rpx;
  175. padding: 40rpx 28rpx;
  176. display: flex;
  177. flex-direction: column;
  178. align-items: center;
  179. }
  180. .dvc-preview-icon {
  181. font-size: 44rpx;
  182. margin-bottom: 14rpx;
  183. }
  184. .dvc-preview-text {
  185. font-size: 24rpx;
  186. color: $facade-text-muted;
  187. text-align: center;
  188. line-height: 1.6;
  189. }
  190. </style>