cognitive-hall.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="page" :style="{ '--font-scale': fontScale }">
  3. <view class="header">
  4. <text class="title">认知能力测评</text>
  5. <text class="subtitle">通过小游戏评估七项核心认知能力</text>
  6. </view>
  7. <view class="member-selector" v-if="members.length > 1">
  8. <text class="selector-label">选择测评对象:</text>
  9. <view class="member-tabs">
  10. <view
  11. class="member-tab"
  12. :class="{ 'member-tab-active': selectedMemberId === m.id }"
  13. v-for="m in members"
  14. :key="m.id"
  15. @click="selectMember(m.id)"
  16. >
  17. <text>{{ m.nickname }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="loading" v-if="loading">
  22. <text>加载中...</text>
  23. </view>
  24. <view class="game-list" v-if="!loading">
  25. <view
  26. class="game-card"
  27. v-for="game in games"
  28. :key="game.code"
  29. @click="navigateTo(game.path)"
  30. >
  31. <view class="game-icon-wrap" :style="{ background: game.colorBg }">
  32. <text class="game-icon">{{ game.icon }}</text>
  33. </view>
  34. <view class="game-info">
  35. <text class="game-name">{{ game.name }}</text>
  36. <text class="game-desc">{{ game.desc }}</text>
  37. <text class="game-status" v-if="game.completed">已完成</text>
  38. <text class="game-status-pending" v-else>未测评</text>
  39. </view>
  40. <text class="game-arrow">›</text>
  41. </view>
  42. </view>
  43. <view class="empty" v-if="!loading && !hasData">
  44. <text class="empty-icon">🧠</text>
  45. <text class="empty-text">暂无认知数据</text>
  46. <text class="empty-hint">完成任意一项测试后即可查看详细报告</text>
  47. </view>
  48. <view class="action-row">
  49. <view class="btn btn--outline" @click="goReport">查看完整报告</view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import { getCognitiveChildScores } from '../utils/api.js'
  55. import { getFamilyMemberList } from '../utils/api.js'
  56. import fontScaleMixin from '@/mixins/font-scale.js'
  57. export default {
  58. mixins: [fontScaleMixin],
  59. data() {
  60. return {
  61. memberId: '',
  62. members: [],
  63. selectedMemberId: null,
  64. scores: null,
  65. loading: true
  66. }
  67. },
  68. computed: {
  69. hasData: function() {
  70. if (!this.scores) return false
  71. var s = this.scores
  72. return !!(s.perceptionScore || s.focusScore || s.memoryScore ||
  73. s.logicScore || s.spatialScore || s.processingSpeedScore || s.languageScore)
  74. },
  75. games: function() {
  76. var s = this.scores
  77. return [
  78. { code: 'perception', name: '感知能力', desc: '感官信息处理能力', icon: '👁️', colorBg: 'rgba(99,102,241,0.15)', path: '/pages/cognitive-test/perception-test', completed: s && s.perceptionScore != null },
  79. { code: 'focus', name: '专注力', desc: '持续集中和抗干扰能力', icon: '🎯', colorBg: 'rgba(239,68,68,0.15)', path: '/pages/games/schulte', completed: s && s.focusScore != null },
  80. { code: 'memory', name: '记忆力', desc: '信息编码和回忆能力', icon: '🧠', colorBg: 'rgba(99,102,241,0.15)', path: '/pages/cognitive-test/memory-test', completed: s && s.memoryScore != null },
  81. { code: 'logic', name: '逻辑推理', desc: '推理和问题解决能力', icon: '💡', colorBg: 'rgba(251,191,36,0.15)', path: '/pages/cognitive-test/logic-test', completed: s && s.logicScore != null },
  82. { code: 'spatial', name: '空间思维', desc: '空间想象和方位判断', icon: '🗺️', colorBg: 'rgba(16,185,129,0.15)', path: '/pages/cognitive-test/spatial-test', completed: s && s.spatialScore != null },
  83. { code: 'speed', name: '加工速度', desc: '信息处理和反应速度', icon: '⚡', colorBg: 'rgba(245,158,11,0.15)', path: '/pages/cognitive-test/speed-test', completed: s && s.processingSpeedScore != null },
  84. { code: 'language', name: '语言表达', desc: '词汇理解与语言组织', icon: '🗣️', colorBg: 'rgba(236,72,153,0.15)', path: '/pages/cognitive-test/language-test', completed: s && s.languageScore != null }
  85. ]
  86. }
  87. },
  88. onLoad: function(options) {
  89. if (options && options.memberId) {
  90. this.memberId = options.memberId
  91. } else {
  92. this.memberId = uni.getStorageSync('currentChildId') || ''
  93. }
  94. this.selectedMemberId = this.memberId
  95. this.loadMembers()
  96. this.loadScores()
  97. },
  98. methods: {
  99. loadMembers: function() {
  100. var self = this
  101. getFamilyMemberList({ visibleOnly: true })
  102. .then(function(res) {
  103. if (res && res.code === 200 && res.data) {
  104. self.members = res.data
  105. if (!self.memberId && res.data.length > 0) {
  106. self.memberId = res.data[0].id
  107. self.selectedMemberId = res.data[0].id
  108. self.loadScores()
  109. }
  110. }
  111. })
  112. .catch(function() {
  113. // 静默失败
  114. })
  115. },
  116. selectMember: function(id) {
  117. this.selectedMemberId = id
  118. this.loadScores()
  119. },
  120. loadScores: function() {
  121. var self = this
  122. var memberId = this.selectedMemberId
  123. if (!memberId) {
  124. this.loading = false
  125. return
  126. }
  127. this.loading = true
  128. getCognitiveChildScores(memberId)
  129. .then(function(res) {
  130. if (res && res.code === 200 && res.data) {
  131. self.scores = res.data
  132. } else {
  133. self.scores = null
  134. }
  135. })
  136. .catch(function() {
  137. self.scores = null
  138. })
  139. .finally(function() {
  140. self.loading = false
  141. })
  142. },
  143. navigateTo: function(path) {
  144. var url = path + '?memberId=' + this.selectedMemberId
  145. uni.navigateTo({ url: url })
  146. },
  147. goReport: function() {
  148. uni.navigateTo({ url: '/pages/wisdom-detail/cognitive-report?memberId=' + (this.selectedMemberId || '') })
  149. }
  150. }
  151. }
  152. </script>
  153. <style scoped lang="scss">
  154. // ===== 页面级局部调色板(单页专有色阶;同值才映射全局令牌,约定见 uni.scss §14) =====
  155. $c-text-ghost-3: $text-ghost-soft;
  156. $c-border-hair: $facade-hairline-2; // 发丝分隔线
  157. $c-ink-night: $app-ink-night; // 深夜蓝黑(本页深色文字)
  158. .page {
  159. min-height: 100vh;
  160. background: $app-bg;
  161. padding-bottom: 40rpx;
  162. box-sizing: border-box;
  163. }
  164. .header {
  165. padding: 40rpx 30rpx 30rpx;
  166. background: linear-gradient(135deg, $dim-wisdom 0%, $facade-violet 100%);
  167. color: $app-surface;
  168. }
  169. .title {
  170. font-size: calc(44rpx * var(--font-scale, 1));
  171. font-weight: bold;
  172. display: block;
  173. }
  174. .subtitle {
  175. font-size: calc(26rpx * var(--font-scale, 1));
  176. opacity: 0.85;
  177. margin-top: 10rpx;
  178. display: block;
  179. }
  180. .member-selector {
  181. padding: 24rpx 30rpx;
  182. background: $app-surface;
  183. margin: 20rpx 0;
  184. border-radius: 16rpx;
  185. margin-left: 30rpx;
  186. margin-right: 30rpx;
  187. }
  188. .selector-label {
  189. font-size: calc(26rpx * var(--font-scale, 1));
  190. color: $facade-text-body;
  191. }
  192. .member-tabs {
  193. display: flex;
  194. flex-direction: row;
  195. flex-wrap: wrap;
  196. margin-top: 16rpx;
  197. }
  198. .member-tab {
  199. padding: 10rpx 28rpx;
  200. border-radius: 30rpx;
  201. margin: 8rpx 8rpx 0 0;
  202. background: $c-border-hair;
  203. font-size: calc(26rpx * var(--font-scale, 1));
  204. color: $facade-text-body;
  205. }
  206. .member-tab-active {
  207. background: $dim-wisdom;
  208. color: $app-surface;
  209. }
  210. .game-list {
  211. padding: 0 30rpx;
  212. }
  213. .game-card {
  214. display: flex;
  215. flex-direction: row;
  216. align-items: center;
  217. background: $app-surface;
  218. border-radius: 20rpx;
  219. padding: 28rpx;
  220. margin-bottom: 20rpx;
  221. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  222. }
  223. .game-icon-wrap {
  224. width: 88rpx;
  225. height: 88rpx;
  226. border-radius: 20rpx;
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. flex-shrink: 0;
  231. }
  232. .game-icon {
  233. font-size: 44rpx;
  234. }
  235. .game-info {
  236. flex: 1;
  237. margin-left: 24rpx;
  238. }
  239. .game-name {
  240. font-size: calc(30rpx * var(--font-scale, 1));
  241. font-weight: bold;
  242. color: $c-ink-night;
  243. display: block;
  244. }
  245. .game-desc {
  246. font-size: calc(24rpx * var(--font-scale, 1));
  247. color: $facade-text-faint;
  248. margin-top: 6rpx;
  249. display: block;
  250. }
  251. .game-status {
  252. font-size: calc(22rpx * var(--font-scale, 1));
  253. color: $dim-action;
  254. margin-top: 8rpx;
  255. display: block;
  256. }
  257. .game-status-pending {
  258. font-size: calc(22rpx * var(--font-scale, 1));
  259. color: $c-text-ghost-3;
  260. margin-top: 8rpx;
  261. display: block;
  262. }
  263. .game-arrow {
  264. font-size: 40rpx;
  265. color: $facade-text-ghost;
  266. margin-left: 16rpx;
  267. }
  268. .loading, .empty {
  269. text-align: center;
  270. padding: 80rpx 40rpx;
  271. color: $facade-text-muted;
  272. font-size: 28rpx;
  273. }
  274. .empty-icon {
  275. font-size: 80rpx;
  276. display: block;
  277. margin-bottom: 20rpx;
  278. }
  279. .empty-hint {
  280. font-size: calc(24rpx * var(--font-scale, 1));
  281. color: $facade-text-ghost-light;
  282. margin-top: 10rpx;
  283. display: block;
  284. }
  285. .action-row {
  286. padding: 30rpx;
  287. }
  288. .btn {
  289. width: 100%;
  290. padding: 24rpx 0;
  291. border-radius: 50rpx;
  292. text-align: center;
  293. font-size: calc(30rpx * var(--font-scale, 1));
  294. font-weight: bold;
  295. box-sizing: border-box;
  296. }
  297. .btn--outline {
  298. border: 2rpx solid $dim-wisdom;
  299. color: $dim-wisdom;
  300. background: transparent;
  301. }
  302. .btn--outline:active {
  303. background: rgba($dim-wisdom, 0.08);
  304. }
  305. </style>