refactor: rewrite company-bank and internship pages
- bank.vue: Composition API, design tokens, 2-col grid, better UX - internship.vue: search bar, category tabs, card list layout
This commit is contained in:
@@ -1,197 +1,259 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page fade-in">
|
||||||
<!-- 搜索栏 -->
|
<!-- 搜索栏 -->
|
||||||
<view class="search-bar">
|
<view class="search-bar">
|
||||||
|
<view class="search-inner">
|
||||||
|
<text class="search-icon">🔍</text>
|
||||||
<input class="search-input" v-model="keyword" placeholder="搜索公司名称..." @confirm="searchCompany" />
|
<input class="search-input" v-model="keyword" placeholder="搜索公司名称..." @confirm="searchCompany" />
|
||||||
|
<text class="search-clear" v-if="keyword" @tap="keyword = ''">✕</text>
|
||||||
|
</view>
|
||||||
<button class="search-btn" @tap="searchCompany">搜索</button>
|
<button class="search-btn" @tap="searchCompany">搜索</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 热门公司 -->
|
<!-- 热门公司 -->
|
||||||
<view class="section" v-if="!searching">
|
<view class="section" v-if="!selectedCompany">
|
||||||
<view class="section-title">热门公司题库</view>
|
<view class="section-header">
|
||||||
<view class="company-grid">
|
<text class="section-title">🏢 热门公司题库</text>
|
||||||
<view
|
|
||||||
class="company-card"
|
|
||||||
v-for="c in hotCompanies"
|
|
||||||
:key="c.name"
|
|
||||||
@tap="selectCompany(c.name)"
|
|
||||||
>
|
|
||||||
<view class="company-name">{{ c.name }}</view>
|
|
||||||
<view class="company-count">{{ c.positionCount > 0 ? c.positionCount + ' 个岗位' : '暂无题库' }}</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
<view class="loading-bar" v-if="loading">
|
||||||
|
<view class="loading-text">加载中...</view>
|
||||||
|
</view>
|
||||||
|
<view class="company-grid" v-else-if="hotCompanies.length > 0">
|
||||||
|
<view class="company-card card" v-for="c in hotCompanies" :key="c.name" @tap="selectCompany(c.name)">
|
||||||
|
<text class="company-name">{{ c.name }}</text>
|
||||||
|
<text class="company-count">{{ c.positionCount > 0 ? c.positionCount + ' 个岗位' : '暂无题库' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="empty" v-else>
|
||||||
|
<text class="empty-icon">📭</text>
|
||||||
|
<text class="empty-text">暂无公司题库数据</text>
|
||||||
|
<text class="empty-hint">完成面试后贡献面经,帮助更多人</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 搜索结果:岗位列表 -->
|
<!-- 岗位列表 -->
|
||||||
<view class="section" v-if="selectedCompany && !loadingPositions">
|
<view class="section" v-if="selectedCompany">
|
||||||
<view class="section-title-row">
|
<view class="section-header">
|
||||||
<text class="section-title">{{ selectedCompany }} - 岗位列表</text>
|
<view class="section-header-left">
|
||||||
<text class="back-link" @tap="selectedCompany = ''">返回</text>
|
<text class="section-back" @tap="backToCompanies">‹ 返回</text>
|
||||||
|
<text class="section-title">{{ selectedCompany }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="position-list">
|
|
||||||
<view
|
|
||||||
class="position-item"
|
|
||||||
v-for="p in positions"
|
|
||||||
:key="p.position"
|
|
||||||
@tap="selectPosition(p.position)"
|
|
||||||
>
|
|
||||||
<view class="position-name">{{ p.position }}</view>
|
|
||||||
<view class="position-meta">{{ p.questionCount }} 题 · {{ p.contributionCount }} 人贡献</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="empty-state" v-if="positions.length === 0">
|
<view class="loading-bar" v-if="loadingPositions">
|
||||||
<text>暂无该公司的面经数据</text>
|
<view class="loading-text">加载岗位中...</view>
|
||||||
<text class="sub-text">成为第一个贡献者吧!</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
<view class="position-list" v-else-if="positions.length > 0">
|
||||||
|
<view class="pos-item card" v-for="p in positions" :key="p.position" @tap="selectPosition(p.position)">
|
||||||
|
<view class="pos-left">
|
||||||
|
<text class="pos-icon">{{ p.icon || '💼' }}</text>
|
||||||
|
<view class="pos-body">
|
||||||
|
<text class="pos-name">{{ p.position }}</text>
|
||||||
|
<text class="pos-meta">{{ p.questionCount }} 题 · {{ p.contributionCount }} 人贡献</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="pos-arrow">›</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="empty" v-else>
|
||||||
|
<text class="empty-icon">📭</text>
|
||||||
|
<text class="empty-text">暂无该公司的面经数据</text>
|
||||||
|
<text class="empty-hint">成为第一个贡献者吧!</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 题目列表 -->
|
<!-- 题目列表 -->
|
||||||
<view class="section" v-if="selectedPosition && !loadingQuestions">
|
<view class="section" v-if="selectedPosition">
|
||||||
<view class="section-title-row">
|
<view class="section-header">
|
||||||
<text class="section-title">{{ selectedCompany }} · {{ selectedPosition }}</text>
|
<view class="section-header-left">
|
||||||
<text class="back-link" @tap="selectedPosition = ''">返回</text>
|
<text class="section-back" @tap="selectedPosition = ''">‹ 返回</text>
|
||||||
|
<text class="section-title">{{ selectedPosition }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="question-list">
|
</view>
|
||||||
<view class="question-item" v-for="(q, i) in questions" :key="i">
|
<view class="loading-bar" v-if="loadingQuestions">
|
||||||
|
<view class="loading-text">加载题目中...</view>
|
||||||
|
</view>
|
||||||
|
<view class="question-list" v-else-if="questions.length > 0">
|
||||||
|
<view class="question-item card" v-for="(q, i) in questions" :key="i">
|
||||||
<view class="q-header">
|
<view class="q-header">
|
||||||
<text class="q-num">#{{ i + 1 }}</text>
|
<text class="q-num">#{{ i + 1 }}</text>
|
||||||
<text class="q-tag">{{ q.type === 'technical' ? '技术' : '行为' }}</text>
|
<text class="q-tag" :class="'q-tag-' + (q.type === 'technical' ? 'tech' : 'behavior')">{{ q.type === 'technical' ? '技术' : '行为' }}</text>
|
||||||
<text class="q-diff">{{ difficultyLabel(q.difficulty) }}</text>
|
<text class="q-diff" :class="'q-diff-' + (q.difficulty || 'medium')">{{ difficultyLabel(q.difficulty) }}</text>
|
||||||
<text class="q-freq">{{ q.frequency }} 次提及</text>
|
<text class="q-freq">{{ q.frequency }} 次提及</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="q-content">{{ q.content }}</view>
|
<text class="q-content">{{ q.content }}</text>
|
||||||
<view class="q-tags" v-if="q.tags && q.tags.length">
|
<view class="q-tags" v-if="q.tags && q.tags.length">
|
||||||
<text class="tag" v-for="t in q.tags" :key="t">{{ t }}</text>
|
<text class="tag" v-for="t in q.tags" :key="t">{{ t }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="q-answer" v-if="q.referenceAnswer">
|
<view class="q-answer" v-if="q.referenceAnswer">
|
||||||
<text class="answer-label">参考思路:</text>
|
<text class="answer-label">💡 参考思路</text>
|
||||||
<text class="answer-text">{{ q.referenceAnswer }}</text>
|
<text class="answer-text">{{ q.referenceAnswer }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="empty-state" v-if="questions.length === 0">
|
|
||||||
<text>暂无题目数据</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
<view class="empty" v-else>
|
||||||
|
<text class="empty-icon">📭</text>
|
||||||
|
<text class="empty-text">暂无题目数据</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 加载态 -->
|
|
||||||
<view class="loading" v-if="loadingPositions || loadingQuestions">
|
|
||||||
<text>加载中...</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
import { api } from '../../config'
|
import { api } from '../../config'
|
||||||
|
|
||||||
export default {
|
const keyword = ref('')
|
||||||
data() {
|
const hotCompanies = ref([])
|
||||||
return {
|
const selectedCompany = ref('')
|
||||||
keyword: '',
|
const selectedPosition = ref('')
|
||||||
searching: false,
|
const positions = ref([])
|
||||||
hotCompanies: [],
|
const questions = ref([])
|
||||||
selectedCompany: '',
|
const loading = ref(true)
|
||||||
selectedPosition: '',
|
const loadingPositions = ref(false)
|
||||||
positions: [],
|
const loadingQuestions = ref(false)
|
||||||
questions: [],
|
|
||||||
loadingPositions: false,
|
onMounted(() => { loadHotCompanies() })
|
||||||
loadingQuestions: false,
|
|
||||||
}
|
async function loadHotCompanies() {
|
||||||
},
|
loading.value = true
|
||||||
onLoad() {
|
|
||||||
this.loadHotCompanies()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async loadHotCompanies() {
|
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({ url: api('/contribution/companies/hot'), method: 'GET' })
|
const token = uni.getStorageSync('token') || ''
|
||||||
if (res.statusCode === 200) this.hotCompanies = res.data || []
|
const header = token ? { 'Authorization': `Bearer ${token}` } : {}
|
||||||
} catch (e) {
|
const res = await uni.request({ url: api('/contribution/companies/hot'), method: 'GET', header })
|
||||||
console.error(e)
|
if (res.statusCode === 200) hotCompanies.value = res.data || []
|
||||||
}
|
} catch (e) { console.error(e) }
|
||||||
},
|
finally { loading.value = false }
|
||||||
difficultyLabel(d) {
|
}
|
||||||
|
|
||||||
|
function difficultyLabel(d) {
|
||||||
const map = { junior: '简单', medium: '中等', senior: '困难' }
|
const map = { junior: '简单', medium: '中等', senior: '困难' }
|
||||||
return map[d] || d || '中等'
|
return map[d] || d || '中等'
|
||||||
},
|
}
|
||||||
async searchCompany() {
|
|
||||||
const kw = this.keyword.trim()
|
function searchCompany() {
|
||||||
|
const kw = keyword.value.trim()
|
||||||
if (!kw) return
|
if (!kw) return
|
||||||
this.selectedCompany = kw
|
selectedCompany.value = kw
|
||||||
this.selectedPosition = ''
|
selectedPosition.value = ''
|
||||||
await this.loadPositions(kw)
|
loadPositions(kw)
|
||||||
},
|
}
|
||||||
async selectCompany(name) {
|
|
||||||
this.selectedCompany = name
|
function selectCompany(name) {
|
||||||
this.keyword = name
|
selectedCompany.value = name
|
||||||
this.selectedPosition = ''
|
keyword.value = name
|
||||||
await this.loadPositions(name)
|
selectedPosition.value = ''
|
||||||
},
|
loadPositions(name)
|
||||||
async loadPositions(company) {
|
}
|
||||||
this.loadingPositions = true
|
|
||||||
|
function backToCompanies() {
|
||||||
|
selectedCompany.value = ''
|
||||||
|
selectedPosition.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadPositions(company) {
|
||||||
|
loadingPositions.value = true
|
||||||
const token = uni.getStorageSync('token') || ''
|
const token = uni.getStorageSync('token') || ''
|
||||||
const header = token ? { 'Authorization': `Bearer ${token}` } : {}
|
const header = token ? { 'Authorization': `Bearer ${token}` } : {}
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({ url: api(`/contribution/company/${encodeURIComponent(company)}`), method: 'GET', header })
|
const res = await uni.request({ url: api(`/contribution/company/${encodeURIComponent(company)}`), method: 'GET', header })
|
||||||
this.positions = res.data || []
|
positions.value = res.data || []
|
||||||
} catch (e) {
|
} catch (e) { positions.value = [] }
|
||||||
this.positions = []
|
finally { loadingPositions.value = false }
|
||||||
}
|
}
|
||||||
this.loadingPositions = false
|
|
||||||
},
|
function selectPosition(position) {
|
||||||
async selectPosition(position) {
|
selectedPosition.value = position
|
||||||
this.selectedPosition = position
|
loadQuestions(selectedCompany.value, position)
|
||||||
await this.loadQuestions(this.selectedCompany, position)
|
}
|
||||||
},
|
|
||||||
async loadQuestions(company, position) {
|
async function loadQuestions(company, position) {
|
||||||
this.loadingQuestions = true
|
loadingQuestions.value = true
|
||||||
const token = uni.getStorageSync('token') || ''
|
const token = uni.getStorageSync('token') || ''
|
||||||
const header = token ? { 'Authorization': `Bearer ${token}` } : {}
|
const header = token ? { 'Authorization': `Bearer ${token}` } : {}
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({
|
const res = await uni.request({
|
||||||
url: api(`/contribution/company/${encodeURIComponent(company)}/position/${encodeURIComponent(position)}`),
|
url: api(`/contribution/company/${encodeURIComponent(company)}/position/${encodeURIComponent(position)}`),
|
||||||
method: 'GET',
|
method: 'GET', header,
|
||||||
header,
|
|
||||||
})
|
})
|
||||||
this.questions = res.data?.questions || []
|
questions.value = res.data?.questions || []
|
||||||
} catch (e) {
|
} catch (e) { questions.value = [] }
|
||||||
this.questions = []
|
finally { loadingQuestions.value = false }
|
||||||
}
|
|
||||||
this.loadingQuestions = false
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page { padding: 20rpx; min-height: 100vh; background: #f5f6f7; }
|
.page { min-height: 100vh; background: var(--color-bg); padding: 20rpx 32rpx 40rpx; }
|
||||||
.search-bar { display: flex; gap: 20rpx; margin-bottom: 30rpx; }
|
|
||||||
.search-input { flex: 1; height: 80rpx; background: #fff; border-radius: 40rpx; padding: 0 30rpx; font-size: 28rpx; }
|
/* 搜索 */
|
||||||
.search-btn { height: 80rpx; line-height: 80rpx; padding: 0 40rpx; background: #4F46E5; color: #fff; border-radius: 40rpx; font-size: 28rpx; }
|
.search-bar { display: flex; gap: 16rpx; margin-bottom: 24rpx; padding-top: 16rpx; }
|
||||||
.section { margin-bottom: 30rpx; background: #fff; border-radius: 16rpx; padding: 30rpx; }
|
.search-inner {
|
||||||
.section-title { font-size: 32rpx; font-weight: 600; margin-bottom: 20rpx; display: block; }
|
flex: 1; height: 76rpx; background: var(--color-surface); border-radius: var(--radius-round);
|
||||||
.section-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20rpx; }
|
display: flex; align-items: center; padding: 0 24rpx; gap: 12rpx;
|
||||||
.back-link { color: #4F46E5; font-size: 26rpx; }
|
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
|
||||||
.company-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20rpx; }
|
}
|
||||||
.company-card { background: #F3F0FF; border-radius: 12rpx; padding: 24rpx; text-align: center; }
|
.search-icon { font-size: 26rpx; }
|
||||||
.company-name { font-size: 28rpx; font-weight: 500; color: #333; }
|
.search-input { flex: 1; font-size: 26rpx; color: var(--color-text); height: 100%; }
|
||||||
.company-count { font-size: 22rpx; color: #999; margin-top: 8rpx; }
|
.search-clear { font-size: 28rpx; color: var(--color-text-tertiary); padding: 8rpx; }
|
||||||
.position-item { padding: 24rpx; border-bottom: 1rpx solid #f0f0f0; }
|
.search-btn {
|
||||||
.position-name { font-size: 28rpx; font-weight: 500; color: #333; }
|
height: 76rpx; line-height: 76rpx; padding: 0 36rpx; background: var(--color-primary);
|
||||||
.position-meta { font-size: 24rpx; color: #999; margin-top: 8rpx; }
|
color: #fff; border-radius: var(--radius-round); font-size: 26rpx; font-weight: 600; flex-shrink: 0;
|
||||||
.question-item { padding: 24rpx; border-bottom: 1rpx solid #f0f0f0; }
|
}
|
||||||
.q-header { display: flex; align-items: center; gap: 12rpx; margin-bottom: 12rpx; }
|
|
||||||
.q-num { font-size: 24rpx; color: #4F46E5; font-weight: 600; }
|
/* 区块 */
|
||||||
.q-tag { font-size: 22rpx; background: #E8F5E9; color: #2E7D32; padding: 2rpx 12rpx; border-radius: 6rpx; }
|
.section { margin-bottom: 24rpx; }
|
||||||
.q-diff { font-size: 22rpx; background: #FFF3E0; color: #E65100; padding: 2rpx 12rpx; border-radius: 6rpx; }
|
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16rpx; }
|
||||||
.q-freq { font-size: 22rpx; color: #999; margin-left: auto; }
|
.section-header-left { display: flex; align-items: center; gap: 16rpx; }
|
||||||
.q-content { font-size: 28rpx; color: #333; line-height: 1.6; }
|
.section-back { font-size: 28rpx; color: var(--color-primary); font-weight: 500; padding: 8rpx 0; }
|
||||||
|
.section-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); }
|
||||||
|
|
||||||
|
/* 公司网格 */
|
||||||
|
.company-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16rpx; }
|
||||||
|
.company-card {
|
||||||
|
padding: 24rpx; border-radius: var(--radius-lg); text-align: center;
|
||||||
|
background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
|
||||||
|
}
|
||||||
|
.company-card:active { opacity: 0.7; }
|
||||||
|
.company-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); display: block; }
|
||||||
|
.company-count { font-size: 20rpx; color: var(--color-text-secondary); margin-top: 8rpx; display: block; }
|
||||||
|
|
||||||
|
/* 岗位列表 */
|
||||||
|
.position-list { display: flex; flex-direction: column; gap: 16rpx; }
|
||||||
|
.pos-item { padding: 24rpx 28rpx; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: space-between; }
|
||||||
|
.pos-item:active { transform: scale(0.98); }
|
||||||
|
.pos-left { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; }
|
||||||
|
.pos-icon { font-size: 36rpx; }
|
||||||
|
.pos-body { flex: 1; min-width: 0; }
|
||||||
|
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
|
||||||
|
.pos-meta { font-size: 22rpx; color: var(--color-text-secondary); margin-top: 4rpx; display: block; }
|
||||||
|
.pos-arrow { font-size: 32rpx; color: var(--color-text-tertiary); flex-shrink: 0; margin-left: 12rpx; }
|
||||||
|
|
||||||
|
/* 题目列表 */
|
||||||
|
.question-list { display: flex; flex-direction: column; gap: 16rpx; }
|
||||||
|
.question-item { padding: 24rpx; border-radius: var(--radius-lg); }
|
||||||
|
.q-header { display: flex; align-items: center; gap: 12rpx; margin-bottom: 12rpx; flex-wrap: wrap; }
|
||||||
|
.q-num { font-size: 22rpx; color: var(--color-primary); font-weight: 700; }
|
||||||
|
.q-tag { font-size: 20rpx; padding: 2rpx 14rpx; border-radius: var(--radius-round); font-weight: 500; }
|
||||||
|
.q-tag-tech { background: #DCFCE7; color: #166534; }
|
||||||
|
.q-tag-behavior { background: #FEF3C7; color: #92400E; }
|
||||||
|
.q-diff { font-size: 20rpx; padding: 2rpx 14rpx; border-radius: var(--radius-round); font-weight: 500; }
|
||||||
|
.q-diff-junior { background: #EEF2FF; color: var(--color-primary); }
|
||||||
|
.q-diff-medium { background: #FEF3C7; color: #92400E; }
|
||||||
|
.q-diff-senior { background: #FEE2E2; color: #991B1B; }
|
||||||
|
.q-freq { font-size: 20rpx; color: var(--color-text-tertiary); margin-left: auto; }
|
||||||
|
.q-content { font-size: 28rpx; color: var(--color-text); line-height: 1.7; }
|
||||||
.q-tags { display: flex; flex-wrap: wrap; gap: 8rpx; margin-top: 12rpx; }
|
.q-tags { display: flex; flex-wrap: wrap; gap: 8rpx; margin-top: 12rpx; }
|
||||||
.tag { font-size: 22rpx; background: #F3F0FF; color: #4F46E5; padding: 4rpx 16rpx; border-radius: 20rpx; }
|
.q-tags .tag { font-size: 20rpx; background: #F3F0FF; color: var(--color-primary); padding: 4rpx 16rpx; border-radius: var(--radius-round); }
|
||||||
.q-answer { margin-top: 16rpx; padding: 16rpx; background: #F8F9FA; border-radius: 8rpx; }
|
.q-answer { margin-top: 16rpx; padding: 20rpx; background: #F9FAFB; border-radius: var(--radius-md); }
|
||||||
.answer-label { font-size: 24rpx; color: #4F46E5; font-weight: 500; }
|
.answer-label { font-size: 22rpx; color: var(--color-primary); font-weight: 600; display: block; margin-bottom: 8rpx; }
|
||||||
.answer-text { font-size: 26rpx; color: #555; line-height: 1.6; }
|
.answer-text { font-size: 24rpx; color: var(--color-text-secondary); line-height: 1.6; }
|
||||||
.empty-state { text-align: center; padding: 60rpx 0; color: #999; font-size: 28rpx; }
|
|
||||||
.sub-text { display: block; margin-top: 12rpx; font-size: 24rpx; color: #bbb; }
|
/* 空状态 */
|
||||||
.loading { text-align: center; padding: 60rpx; color: #999; }
|
.empty { text-align: center; padding: 60rpx 0; background: var(--color-surface); border-radius: var(--radius-lg); }
|
||||||
|
.empty-icon { font-size: 48rpx; display: block; margin-bottom: 12rpx; }
|
||||||
|
.empty-text { font-size: 28rpx; color: var(--color-text-secondary); display: block; }
|
||||||
|
.empty-hint { font-size: 22rpx; color: var(--color-text-tertiary); margin-top: 8rpx; display: block; }
|
||||||
|
|
||||||
|
/* 加载 */
|
||||||
|
.loading-bar { text-align: center; padding: 40rpx; background: var(--color-surface); border-radius: var(--radius-lg); }
|
||||||
|
.loading-text { font-size: 24rpx; color: var(--color-text-tertiary); }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,67 +1,157 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page fade-in">
|
||||||
<view class="hero">
|
<!-- 搜索栏 -->
|
||||||
<text class="hero-title">实习推荐</text>
|
<view class="search-bar">
|
||||||
<text class="hero-sub">热门实习岗位,点击直接模拟面试</text>
|
<view class="search-inner">
|
||||||
|
<text class="search-icon">🔍</text>
|
||||||
|
<input class="search-input" v-model="keyword" placeholder="搜索岗位或公司..." @input="onSearch" />
|
||||||
|
<text class="search-clear" v-if="keyword" @tap="keyword = ''; onSearch()">✕</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="body">
|
<!-- 分类标签 -->
|
||||||
<view class="section-title">🔥 热门实习</view>
|
<view class="tabs">
|
||||||
<view class="position-list card">
|
<view class="tab" :class="tab === 'all' && 'tab-active'" @tap="tab = 'all'; tabIndex = 0">
|
||||||
<view class="pos-item" v-for="(item, idx) in positions" :key="idx" @click="startInterview(item)">
|
<text class="tab-text">全部</text>
|
||||||
|
</view>
|
||||||
|
<view class="tab" :class="tab === 'ai' && 'tab-active'" @tap="tab = 'ai'; tabIndex = 1">
|
||||||
|
<text class="tab-text">🤖 AI 岗位</text>
|
||||||
|
</view>
|
||||||
|
<view class="tab" :class="tab === 'traditional' && 'tab-active'" @tap="tab = 'traditional'; tabIndex = 2">
|
||||||
|
<text class="tab-text">💼 传统岗位</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 结果计数 -->
|
||||||
|
<view class="result-info" v-if="!loading">
|
||||||
|
<text class="result-count">共 {{ filteredPositions.length }} 个岗位</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 岗位列表 -->
|
||||||
|
<view class="position-list">
|
||||||
|
<view class="pos-item card" v-for="(item, idx) in filteredPositions" :key="idx" @click="startInterview(item)">
|
||||||
<view class="pos-left">
|
<view class="pos-left">
|
||||||
<view class="pos-rank">{{ idx + 1 }}</view>
|
<view class="pos-icon-wrap">
|
||||||
|
<text class="pos-icon">{{ item.icon || '💼' }}</text>
|
||||||
|
</view>
|
||||||
<view class="pos-body">
|
<view class="pos-body">
|
||||||
<text class="pos-name">{{ item.name }}</text>
|
<text class="pos-name">{{ item.name }}</text>
|
||||||
|
<view class="pos-meta-row" v-if="item.company">
|
||||||
<text class="pos-company">{{ item.company }}</text>
|
<text class="pos-company">{{ item.company }}</text>
|
||||||
|
<text class="pos-badge" :class="item.category === 'ai' ? 'badge-ai' : 'badge-traditional'">{{ item.category === 'ai' ? 'AI' : '传统' }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="pos-salary">{{ item.salary }}</text>
|
</view>
|
||||||
|
<view class="pos-right">
|
||||||
|
<text class="pos-salary" v-if="item.salary">{{ item.salary }}</text>
|
||||||
|
<text class="pos-action">模拟 ›</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="empty" v-if="!loading && positions.length === 0">
|
<!-- 空状态 -->
|
||||||
<text class="empty-text">暂无实习岗位数据</text>
|
<view class="empty" v-if="!loading && filteredPositions.length === 0">
|
||||||
|
<text class="empty-icon">🔍</text>
|
||||||
|
<text class="empty-text">{{ keyword ? '没有匹配的岗位' : '暂无岗位数据' }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 加载 -->
|
||||||
|
<view class="loading-bar" v-if="loading">
|
||||||
|
<text class="loading-text">加载中...</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { api } from '../../config'
|
import { api } from '../../config'
|
||||||
|
|
||||||
|
const keyword = ref('')
|
||||||
|
const tab = ref('all')
|
||||||
|
const tabIndex = ref(0)
|
||||||
const positions = ref([])
|
const positions = ref([])
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
|
|
||||||
|
const filteredPositions = computed(() => {
|
||||||
|
let list = positions.value
|
||||||
|
if (tab.value !== 'all') {
|
||||||
|
list = list.filter(p => p.category === tab.value)
|
||||||
|
}
|
||||||
|
if (keyword.value.trim()) {
|
||||||
|
const kw = keyword.value.trim().toLowerCase()
|
||||||
|
list = list.filter(p => (p.name && p.name.toLowerCase().includes(kw)) || (p.company && p.company.toLowerCase().includes(kw)))
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await uni.request({ url: api('/positions/hot'), method: 'GET' })
|
const res = await uni.request({ url: api('/positions/hot'), method: 'GET' })
|
||||||
if (res.statusCode === 200) positions.value = res.data || []
|
if (res.statusCode === 200) positions.value = res.data || []
|
||||||
} catch(e) { console.error(e) }
|
} catch (e) { console.error(e) }
|
||||||
finally { loading.value = false }
|
finally { loading.value = false }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function onSearch() { /* reactivity handles filtering via computed */ }
|
||||||
|
|
||||||
const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/interview?position=${encodeURIComponent(pos.name)}` })
|
const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/interview?position=${encodeURIComponent(pos.name)}` })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page { min-height: 100vh; background: var(--color-bg); }
|
.page { min-height: 100vh; background: var(--color-bg); padding: 20rpx 32rpx 40rpx; }
|
||||||
.hero { background: linear-gradient(135deg, var(--color-gradient-start) 0%, var(--color-gradient-mid) 50%, var(--color-gradient-end) 100%); padding: 48rpx 32rpx 72rpx; border-radius: 0 0 48rpx 48rpx; }
|
|
||||||
.hero-title { font-size: 40rpx; font-weight: 700; color: #FFFFFF; display: block; }
|
/* 搜索 */
|
||||||
.hero-sub { font-size: 22rpx; color: rgba(255,255,255,0.7); margin-top: 8rpx; display: block; }
|
.search-bar { padding-top: 16rpx; margin-bottom: 20rpx; }
|
||||||
.body { padding: 32rpx; margin-top: -40rpx; }
|
.search-inner {
|
||||||
.section-title { font-size: 28rpx; font-weight: 600; color: var(--color-text); margin-bottom: 16rpx; }
|
height: 76rpx; background: var(--color-surface); border-radius: var(--radius-round);
|
||||||
.position-list { border-radius: var(--radius-lg); overflow: hidden; }
|
display: flex; align-items: center; padding: 0 24rpx; gap: 12rpx;
|
||||||
.pos-item { padding: 24rpx 28rpx; border-bottom: 1rpx solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
|
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
|
||||||
.pos-item:active { background: #F9FAFB; }
|
}
|
||||||
.pos-item:last-child { border-bottom: none; }
|
.search-icon { font-size: 26rpx; }
|
||||||
.pos-left { display: flex; align-items: center; gap: 16rpx; }
|
.search-input { flex: 1; font-size: 26rpx; color: var(--color-text); height: 100%; }
|
||||||
.pos-rank { width: 40rpx; height: 40rpx; border-radius: 10rpx; background: #F3F4F6; display: flex; align-items: center; justify-content: center; font-size: 22rpx; font-weight: 700; color: var(--color-primary); flex-shrink: 0; }
|
.search-clear { font-size: 28rpx; color: var(--color-text-tertiary); padding: 8rpx; }
|
||||||
.pos-body { display: flex; flex-direction: column; }
|
|
||||||
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
|
/* 分类标签 */
|
||||||
.pos-company { font-size: 22rpx; color: var(--color-text-tertiary); margin-top: 4rpx; }
|
.tabs { display: flex; gap: 12rpx; margin-bottom: 16rpx; }
|
||||||
.pos-salary { font-size: 24rpx; color: var(--color-primary); font-weight: 600; }
|
.tab {
|
||||||
.empty { display: flex; justify-content: center; padding: 60rpx 0; }
|
padding: 12rpx 24rpx; border-radius: var(--radius-round); background: var(--color-surface);
|
||||||
.empty-text { font-size: 26rpx; color: var(--color-text-tertiary); }
|
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
|
||||||
|
}
|
||||||
|
.tab-active { background: var(--color-primary); }
|
||||||
|
.tab-active .tab-text { color: #fff; }
|
||||||
|
.tab-text { font-size: 24rpx; color: var(--color-text-secondary); font-weight: 500; }
|
||||||
|
|
||||||
|
/* 结果信息 */
|
||||||
|
.result-info { margin-bottom: 16rpx; }
|
||||||
|
.result-count { font-size: 22rpx; color: var(--color-text-tertiary); }
|
||||||
|
|
||||||
|
/* 岗位列表 */
|
||||||
|
.position-list { display: flex; flex-direction: column; gap: 16rpx; }
|
||||||
|
.pos-item {
|
||||||
|
padding: 24rpx 28rpx; border-radius: var(--radius-lg);
|
||||||
|
display: flex; align-items: center; justify-content: space-between;
|
||||||
|
}
|
||||||
|
.pos-item:active { transform: scale(0.98); }
|
||||||
|
.pos-left { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; }
|
||||||
|
.pos-icon-wrap { width: 56rpx; height: 56rpx; background: #F3F4F6; border-radius: 14rpx; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
|
||||||
|
.pos-icon { font-size: 28rpx; }
|
||||||
|
.pos-body { flex: 1; min-width: 0; }
|
||||||
|
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); display: block; }
|
||||||
|
.pos-meta-row { display: flex; align-items: center; gap: 10rpx; margin-top: 6rpx; }
|
||||||
|
.pos-company { font-size: 22rpx; color: var(--color-text-tertiary); }
|
||||||
|
.pos-badge { font-size: 18rpx; padding: 2rpx 12rpx; border-radius: var(--radius-round); font-weight: 500; }
|
||||||
|
.badge-ai { background: #FEF3C7; color: #92400E; }
|
||||||
|
.badge-traditional { background: #EEF2FF; color: var(--color-primary); }
|
||||||
|
.pos-right { text-align: right; flex-shrink: 0; margin-left: 16rpx; }
|
||||||
|
.pos-salary { font-size: 24rpx; color: var(--color-primary); font-weight: 600; display: block; margin-bottom: 4rpx; }
|
||||||
|
.pos-action { font-size: 22rpx; color: var(--color-text-tertiary); }
|
||||||
|
|
||||||
|
/* 空状态 */
|
||||||
|
.empty { text-align: center; padding: 80rpx 0; }
|
||||||
|
.empty-icon { font-size: 56rpx; display: block; margin-bottom: 16rpx; }
|
||||||
|
.empty-text { font-size: 28rpx; color: var(--color-text-secondary); }
|
||||||
|
|
||||||
|
/* 加载 */
|
||||||
|
.loading-bar { text-align: center; padding: 60rpx; }
|
||||||
|
.loading-text { font-size: 24rpx; color: var(--color-text-tertiary); }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user