OnboardingGuide.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="onboarding-overlay" v-if="show">
  3. <view class="onboarding-card">
  4. <!-- 顶部品牌条 -->
  5. <view class="onboarding-topbar"></view>
  6. <!-- 步骤内容 -->
  7. <view class="onboarding-content" :key="currentStep" :class="{ 'onboarding-content--intro': steps[currentStep].isIntro }">
  8. <text class="onboarding-icon">{{ steps[currentStep].icon }}</text>
  9. <text class="onboarding-title" :class="{ 'onboarding-title--intro': steps[currentStep].isIntro }">{{ steps[currentStep].title }}</text>
  10. <text class="onboarding-desc">{{ steps[currentStep].desc }}</text>
  11. </view>
  12. <!-- 步进器 -->
  13. <view class="onboarding-dots">
  14. <view
  15. v-for="(s, i) in steps"
  16. :key="i"
  17. class="dot"
  18. :class="{ active: i === currentStep }">
  19. </view>
  20. </view>
  21. <!-- 按钮 -->
  22. <view class="onboarding-action">
  23. <view
  24. class="onboarding-btn"
  25. :class="{ 'onboarding-btn--last': currentStep === steps.length - 1 }"
  26. @click="handleNext">
  27. <text>{{ currentStep < steps.length - 1 ? '下一步' : '开始体验!' }}</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { getGuideConfig } from '../utils/api.js'
  35. var PARENT_STEPS = [
  36. {
  37. icon: '🔍',
  38. title: '你真的了解孩子的状态吗?',
  39. desc: '情绪低落没察觉、习惯变化没注意、能力短板没发现——很多问题等爆发了才看见。浠艾福帮你在问题发生前,看清孩子真实的身心状态。',
  40. isIntro: true
  41. },
  42. {
  43. icon: '🌏',
  44. title: '五维沙盘,看见全家',
  45. desc: '身·心·智·行·富,一张全景图看清每个维度。孩子身体好不好、情绪怎么样、能力到哪了——不用猜,看得见。'
  46. },
  47. {
  48. icon: '📋',
  49. title: '小任务,大改变',
  50. desc: '布置每日小任务,完成就能攒星星。每天一点点积累,好习惯自然养成。'
  51. },
  52. {
  53. icon: '🎁',
  54. title: '心愿墙,看得见努力',
  55. desc: '孩子攒够星星就能兑换心愿。努力有回报,目标感和坚持力一起培养。'
  56. }
  57. ]
  58. var CHILD_STEPS = [
  59. {
  60. icon: '🔍',
  61. title: '你的每一点成长,都被看见',
  62. desc: '今天完成了几个任务?比昨天进步了多少?浠艾福帮你记录每一点努力,让成长看得见。',
  63. isIntro: true
  64. },
  65. {
  66. icon: '🌟',
  67. title: '赚星星',
  68. desc: '完成爸爸妈妈布置的任务,就能获得星星积分,越努力越多!'
  69. },
  70. {
  71. icon: '🎮',
  72. title: '玩中学',
  73. desc: '完成任务后可以玩小游戏、兑换心愿,学习和快乐两不误!'
  74. },
  75. {
  76. icon: '🏆',
  77. title: '升级挑战',
  78. desc: '从星星宝宝到宇宙小英雄,一步步升级,看看你能走多远!'
  79. }
  80. ]
  81. export default {
  82. name: 'OnboardingGuide',
  83. props: {
  84. role: { type: String, default: 'parent' },
  85. show: { type: Boolean, default: false },
  86. position: { type: String, default: 'home' }
  87. },
  88. data() {
  89. return {
  90. currentStep: 0,
  91. _configSteps: null,
  92. _configVersion: '1.0'
  93. }
  94. },
  95. created() {
  96. var self = this
  97. getGuideConfig().then(function(res) {
  98. var cfg = (res && res.data) ? res.data : null
  99. if (cfg && (cfg.parent || cfg.child)) {
  100. self._configSteps = cfg
  101. self._configVersion = cfg.version || '1.0'
  102. }
  103. }).catch(function() {
  104. // 拉取配置失败,保持 null 走默认步骤
  105. })
  106. },
  107. computed: {
  108. steps() {
  109. if (this._configSteps) {
  110. return this.role === 'child' ? (this._configSteps.child || CHILD_STEPS) : (this._configSteps.parent || PARENT_STEPS)
  111. }
  112. if (this.role === 'child') return CHILD_STEPS
  113. return PARENT_STEPS
  114. }
  115. },
  116. watch: {
  117. show(val) {
  118. if (val) {
  119. this.currentStep = 0
  120. }
  121. }
  122. },
  123. methods: {
  124. handleNext() {
  125. if (this.currentStep < this.steps.length - 1) {
  126. this.currentStep++
  127. } else {
  128. uni.setStorageSync('_onboardingDone', JSON.stringify({ version: this._configVersion || '1.0', doneAt: Date.now() }))
  129. this.$emit('close')
  130. }
  131. }
  132. }
  133. }
  134. </script>
  135. <style scoped>
  136. /* ============================================================
  137. OnboardingGuide — 首次登录引导浮层
  138. 设计体系:统一使用 uni.scss design tokens
  139. ============================================================ */
  140. .onboarding-overlay {
  141. position: fixed;
  142. top: 0;
  143. left: 0;
  144. width: 100%;
  145. height: 100%;
  146. background: rgba(0, 0, 0, 0.5);
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. z-index: 9998;
  151. animation: fadeIn 0.25s ease;
  152. }
  153. .onboarding-card {
  154. width: 640rpx;
  155. min-height: 680rpx;
  156. background: var(--surface, #FFFFFF);
  157. border-radius: var(--radius-xl, 32rpx);
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. overflow: hidden;
  162. box-shadow: var(--shadow-lg, 0 8rpx 32rpx rgba(91, 155, 213, 0.10));
  163. animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  164. }
  165. /* 顶部品牌装饰条 — 暖珊瑚色 */
  166. .onboarding-topbar {
  167. width: 100%;
  168. height: 12rpx;
  169. background: var(--color-primary, #F97316);
  170. flex-shrink: 0;
  171. }
  172. /* ============================================================
  173. 内容区 — flex 居中,带淡入动画
  174. ============================================================ */
  175. .onboarding-content {
  176. flex: 1;
  177. display: flex;
  178. flex-direction: column;
  179. align-items: center;
  180. justify-content: center;
  181. padding: 80rpx 56rpx 48rpx;
  182. animation: fadeIn 0.3s ease;
  183. }
  184. .onboarding-icon {
  185. font-size: 80rpx;
  186. margin-bottom: 32rpx;
  187. display: block;
  188. }
  189. .onboarding-title {
  190. font-size: 36rpx;
  191. font-weight: 700;
  192. color: var(--text, #1E293B);
  193. text-align: center;
  194. margin-bottom: 20rpx;
  195. display: block;
  196. line-height: 1.3;
  197. }
  198. .onboarding-desc {
  199. font-size: 28rpx;
  200. color: var(--text-secondary, #64748B);
  201. text-align: center;
  202. line-height: 1.6;
  203. display: block;
  204. padding: 0 16rpx;
  205. }
  206. /* ============================================================
  207. 介绍步骤 — 开场身份定义页
  208. ============================================================ */
  209. .onboarding-content--intro {
  210. padding: 64rpx 56rpx 48rpx;
  211. }
  212. .onboarding-title--intro {
  213. font-size: 32rpx;
  214. font-weight: 800;
  215. color: var(--color-primary, #F97316);
  216. line-height: 1.4;
  217. }
  218. /* ============================================================
  219. 步进器圆点
  220. ============================================================ */
  221. .onboarding-dots {
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. gap: 16rpx;
  226. padding: 0 56rpx 40rpx;
  227. flex-shrink: 0;
  228. }
  229. .dot {
  230. width: 14rpx;
  231. height: 14rpx;
  232. border-radius: 50%;
  233. background: var(--border, #CBD5E1);
  234. transition: background 0.3s ease, transform 0.3s ease;
  235. }
  236. .dot.active {
  237. background: var(--color-primary, #F97316);
  238. transform: scale(1.3);
  239. }
  240. /* ============================================================
  241. 底部按钮
  242. ============================================================ */
  243. .onboarding-action {
  244. width: 100%;
  245. padding: 0 56rpx 48rpx;
  246. flex-shrink: 0;
  247. box-sizing: border-box;
  248. }
  249. .onboarding-btn {
  250. width: 100%;
  251. height: 88rpx;
  252. border-radius: 999rpx;
  253. background: var(--color-primary, #5B9BD5);
  254. color: #FFFFFF;
  255. font-size: 32rpx;
  256. font-weight: 700;
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. transition: opacity 0.2s ease, transform 0.15s ease;
  261. box-shadow: 0 4rpx 16rpx rgba(91, 155, 213, 0.25);
  262. }
  263. .onboarding-btn:active {
  264. opacity: 0.85;
  265. transform: scale(0.97);
  266. }
  267. /* 最后一步:暖珊瑚色按钮 */
  268. .onboarding-btn--last {
  269. background: var(--color-primary, #F97316);
  270. box-shadow: 0 4rpx 16rpx rgba(249, 115, 22, 0.30);
  271. }
  272. </style>