去掉协会 WebView 和魔方账密页,微信登录与咨询接口共用同一 token 和拦截器。 Co-authored-by: Cursor <cursoragent@cursor.com>
86 lines
2.8 KiB
Vue
86 lines
2.8 KiB
Vue
<template>
|
||
<yxg-page :title="cat?.title || '题库分类'">
|
||
<view class="head">
|
||
<yxg-tool-icon :name="heroIcon" :size="40" />
|
||
<view>
|
||
<text class="title">{{ cat?.title || '题库分类' }}</text>
|
||
<text v-if="cat" class="sub">{{ cat.description }}</text>
|
||
</view>
|
||
</view>
|
||
<text v-if="loading" class="hint">加载中…</text>
|
||
<text v-else-if="error" class="err" @click="load">{{ error }} · 重试</text>
|
||
<view v-else class="list">
|
||
<view v-for="it in items" :key="it.slug" class="row" @click="yxgGo(it.path)">
|
||
<yxg-tool-icon :name="iconName(it.icon || cat?.icon || 'mbti')" :size="28" />
|
||
<view class="row-body">
|
||
<text class="row-t">{{ it.title }}</text>
|
||
<text class="row-d">{{ it.description }} · {{ it.question_count }} 题</text>
|
||
</view>
|
||
<text class="chev">›</text>
|
||
</view>
|
||
</view>
|
||
<text class="disc">题库内容仅供自我探索参考,不构成心理或医学诊断。</text>
|
||
</yxg-page>
|
||
</template>
|
||
|
||
<script setup>
|
||
import YxgPage from '@/components/yxg/yxg-page.vue'
|
||
import YxgToolIcon from '@/components/yxg/yxg-tool-icon.vue'
|
||
import { yxgApi } from '@/util/yxgApi.js'
|
||
import { ensureAccount } from '@/util/yxgAuth.js'
|
||
import { resolveIcon } from '@/util/yxgCatalog.js'
|
||
import { yxgGo } from '@/util/yxgNav.js'
|
||
|
||
const category = ref('')
|
||
const cat = ref(null)
|
||
const items = ref([])
|
||
const loading = ref(true)
|
||
const error = ref('')
|
||
const heroIcon = computed(() => resolveIcon(cat.value?.icon || 'mbti'))
|
||
|
||
function iconName(raw) {
|
||
return resolveIcon(raw)
|
||
}
|
||
|
||
async function load() {
|
||
loading.value = true
|
||
error.value = ''
|
||
if (!(await ensureAccount(`/explore/bank/${category.value}`))) {
|
||
loading.value = false
|
||
return
|
||
}
|
||
try {
|
||
const res = await yxgApi.getScaleBankCategory(category.value)
|
||
cat.value = res.category
|
||
items.value = res.items || []
|
||
} catch (e) {
|
||
error.value = e instanceof Error ? e.message : '加载失败'
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
onLoad((q) => {
|
||
category.value = q.category || ''
|
||
load()
|
||
})
|
||
</script>
|
||
|
||
<style>
|
||
page { background-color: #ffd1c7; }
|
||
</style>
|
||
<style scoped>
|
||
.head { display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
|
||
.title { display: block; font-size: 20px; font-weight: 700; color: #333; }
|
||
.sub { display: block; font-size: 12px; color: #999; margin-top: 2px; }
|
||
.list { margin: 8px 16px; background: #fff; border-radius: 16px; }
|
||
.row { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid #f5f5f5; }
|
||
.row:last-child { border-bottom: none; }
|
||
.row-body { flex: 1; min-width: 0; }
|
||
.row-t { display: block; font-size: 15px; font-weight: 650; color: #222; }
|
||
.row-d { display: block; font-size: 12px; color: #999; margin-top: 2px; }
|
||
.chev { color: #ccc; }
|
||
.hint, .err, .disc { display: block; padding: 16px; font-size: 13px; color: #999; }
|
||
.err { color: #e54d42; }
|
||
</style>
|