soothe-toolbox.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view class="toolbox-container" :style="{ '--font-scale': fontScale }">
  3. <!-- ===== 4-7-8 呼吸练习 ===== -->
  4. <view class="tool-section">
  5. <view class="section-header">
  6. <text class="section-emoji">&#x1F9D8;</text>
  7. <text class="section-title">4-7-8 呼吸练习</text>
  8. </view>
  9. <text class="section-desc">用深呼吸让自己平静下来</text>
  10. <view class="breathing-area" @click="toggleBreathing">
  11. <view :class="['breath-circle', breathPhase]">
  12. <text class="breath-text">{{ breathInstruction }}</text>
  13. </view>
  14. </view>
  15. <text class="breath-hint" v-if="!breathing">点击开始呼吸练习</text>
  16. <text class="breath-count" v-if="breathing">第 {{ breathRound }} 轮</text>
  17. </view>
  18. <!-- ===== 正念练习 ===== -->
  19. <view class="tool-section">
  20. <view class="section-header">
  21. <text class="section-emoji">&#x1F4A1;</text>
  22. <text class="section-title">正念练习</text>
  23. </view>
  24. <view class="mindfulness-cards">
  25. <view
  26. :class="['mind-card', activeMindCard === idx ? 'mind-card-active' : '']"
  27. v-for="(item, idx) in mindfulnessItems"
  28. :key="idx"
  29. @click="activeMindCard = idx">
  30. <text class="mind-card-title">{{ item.title }}</text>
  31. <text class="mind-card-desc">{{ item.desc }}</text>
  32. </view>
  33. </view>
  34. <view class="mindfulness-content" v-if="activeMindCard !== -1">
  35. <text class="mindfulness-text">{{ mindfulnessItems[activeMindCard].content }}</text>
  36. </view>
  37. </view>
  38. <!-- ===== 情绪涂鸦 ===== -->
  39. <view class="tool-section">
  40. <view class="section-header">
  41. <text class="section-emoji">&#x1F3A8;</text>
  42. <text class="section-title">情绪涂鸦</text>
  43. </view>
  44. <text class="section-desc">在纸上自由画下你现在的情绪</text>
  45. <view class="doodle-suggestions">
  46. <view class="doodle-item" v-for="(item, idx) in doodlePrompts" :key="idx">
  47. <text class="doodle-icon">{{ item.icon }}</text>
  48. <text class="doodle-text">{{ item.text }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- ===== 运动释压 ===== -->
  53. <view class="tool-section">
  54. <view class="section-header">
  55. <text class="section-emoji">&#x1F3CB;</text>
  56. <text class="section-title">运动释压</text>
  57. </view>
  58. <text class="section-desc">简单的伸展动作,释放身体紧张</text>
  59. <view class="exercise-list">
  60. <view class="exercise-item" v-for="(ex, idx) in exercises" :key="idx">
  61. <text class="exercise-name">{{ ex.name }}</text>
  62. <text class="exercise-desc">{{ ex.desc }}</text>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 底部提示 -->
  67. <view class="disclaimer">
  68. <text class="disclaimer-text">以上内容仅供参考,不能替代专业心理咨询或医疗建议。如有需要,请寻求专业帮助。</text>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import fontScaleMixin from '@/mixins/font-scale.js'
  74. export default {
  75. mixins: [fontScaleMixin],
  76. data() {
  77. return {
  78. breathing: false,
  79. breathPhase: 'inhal',
  80. breathInstruction: '吸气',
  81. breathRound: 0,
  82. breathTimer: null,
  83. activeMindCard: -1,
  84. mindfulnessItems: [
  85. {
  86. title: '5-4-3-2-1 感官练习',
  87. desc: '快速回归当下',
  88. content: '找一个舒服的姿势坐下,深呼吸三次。然后:\n\n看:说出你看到的 5 样东西\n听:说出你听到的 4 种声音\n触:感受你身体的 3 处触觉\n闻:闻到的 2 种气味\n味:品尝到的 1 种味道\n\n这个练习能帮你快速从焦虑中回到当下。'
  89. },
  90. {
  91. title: '身体扫描',
  92. desc: '放松全身',
  93. content: '闭上眼睛,把注意力带到脚趾。感受脚趾的温度和触感。\n\n慢慢向上移动注意力:脚掌 → 脚踝 → 小腿 → 膝盖 → 大腿 → 腹部 → 胸部 → 手指 → 手臂 → 肩膀 → 脖子 → 面部 → 头顶。\n\n在每个部位停留 3-5 秒,感受那里的感觉。'
  94. },
  95. {
  96. title: '感恩三件事',
  97. desc: '培养积极心态',
  98. content: '想一想今天让你感到感恩的三件事。可以是很小的事:\n\n1. 今天吃到了一顿美味的饭\n2. 有人对你说了一句温暖的话\n3. 今天的天气很好\n4. 你学会了一样新东西\n5. 帮助了别人\n\n在心里默默感谢这些美好。'
  99. }
  100. ],
  101. doodlePrompts: [
  102. { icon: '\u{1F308}', text: '画出你今天的情绪彩虹' },
  103. { icon: '\u{1F33F}', text: '画一棵代表你内心的小树' },
  104. { icon: '\u{1F30A}', text: '画出心情波浪' },
  105. { icon: '\u{1F31F}', text: '画出你心中的星星' }
  106. ],
  107. exercises: [
  108. { name: '耸肩放松', desc: '双肩用力向上耸起(靠近耳朵),保持 5 秒,然后突然放松。重复 5 次。' },
  109. { name: '颈部伸展', desc: '慢慢将头向右侧倾斜,右手轻压头部,保持 15 秒。换左侧重复。' },
  110. { name: '猫牛式', desc: '双手双膝着地,吸气时塌腰抬头(牛式),呼气时弓背低头(猫式)。重复 10 次。' },
  111. { name: '蝴蝶式', desc: '坐姿,双脚掌相对,双手握住脚踝,膝盖向两侧打开轻轻上下抖动,像蝴蝶扇动翅膀。' }
  112. ]
  113. }
  114. },
  115. methods: {
  116. toggleBreathing() {
  117. if (this.breathing) {
  118. this.stopBreathing()
  119. } else {
  120. this.startBreathing()
  121. }
  122. },
  123. startBreathing() {
  124. this.breathing = true
  125. this.breathRound = 1
  126. this.doBreathPhase('inhal', 4)
  127. },
  128. doBreathPhase(phase, seconds) {
  129. var self = this
  130. if (!self.breathing) return
  131. self.breathPhase = phase
  132. var instructions = {
  133. inhal: '吸气...',
  134. hold: '屏息...',
  135. exhale: '呼气...'
  136. }
  137. self.breathInstruction = instructions[phase] || ''
  138. self.breathTimer = setTimeout(function() {
  139. if (!self.breathing) return
  140. if (phase === 'inhal') {
  141. self.doBreathPhase('hold', 7)
  142. } else if (phase === 'hold') {
  143. self.doBreathPhase('exhale', 8)
  144. } else {
  145. // exhale done, start next round
  146. var nextRound = self.breathRound + 1
  147. self.breathRound = nextRound
  148. if (nextRound <= 5) {
  149. self.doBreathPhase('inhal', 4)
  150. } else {
  151. self.stopBreathing()
  152. uni.showToast({ title: '完成一组呼吸', icon: 'none' })
  153. }
  154. }
  155. }, seconds * 1000)
  156. },
  157. stopBreathing() {
  158. this.breathing = false
  159. if (this.breathTimer) {
  160. clearTimeout(this.breathTimer)
  161. this.breathTimer = null
  162. }
  163. this.breathPhase = 'inhal'
  164. this.breathInstruction = '吸气'
  165. this.breathRound = 0
  166. }
  167. },
  168. onUnload() {
  169. this.stopBreathing()
  170. }
  171. }
  172. </script>
  173. <style scoped lang="scss">
  174. .toolbox-container {
  175. min-height: 100vh;
  176. background: linear-gradient(180deg, $status-success-tint-2 0%, $app-surface 50%, $facade-brand-tint 100%);
  177. padding-bottom: 40rpx;
  178. }
  179. .tool-section {
  180. margin: 24rpx 32rpx;
  181. background: $app-surface;
  182. border-radius: 24rpx;
  183. padding: 28rpx;
  184. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04);
  185. }
  186. .section-header {
  187. display: flex;
  188. align-items: center;
  189. margin-bottom: 8rpx;
  190. }
  191. .section-emoji {
  192. font-size: calc(36rpx * var(--font-scale, 1));
  193. margin-right: 12rpx;
  194. }
  195. .section-title {
  196. font-size: calc(30rpx * var(--font-scale, 1));
  197. font-weight: 600;
  198. color: $facade-text-strong;
  199. }
  200. .section-desc {
  201. font-size: calc(24rpx * var(--font-scale, 1));
  202. color: $facade-text-muted;
  203. display: block;
  204. margin-bottom: 20rpx;
  205. }
  206. /* ===== 呼吸练习 ===== */
  207. .breathing-area {
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. padding: 40rpx 0;
  212. }
  213. .breath-circle {
  214. width: 280rpx;
  215. height: 280rpx;
  216. border-radius: 50%;
  217. background: linear-gradient(135deg, $status-success-light, $status-success-light-2);
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. transition: background 0.3s ease;
  222. box-shadow: 0 8rpx 40rpx rgba(16, 185, 129, 0.2);
  223. }
  224. .breath-circle.inhal {
  225. animation: breatheIn 4s ease-in-out;
  226. }
  227. .breath-circle.hold {
  228. background: linear-gradient(135deg, $status-warning-light, $dim-wealth);
  229. box-shadow: 0 8rpx 40rpx rgba(245, 158, 11, 0.3);
  230. }
  231. .breath-circle.exhale {
  232. animation: breatheOut 8s ease-in-out;
  233. }
  234. .breath-text {
  235. font-size: calc(36rpx * var(--font-scale, 1));
  236. font-weight: 600;
  237. color: $app-surface;
  238. }
  239. .breath-hint {
  240. display: block;
  241. text-align: center;
  242. font-size: calc(24rpx * var(--font-scale, 1));
  243. color: $facade-text-muted;
  244. }
  245. .breath-count {
  246. display: block;
  247. text-align: center;
  248. font-size: calc(24rpx * var(--font-scale, 1));
  249. color: $status-success;
  250. margin-top: 8rpx;
  251. }
  252. /* ===== 正念练习 ===== */
  253. .mindfulness-cards {
  254. display: flex;
  255. flex-direction: column;
  256. gap: 16rpx;
  257. }
  258. .mind-card {
  259. padding: 20rpx;
  260. background: $facade-fill-ghost-2;
  261. border-radius: 16rpx;
  262. border: 2rpx solid transparent;
  263. }
  264. .mind-card-active {
  265. background: $status-success-tint-2;
  266. border-color: $status-success;
  267. }
  268. .mind-card-title {
  269. font-size: calc(26rpx * var(--font-scale, 1));
  270. font-weight: 600;
  271. color: $facade-text-strong;
  272. display: block;
  273. }
  274. .mind-card-desc {
  275. font-size: calc(22rpx * var(--font-scale, 1));
  276. color: $facade-text-muted;
  277. display: block;
  278. margin-top: 4rpx;
  279. }
  280. .mindfulness-content {
  281. margin-top: 16rpx;
  282. padding: 20rpx;
  283. background: $status-success-tint-2;
  284. border-radius: 16rpx;
  285. border-left: 6rpx solid $status-success;
  286. }
  287. .mindfulness-text {
  288. font-size: calc(24rpx * var(--font-scale, 1));
  289. color: $facade-text-deep;
  290. line-height: 1.8;
  291. white-space: pre-wrap;
  292. }
  293. /* ===== 情绪涂鸦 ===== */
  294. .doodle-suggestions {
  295. display: flex;
  296. flex-wrap: wrap;
  297. gap: 16rpx;
  298. }
  299. .doodle-item {
  300. width: calc(50% - 8rpx);
  301. display: flex;
  302. align-items: center;
  303. gap: 12rpx;
  304. padding: 20rpx;
  305. background: $dim-wealth-tint;
  306. border-radius: 16rpx;
  307. box-sizing: border-box;
  308. }
  309. .doodle-icon {
  310. font-size: calc(36rpx * var(--font-scale, 1));
  311. }
  312. .doodle-text {
  313. font-size: calc(24rpx * var(--font-scale, 1));
  314. color: $facade-text-body;
  315. flex: 1;
  316. }
  317. /* ===== 运动释压 ===== */
  318. .exercise-list {
  319. display: flex;
  320. flex-direction: column;
  321. gap: 16rpx;
  322. }
  323. .exercise-item {
  324. padding: 20rpx;
  325. background: $tint-sky-soft;
  326. border-radius: 16rpx;
  327. border-left: 6rpx solid $status-info;
  328. }
  329. .exercise-name {
  330. font-size: calc(26rpx * var(--font-scale, 1));
  331. font-weight: 600;
  332. color: $status-info-deep;
  333. display: block;
  334. margin-bottom: 6rpx;
  335. }
  336. .exercise-desc {
  337. font-size: calc(24rpx * var(--font-scale, 1));
  338. color: $facade-text-body;
  339. line-height: 1.6;
  340. display: block;
  341. }
  342. /* ===== 免责声明 ===== */
  343. .disclaimer {
  344. margin: 32rpx;
  345. padding: 20rpx;
  346. background: $status-warning-soft;
  347. border-radius: 16rpx;
  348. }
  349. .disclaimer-text {
  350. font-size: calc(22rpx * var(--font-scale, 1));
  351. color: $status-warning-strong;
  352. line-height: 1.6;
  353. }
  354. </style>