cognitive-hall.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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/cognitive-report?memberId=' + (this.selectedMemberId || '') })
  147. }
  148. }
  149. }
  150. </script>
  151. <style scoped>
  152. .page {
  153. min-height: 100vh;
  154. background: #f5f7fa;
  155. padding-bottom: 40rpx;
  156. box-sizing: border-box;
  157. }
  158. .header {
  159. padding: 40rpx 30rpx 30rpx;
  160. background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  161. color: #fff;
  162. }
  163. .title {
  164. font-size: 44rpx;
  165. font-weight: bold;
  166. display: block;
  167. }
  168. .subtitle {
  169. font-size: 26rpx;
  170. opacity: 0.85;
  171. margin-top: 10rpx;
  172. display: block;
  173. }
  174. .member-selector {
  175. padding: 24rpx 30rpx;
  176. background: #fff;
  177. margin: 20rpx 0;
  178. border-radius: 16rpx;
  179. margin-left: 30rpx;
  180. margin-right: 30rpx;
  181. }
  182. .selector-label {
  183. font-size: 26rpx;
  184. color: #666;
  185. }
  186. .member-tabs {
  187. display: flex;
  188. flex-direction: row;
  189. flex-wrap: wrap;
  190. margin-top: 16rpx;
  191. }
  192. .member-tab {
  193. padding: 10rpx 28rpx;
  194. border-radius: 30rpx;
  195. margin: 8rpx 8rpx 0 0;
  196. background: #eee;
  197. font-size: 26rpx;
  198. color: #666;
  199. }
  200. .member-tab-active {
  201. background: #6366f1;
  202. color: #fff;
  203. }
  204. .game-list {
  205. padding: 0 30rpx;
  206. }
  207. .game-card {
  208. display: flex;
  209. flex-direction: row;
  210. align-items: center;
  211. background: #fff;
  212. border-radius: 20rpx;
  213. padding: 28rpx;
  214. margin-bottom: 20rpx;
  215. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  216. }
  217. .game-icon-wrap {
  218. width: 88rpx;
  219. height: 88rpx;
  220. border-radius: 20rpx;
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. flex-shrink: 0;
  225. }
  226. .game-icon {
  227. font-size: 44rpx;
  228. }
  229. .game-info {
  230. flex: 1;
  231. margin-left: 24rpx;
  232. }
  233. .game-name {
  234. font-size: 30rpx;
  235. font-weight: bold;
  236. color: #1a1a2e;
  237. display: block;
  238. }
  239. .game-desc {
  240. font-size: 24rpx;
  241. color: #888;
  242. margin-top: 6rpx;
  243. display: block;
  244. }
  245. .game-status {
  246. font-size: 22rpx;
  247. color: #10B981;
  248. margin-top: 8rpx;
  249. display: block;
  250. }
  251. .game-status-pending {
  252. font-size: 22rpx;
  253. color: #aaa;
  254. margin-top: 8rpx;
  255. display: block;
  256. }
  257. .game-arrow {
  258. font-size: 40rpx;
  259. color: #ccc;
  260. margin-left: 16rpx;
  261. }
  262. .loading, .empty {
  263. text-align: center;
  264. padding: 80rpx 40rpx;
  265. color: #999;
  266. font-size: 28rpx;
  267. }
  268. .empty-icon {
  269. font-size: 80rpx;
  270. display: block;
  271. margin-bottom: 20rpx;
  272. }
  273. .empty-hint {
  274. font-size: 24rpx;
  275. color: #bbb;
  276. margin-top: 10rpx;
  277. display: block;
  278. }
  279. .action-row {
  280. padding: 30rpx;
  281. }
  282. .btn {
  283. width: 100%;
  284. padding: 24rpx 0;
  285. border-radius: 50rpx;
  286. text-align: center;
  287. font-size: 30rpx;
  288. font-weight: bold;
  289. box-sizing: border-box;
  290. }
  291. .btn--outline {
  292. border: 2rpx solid #6366f1;
  293. color: #6366f1;
  294. background: transparent;
  295. }
  296. .btn--outline:active {
  297. background: rgba(99,102,241,0.08);
  298. }
  299. </style>