cognitive-hall.vue 8.6 KB

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