refactor(login): move match-route logic to dedicated service and fix import
- 提取登录回跳、产品对比的路由匹配逻辑至独立的 match-route.uts 服务 - 修复登录页面导入对比服务的错误,改为导入新的 match-route 模块 - 保持原有的路由参数校验和跳转逻辑不变,仅重构代码结构
This commit is contained in:
@@ -1,34 +1,28 @@
|
||||
<template>
|
||||
<view class="page" :style="pageStyle()">
|
||||
<AppHeader title="本次融资匹配" :customBack="true" @back="back" />
|
||||
<AppHeader title="AI匹配结果" :customBack="true" @back="back" />
|
||||
<scroll-view scroll-y :style="contentStyle(96, false)">
|
||||
<view v-if="pageActive" class="content">
|
||||
<text class="eyebrow">评估记录 {{ assessmentId.length > 0 ? '#' + assessmentId : '待选择' }}</text>
|
||||
<text class="headline">找到适合本次需求的方向</text>
|
||||
<text class="intro">每项结论都有依据。自填资料尚未核验,匹配结果不代表审批。</text>
|
||||
<view class="summary-card"><text class="summary-title">{{ summaryTitle }}</text><text class="summary-note">依据本次资料筛选 · 查看产品了解具体条件</text></view>
|
||||
<view v-if="assessmentId.length == 0 && error.length == 0" class="state-panel"><text class="state-title">先选择一份评估</text><text class="muted">从融资档案查看已完成的评估,再获取对应匹配结果。</text><button class="primary" @click="history">选择历史评估</button><button class="secondary" @click="start">开始新评估</button></view>
|
||||
<template v-else>
|
||||
<view class="tabs">
|
||||
<view v-for="item in groups" :key="item.id" :class="group == item.id ? 'tab chosen' : 'tab'" @click="selectGroup(item.id)"><text :class="group == item.id ? 'tab-label selected' : 'tab-label'">{{ item.label }}</text><text class="count">{{ count(item.id) }}</text></view>
|
||||
</view>
|
||||
<text v-if="message.length > 0" class="muted notice">{{ message }}</text>
|
||||
<view v-if="error.length == 0 && assessmentId.length > 0" class="compare-bar"><text class="compare-caption">已选 {{ selectedIds.length }} / 3 项,可跨分组选择</text><button class="compare-button" :disabled="selectedIds.length < 2" @click="openCompare">对比所选产品</button></view>
|
||||
<text v-if="loading && matches.length == 0" class="state-copy">正在读取本次匹配结果…</text>
|
||||
<view v-if="error.length > 0" class="state-panel"><text class="state-title">暂时无法读取</text><text class="muted">{{ error }}</text><button class="secondary" @click="retry">重新加载</button><text class="link" @click="history">返回融资档案</text></view>
|
||||
<view v-if="pageError.length > 0" class="state-panel"><text class="muted">{{ pageError }}</text><button class="secondary" :disabled="loading" @click="loadMore">重试加载更多</button></view>
|
||||
<view v-if="!loading && error.length == 0 && matches.length == 0" class="state-panel"><text class="state-title">{{ status == 'unavailable' ? '本次未执行匹配' : (group == 'eligible' ? '暂无符合已知条件的产品' : (group == 'ineligible' ? '暂无条件不符的产品' : '暂无待核实的产品')) }}</text><text class="muted">{{ status == 'unavailable' ? '历史结果不会自动补算。可从融资档案发起新的评估。' : '可切换分组查看其他结果,或返回报告了解资料准备情况。' }}</text><text class="link" @click="report">查看本次报告</text></view>
|
||||
<view v-for="item in matches" :key="item.id" class="card" @click="openProduct(item.id)">
|
||||
<view class="card-head"><view class="mark"><text class="mark-text">融</text></view><view class="identity"><text class="name">{{ item.product.name }}</text><text class="bank">{{ item.product.bank }} · {{ item.product.objects }}</text></view></view>
|
||||
<view class="badge-row"><text :class="item.state == 'eligible' ? 'badge good' : (item.state == 'ineligible' ? 'badge blocked' : 'badge pending')">{{ item.stateLabel }}</text></view>
|
||||
<view class="amount-row"><text class="amount">{{ item.product.amount }}</text><text class="caption">产品额度范围</text></view>
|
||||
<view class="metrics"><view class="metric"><text class="value">{{ item.product.rate }}</text><text class="caption">年化利率范围</text></view><view class="metric"><text class="value">{{ item.product.term }}</text><text class="caption">期限范围</text></view></view>
|
||||
<view class="reasons"><text class="reason" v-for="reason in preview(item)" :key="reason.id">{{ reason.text }}</text></view>
|
||||
<view class="card-head"><view :class="bankMarkClass(item.product.bank)"><text class="mark-text">{{ item.product.bank.slice(0, 1) }}</text></view><view class="identity"><text class="bank-name">{{ item.product.bank }}</text><text class="product-name">{{ item.product.name }}</text></view><text :class="item.state == 'eligible' ? 'match-state good' : (item.state == 'ineligible' ? 'match-state blocked' : 'match-state pending')">{{ item.stateLabel }}</text><text class="card-arrow">›</text></view>
|
||||
<view class="tags"><text class="tag">年化 {{ item.product.rate }}</text><text class="tag">{{ item.product.term }}</text><text class="tag">{{ item.product.objects }}</text></view>
|
||||
<text v-if="item.availability != 'available'" class="availability">{{ item.availabilityLabel }};历史结果仍可查看。</text>
|
||||
<view class="card-foot"><text class="version">评估时版本 v{{ item.product.version }}</text><text class="detail-link">查看依据与详情 ›</text></view>
|
||||
<button class="choose-button" @click.stop="toggleCompare(item.id)">{{ selectedIds.includes(item.id) ? '已加入对比 · 点击移除' : '加入对比' }}</button>
|
||||
<view class="card-foot"><text class="detail-link">查看匹配依据</text><view class="choose-control" @click.stop="toggleCompare(item.id)"><text :class="selectedIds.includes(item.id) ? 'selection-box selected-box' : 'selection-box'">{{ selectedIds.includes(item.id) ? '✓' : '+' }}</text><text class="choose-label">{{ selectedIds.includes(item.id) ? '已选对比' : '加入对比' }}</text></view></view>
|
||||
</view>
|
||||
<button v-if="hasMore && pageError.length == 0" class="secondary" :disabled="loading" @click="loadMore">{{ loading ? '正在加载…' : '查看更多' }}</button>
|
||||
<button v-if="hasMore && pageError.length == 0" class="more-button" :disabled="loading" @click="loadMore">{{ loading ? '正在加载…' : '查看更多产品(共' + count(group) + '项)' }}</button>
|
||||
<view v-if="error.length == 0 && matches.length > 0" class="compare-bar"><text class="compare-caption">已选 {{ selectedIds.length }} / 3 项</text><button class="compare-button" :disabled="selectedIds.length < 2" @click="openCompare">对比所选产品</button></view>
|
||||
<text v-if="matches.length > 0 && !hasMore" class="end-note">已显示本组全部结果 · 顺序不代表产品优劣</text>
|
||||
<text v-if="message.length > 0" class="muted notice">{{ message }}</text>
|
||||
<text class="link" @click="report">返回本次报告</text>
|
||||
</template>
|
||||
</view>
|
||||
@@ -39,7 +33,7 @@
|
||||
import AppHeader from '@/components/AppHeader.uvue'
|
||||
import { usePageLayout } from '@/services/layout.uts'
|
||||
import { getSession } from '@/services/api.uts'
|
||||
import { MatchView, MatchReason, MatchPage, fetchMatchPage, validRecordId } from '@/packages/finance/services/matches.uts'
|
||||
import { MatchView, MatchPage, fetchMatchPage, validRecordId } from '@/packages/finance/services/matches.uts'
|
||||
import { parseCompareIds, compareSelection, saveCompareSelection, compareQuery, matchReturnPath } from '@/packages/finance/services/compare.uts'
|
||||
const { pageStyle, contentStyle } = usePageLayout()
|
||||
type MatchGroup = { id: string, label: string }
|
||||
@@ -52,7 +46,14 @@
|
||||
let cursor = ''; let generation = 0; let visible = false; let routeError = ''; let owner = ''
|
||||
let firstPage: MatchPage | null = null; let accountTimer = 0
|
||||
const count = (id: string): string => id == 'eligible' ? eligible.value : (id == 'ineligible' ? ineligible.value : unknown.value)
|
||||
const preview = (item: MatchView): MatchReason[] => item.state == 'ineligible' ? item.blocking.slice(0, 3) : (item.state == 'unknown' ? item.cautions.slice(0, 3) : item.positive.slice(0, 3))
|
||||
const summaryTitle = computed((): string => {
|
||||
if (assessmentId.value.length == 0) return '选择评估,查看融资匹配'
|
||||
if (error.value.length > 0) return '匹配结果暂不可读取'
|
||||
if (status.value == 'unavailable') return '这份报告尚未执行产品匹配'
|
||||
if (eligible.value == '—') return '正在为你读取匹配结果'
|
||||
return eligible.value == '0' ? '暂未筛选出符合已知条件的产品' : '为你筛选出' + eligible.value + '项符合已知条件的产品'
|
||||
})
|
||||
const bankMarkClass = (bank: string): string => bank.includes('工商') || bank.includes('招商') || bank.includes('中国银行') ? 'mark mark-red' : (bank.includes('农业') || bank.includes('邮储') ? 'mark mark-green' : 'mark mark-blue')
|
||||
const clear = () => { matches.value = []; message.value = ''; status.value = ''; pageError.value = ''; hasMore.value = false; cursor = ''; firstPage = null; eligible.value = '—'; ineligible.value = '—'; unknown.value = '—' }
|
||||
const stopAccountTimer = () => { if (accountTimer != 0) clearInterval(accountTimer); accountTimer = 0 }
|
||||
const login = () => { uni.redirectTo({ url: '/packages/account/login/login?resumeMatch=1&matchPage=matches' + compareQuery(assessmentId.value, selectedIds.value, revisionId.value).replace('?', '&') + '&group=' + group.value }) }
|
||||
@@ -130,34 +131,46 @@
|
||||
onUnload(() => { visible = false; pageActive.value = false; stopAccountTimer(); generation++; clear() })
|
||||
</script>
|
||||
<style>
|
||||
.compare-bar { background-color: #fff; border-radius: 16rpx; padding: 20rpx; margin-bottom: 22rpx; }
|
||||
.page { background-color: #fff; }
|
||||
.summary-card { background-color: #edf5ff; padding: 28rpx 26rpx; border-radius: 10rpx; }
|
||||
.summary-title { color: #1a5aa8; font-size: 31rpx; line-height: 47rpx; font-weight: 600; }
|
||||
.summary-note { color: #7188a4; font-size: 22rpx; line-height: 35rpx; margin-top: 9rpx; }
|
||||
.compare-bar { flex-direction: row; align-items: center; justify-content: space-between; border-top: 1rpx solid #edf1f6; padding: 20rpx 0; margin-top: 20rpx; }
|
||||
.compare-caption { color: #506c8b; font-size: 24rpx; }
|
||||
.compare-button { background-color: #0868f7; color: #fff; font-size: 25rpx; margin-top: 14rpx; border-radius: 12rpx; }
|
||||
.choose-button { color: #0868f7; background-color: #eef5ff; font-size: 24rpx; margin-top: 22rpx; border-radius: 12rpx; }
|
||||
.compare-button { background-color: #0868f7; color: #fff; font-size: 24rpx; border-radius: 10rpx; margin: 0; padding: 0 22rpx; }
|
||||
.content { padding: 30rpx 28rpx 60rpx; }
|
||||
.eyebrow { font-size: 22rpx; color: #61758f; }
|
||||
.headline { font-size: 37rpx; font-weight: 700; color: #142d4e; margin-top: 14rpx; }
|
||||
.intro { font-size: 24rpx; line-height: 38rpx; color: #718198; margin-top: 14rpx; }
|
||||
.tabs { flex-direction: row; background-color: #fff; border-radius: 16rpx; padding: 8rpx; margin-top: 28rpx; }
|
||||
.tab { flex: 1; align-items: center; padding: 17rpx 2rpx; border-radius: 12rpx; }
|
||||
.tabs { flex-direction: row; background-color: #f7f9fc; border-radius: 10rpx; padding: 6rpx; margin-top: 24rpx; margin-bottom: 24rpx; }
|
||||
.tab { flex: 1; flex-direction: row; align-items: center; justify-content: center; padding: 15rpx 2rpx; border-radius: 8rpx; }
|
||||
.chosen { background-color: #eaf3ff; }
|
||||
.tab-label { font-size: 24rpx; color: #6e7e93; }
|
||||
.selected { color: #0868f7; font-weight: 700; }
|
||||
.count { font-size: 31rpx; color: #223d60; margin-top: 8rpx; font-weight: 700; }
|
||||
.count { font-size: 24rpx; color: #61768e; margin-left: 8rpx; }
|
||||
.muted { font-size: 24rpx; line-height: 39rpx; color: #758399; }
|
||||
.notice { margin: 20rpx 4rpx; }
|
||||
.card { padding: 28rpx; background-color: #fff; border: 1rpx solid #e5edf7; border-radius: 20rpx; margin-bottom: 22rpx; }
|
||||
.card { padding: 24rpx 22rpx 18rpx; background-color: #fff; border: 1rpx solid #e2e8ef; border-radius: 10rpx; margin-bottom: 20rpx; }
|
||||
.card-head { flex-direction: row; align-items: center; }
|
||||
.mark { width: 70rpx; height: 70rpx; background-color: #eaf3ff; border-radius: 16rpx; align-items: center; justify-content: center; margin-right: 18rpx; flex-shrink: 0; }
|
||||
.mark-text { font-size: 32rpx; color: #0868f7; font-weight: 700; }
|
||||
.mark { width: 66rpx; height: 66rpx; border-radius: 33rpx; align-items: center; justify-content: center; margin-right: 16rpx; flex-shrink: 0; }
|
||||
.mark-blue { background-color: #edf4fd; }
|
||||
.mark-red { background-color: #fcedef; }
|
||||
.mark-green { background-color: #eaf6f1; }
|
||||
.mark-text { font-size: 30rpx; color: #2765ad; font-weight: 700; }
|
||||
.mark-red .mark-text { color: #b84554; }
|
||||
.mark-green .mark-text { color: #28856b; }
|
||||
.identity { flex: 1; }
|
||||
.name { font-size: 29rpx; line-height: 42rpx; color: #203652; font-weight: 700; }
|
||||
.bank { font-size: 22rpx; color: #7a899d; line-height: 34rpx; margin-top: 6rpx; }
|
||||
.bank-name { font-size: 28rpx; line-height: 40rpx; color: #24354b; font-weight: 600; }
|
||||
.product-name { font-size: 22rpx; color: #7a899d; line-height: 34rpx; margin-top: 3rpx; }
|
||||
.match-state { font-size: 20rpx; line-height: 30rpx; max-width: 140rpx; flex-shrink: 0; text-align: right; margin-left: 10rpx; }
|
||||
.card-arrow { font-size: 38rpx; color: #a3aebe; margin-left: 12rpx; }
|
||||
.tags { flex-direction: row; flex-wrap: wrap; margin-top: 18rpx; }
|
||||
.tag { background-color: #f2f5f9; color: #718197; font-size: 20rpx; line-height: 30rpx; padding: 4rpx 10rpx; border-radius: 4rpx; margin-right: 8rpx; margin-bottom: 6rpx; }
|
||||
.badge-row { flex-direction: row; align-items: center; margin-top: 20rpx; }
|
||||
.badge { padding: 8rpx 16rpx; border-radius: 8rpx; font-size: 22rpx; }
|
||||
.good { color: #187857; background-color: #eaf7f1; }
|
||||
.blocked { color: #ae593d; background-color: #fff0e9; }
|
||||
.pending { color: #9a7320; background-color: #fff8e5; }
|
||||
.good { color: #187857; }
|
||||
.blocked { color: #ae593d; }
|
||||
.pending { color: #9a7320; }
|
||||
.demo { font-size: 21rpx; margin-left: 14rpx; color: #78879b; }
|
||||
.amount-row { margin-top: 26rpx; }
|
||||
.amount { font-size: 38rpx; font-weight: 700; color: #123a6c; line-height: 54rpx; }
|
||||
@@ -168,9 +181,14 @@
|
||||
.reasons { margin-top: 22rpx; border-top: 1rpx solid #edf2f8; padding-top: 12rpx; }
|
||||
.reason { font-size: 23rpx; line-height: 37rpx; color: #60758e; margin-top: 8rpx; }
|
||||
.availability { font-size: 23rpx; line-height: 37rpx; color: #a87534; margin-top: 12rpx; }
|
||||
.card-foot { flex-direction: row; justify-content: space-between; margin-top: 24rpx; }
|
||||
.card-foot { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 10rpx; }
|
||||
.version { font-size: 21rpx; color: #98a3b2; }
|
||||
.detail-link { font-size: 23rpx; color: #0868f7; }
|
||||
.detail-link { font-size: 20rpx; color: #8c99aa; }
|
||||
.choose-control { flex-direction: row; align-items: center; padding: 5rpx 0 5rpx 12rpx; }
|
||||
.selection-box { width: 28rpx; height: 28rpx; text-align: center; line-height: 26rpx; border: 1rpx solid #c3d4e9; border-radius: 6rpx; color: #527ba9; font-size: 22rpx; }
|
||||
.selected-box { background-color: #0868f7; color: #fff; border-color: #0868f7; }
|
||||
.choose-label { font-size: 21rpx; color: #527ba9; margin-left: 8rpx; }
|
||||
.more-button { background-color: #0868f7; color: #fff; font-size: 24rpx; border-radius: 10rpx; margin-top: 6rpx; }
|
||||
.state-panel { padding: 42rpx 28rpx; background-color: #fff; border-radius: 18rpx; margin-top: 24rpx; }
|
||||
.state-title { font-size: 30rpx; font-weight: 700; color: #273f5f; margin-bottom: 16rpx; }
|
||||
.state-copy { padding: 40rpx 12rpx; font-size: 26rpx; color: #73839a; }
|
||||
|
||||
Reference in New Issue
Block a user