| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <template>
- <view class="page">
- <view class="header">
- <text class="title">认知能力测评</text>
- <text class="subtitle">通过小游戏评估七项核心认知能力</text>
- </view>
- <view class="member-selector" v-if="members.length > 1">
- <text class="selector-label">选择测评对象:</text>
- <view class="member-tabs">
- <view
- class="member-tab"
- :class="{ 'member-tab-active': selectedMemberId === m.id }"
- v-for="m in members"
- :key="m.id"
- @click="selectMember(m.id)"
- >
- <text>{{ m.nickname }}</text>
- </view>
- </view>
- </view>
- <view class="loading" v-if="loading">
- <text>加载中...</text>
- </view>
- <view class="game-list" v-if="!loading">
- <view
- class="game-card"
- v-for="game in games"
- :key="game.code"
- @click="navigateTo(game.path)"
- >
- <view class="game-icon-wrap" :style="{ background: game.colorBg }">
- <text class="game-icon">{{ game.icon }}</text>
- </view>
- <view class="game-info">
- <text class="game-name">{{ game.name }}</text>
- <text class="game-desc">{{ game.desc }}</text>
- <text class="game-status" v-if="game.completed">已完成</text>
- <text class="game-status-pending" v-else>未测评</text>
- </view>
- <text class="game-arrow">›</text>
- </view>
- </view>
- <view class="empty" v-if="!loading && !hasData">
- <text class="empty-icon">🧠</text>
- <text class="empty-text">暂无认知数据</text>
- <text class="empty-hint">完成任意一项测试后即可查看详细报告</text>
- </view>
- <view class="action-row">
- <view class="btn btn--outline" @click="goReport">查看完整报告</view>
- </view>
- </view>
- </template>
- <script>
- import { getCognitiveChildScores } from '../../utils/api.js'
- import { getFamilyMemberList } from '../../utils/api.js'
- export default {
- data() {
- return {
- memberId: '',
- members: [],
- selectedMemberId: null,
- scores: null,
- loading: true
- }
- },
- computed: {
- hasData: function() {
- if (!this.scores) return false
- var s = this.scores
- return !!(s.perceptionScore || s.focusScore || s.memoryScore ||
- s.logicScore || s.spatialScore || s.processingSpeedScore || s.languageScore)
- },
- games: function() {
- var s = this.scores
- return [
- { code: 'perception', name: '感知能力', desc: '感官信息处理能力', icon: '👁️', colorBg: 'rgba(99,102,241,0.15)', path: '/pages/cognitive-test/perception-test', completed: s && s.perceptionScore != null },
- { code: 'focus', name: '专注力', desc: '持续集中和抗干扰能力', icon: '🎯', colorBg: 'rgba(239,68,68,0.15)', path: '/pages/games/schulte', completed: s && s.focusScore != null },
- { code: 'memory', name: '记忆力', desc: '信息编码和回忆能力', icon: '🧠', colorBg: 'rgba(99,102,241,0.15)', path: '/pages/cognitive-test/memory-test', completed: s && s.memoryScore != null },
- { code: 'logic', name: '逻辑推理', desc: '推理和问题解决能力', icon: '💡', colorBg: 'rgba(251,191,36,0.15)', path: '/pages/cognitive-test/logic-test', completed: s && s.logicScore != null },
- { code: 'spatial', name: '空间思维', desc: '空间想象和方位判断', icon: '🗺️', colorBg: 'rgba(16,185,129,0.15)', path: '/pages/cognitive-test/spatial-test', completed: s && s.spatialScore != null },
- { code: 'speed', name: '加工速度', desc: '信息处理和反应速度', icon: '⚡', colorBg: 'rgba(245,158,11,0.15)', path: '/pages/cognitive-test/speed-test', completed: s && s.processingSpeedScore != null },
- { code: 'language', name: '语言表达', desc: '词汇理解与语言组织', icon: '🗣️', colorBg: 'rgba(236,72,153,0.15)', path: '/pages/cognitive-test/language-test', completed: s && s.languageScore != null }
- ]
- }
- },
- onLoad: function(options) {
- if (options && options.memberId) {
- this.memberId = options.memberId
- } else {
- this.memberId = uni.getStorageSync('currentChildId') || ''
- }
- this.selectedMemberId = this.memberId
- this.loadMembers()
- this.loadScores()
- },
- methods: {
- loadMembers: function() {
- var self = this
- getFamilyMemberList({ visibleOnly: true })
- .then(function(res) {
- if (res && res.code === 200 && res.data) {
- self.members = res.data
- if (!self.memberId && res.data.length > 0) {
- self.memberId = res.data[0].id
- self.selectedMemberId = res.data[0].id
- self.loadScores()
- }
- }
- })
- .catch(function() {
- // 静默失败
- })
- },
- selectMember: function(id) {
- this.selectedMemberId = id
- this.loadScores()
- },
- loadScores: function() {
- var self = this
- var memberId = this.selectedMemberId
- if (!memberId) {
- this.loading = false
- return
- }
- this.loading = true
- getCognitiveChildScores(memberId)
- .then(function(res) {
- if (res && res.code === 200 && res.data) {
- self.scores = res.data
- } else {
- self.scores = null
- }
- })
- .catch(function() {
- self.scores = null
- })
- .finally(function() {
- self.loading = false
- })
- },
- navigateTo: function(path) {
- var url = path + '?memberId=' + this.selectedMemberId
- uni.navigateTo({ url: url })
- },
- goReport: function() {
- uni.navigateTo({ url: '/pages/wisdom/cognitive-report?memberId=' + (this.selectedMemberId || '') })
- }
- }
- }
- </script>
- <style scoped>
- .page {
- min-height: 100vh;
- background: #f5f7fa;
- padding-bottom: 40rpx;
- box-sizing: border-box;
- }
- .header {
- padding: 40rpx 30rpx 30rpx;
- background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
- color: #fff;
- }
- .title {
- font-size: 44rpx;
- font-weight: bold;
- display: block;
- }
- .subtitle {
- font-size: 26rpx;
- opacity: 0.85;
- margin-top: 10rpx;
- display: block;
- }
- .member-selector {
- padding: 24rpx 30rpx;
- background: #fff;
- margin: 20rpx 0;
- border-radius: 16rpx;
- margin-left: 30rpx;
- margin-right: 30rpx;
- }
- .selector-label {
- font-size: 26rpx;
- color: #666;
- }
- .member-tabs {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- margin-top: 16rpx;
- }
- .member-tab {
- padding: 10rpx 28rpx;
- border-radius: 30rpx;
- margin: 8rpx 8rpx 0 0;
- background: #eee;
- font-size: 26rpx;
- color: #666;
- }
- .member-tab-active {
- background: #6366f1;
- color: #fff;
- }
- .game-list {
- padding: 0 30rpx;
- }
- .game-card {
- display: flex;
- flex-direction: row;
- align-items: center;
- background: #fff;
- border-radius: 20rpx;
- padding: 28rpx;
- margin-bottom: 20rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .game-icon-wrap {
- width: 88rpx;
- height: 88rpx;
- border-radius: 20rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- }
- .game-icon {
- font-size: 44rpx;
- }
- .game-info {
- flex: 1;
- margin-left: 24rpx;
- }
- .game-name {
- font-size: 30rpx;
- font-weight: bold;
- color: #1a1a2e;
- display: block;
- }
- .game-desc {
- font-size: 24rpx;
- color: #888;
- margin-top: 6rpx;
- display: block;
- }
- .game-status {
- font-size: 22rpx;
- color: #10B981;
- margin-top: 8rpx;
- display: block;
- }
- .game-status-pending {
- font-size: 22rpx;
- color: #aaa;
- margin-top: 8rpx;
- display: block;
- }
- .game-arrow {
- font-size: 40rpx;
- color: #ccc;
- margin-left: 16rpx;
- }
- .loading, .empty {
- text-align: center;
- padding: 80rpx 40rpx;
- color: #999;
- font-size: 28rpx;
- }
- .empty-icon {
- font-size: 80rpx;
- display: block;
- margin-bottom: 20rpx;
- }
- .empty-hint {
- font-size: 24rpx;
- color: #bbb;
- margin-top: 10rpx;
- display: block;
- }
- .action-row {
- padding: 30rpx;
- }
- .btn {
- width: 100%;
- padding: 24rpx 0;
- border-radius: 50rpx;
- text-align: center;
- font-size: 30rpx;
- font-weight: bold;
- box-sizing: border-box;
- }
- .btn--outline {
- border: 2rpx solid #6366f1;
- color: #6366f1;
- background: transparent;
- }
- .btn--outline:active {
- background: rgba(99,102,241,0.08);
- }
- </style>
|