fix(assessment): 移除信息填写页进行中测评记录恢复功能

- 移除 getPendingRecord API 调用和相关弹窗
- 移除 isContinueMode 计算属性和表单禁用逻辑
- 移除断点续答相关的函数和样式
- 每次进入信息填写页都是全新填写
This commit is contained in:
zpc 2026-02-23 01:16:24 +08:00
parent b8fe6fc9b0
commit 0cbd9d4745
2 changed files with 10 additions and 163 deletions

View File

@ -15,7 +15,7 @@ import { onLoad, onUnload } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/user.js'
import { useAuth } from '@/composables/useAuth.js'
import { usePayment } from '@/composables/usePayment.js'
import { getIntro, verifyInviteCode, getPendingRecord } from '@/api/assessment.js'
import { getIntro, verifyInviteCode } from '@/api/assessment.js'
import { createOrder } from '@/api/order.js'
import { isPhone } from '@/utils/validate.js'
import Navbar from '@/components/Navbar/index.vue'
@ -64,21 +64,6 @@ function getEducationStageValue(label) {
return map[label] || 1
}
/**
* 数值转学业阶段文本
*/
function getEducationStageLabel(value) {
const map = { 1: '小学及以下', 2: '初中', 3: '高中', 4: '大专' }
return map[value] || ''
}
/**
* 数值转性别文本
*/
function getGenderLabel(value) {
return value === 1 ? '男' : value === 2 ? '女' : ''
}
//
const genderIndex = ref(-1)
const ageIndex = ref(-1)
@ -95,10 +80,6 @@ const inviteLoading = ref(false)
//
const pageLoading = ref(true)
//
const pendingRecord = ref(null)
const showPendingPopup = ref(false)
// key
const STORAGE_KEY = 'assessment_info_form'
@ -177,16 +158,10 @@ const isFormComplete = computed(() => {
)
})
/**
* 是否处于继续上次测评模式
*/
const isContinueMode = computed(() => pendingRecord.value !== null)
/**
* 底部按钮文案
*/
const payBtnText = computed(() => {
if (isContinueMode.value) return '开始答题'
return `支付¥${introData.value.price || 20}元开始测评`
})
@ -212,56 +187,6 @@ async function loadIntro() {
}
}
/**
* 检查是否有进行中的测评记录
*/
async function checkPendingRecord() {
if (!userStore.isLoggedIn) return
try {
const res = await getPendingRecord(typeId.value)
if (res && res.code === 0 && res.data) {
pendingRecord.value = res.data
showPendingPopup.value = true
}
} catch (error) {
console.error('查询进行中测评记录失败:', error)
}
}
/**
* 用户选择继续上次测评
*/
function handleContinuePending() {
showPendingPopup.value = false
const record = pendingRecord.value
//
formData.value.name = record.name || ''
formData.value.phone = record.phone || ''
formData.value.gender = getGenderLabel(record.gender)
formData.value.age = record.age ? `${record.age}` : ''
formData.value.educationStage = getEducationStageLabel(record.educationStage)
formData.value.province = record.province || ''
formData.value.city = record.city || ''
formData.value.district = record.district || ''
//
genderIndex.value = record.gender === 1 ? 0 : record.gender === 2 ? 1 : -1
ageIndex.value = record.age ? record.age - 10 : -1
const eduIdx = educationOptions.indexOf(getEducationStageLabel(record.educationStage))
educationIndex.value = eduIdx >= 0 ? eduIdx : -1
regionValue.value = [record.province || '', record.city || '', record.district || '']
}
/**
* 用户选择不继续上次测评
*/
function handleDismissPending() {
showPendingPopup.value = false
pendingRecord.value = null
}
/** 性别选择 */
function onGenderChange(e) {
genderIndex.value = e.detail.value
@ -334,19 +259,9 @@ function buildAssessmentInfo() {
}
}
/** 支付测评 / 继续上次测评 */
/** 支付测评 */
async function handlePayAssessment() {
if (!checkLogin()) return
//
if (isContinueMode.value) {
clearFormStorage()
uni.redirectTo({
url: `/pages/assessment/questions/index?typeId=${typeId.value}&recordId=${pendingRecord.value.recordId}`
})
return
}
if (!validateForm()) return
try {
@ -459,8 +374,6 @@ onLoad((options) => {
}
loadIntro()
//
checkPendingRecord()
})
/** 页面卸载时保存 */
@ -490,7 +403,7 @@ onUnload(() => {
<!-- 表单卡片 -->
<view class="form-card">
<view class="form-tip">
{{ isContinueMode ? '您有一次未完成的测评,信息已自动填充' : '正式测评前,请先填写您的基本信息' }}
正式测评前请先填写您的基本信息
</view>
<!-- 姓名 -->
@ -503,7 +416,6 @@ onUnload(() => {
placeholder-class="input-placeholder"
v-model="formData.name"
maxlength="20"
:disabled="isContinueMode"
/>
</view>
</view>
@ -518,7 +430,6 @@ onUnload(() => {
placeholder-class="input-placeholder"
v-model="formData.phone"
maxlength="11"
:disabled="isContinueMode"
/>
</view>
</view>
@ -526,7 +437,7 @@ onUnload(() => {
<!-- 性别 -->
<view class="form-item">
<view class="form-label"><text class="required">*</text>性别</view>
<picker mode="selector" :range="genderOptions" @change="onGenderChange" :disabled="isContinueMode">
<picker mode="selector" :range="genderOptions" @change="onGenderChange">
<view class="form-select-box">
<text :class="formData.gender ? 'select-value' : 'select-placeholder'">
{{ formData.gender || '请选择' }}
@ -539,7 +450,7 @@ onUnload(() => {
<!-- 年龄 -->
<view class="form-item">
<view class="form-label"><text class="required">*</text>年龄</view>
<picker mode="selector" :range="ageOptions" @change="onAgeChange" :disabled="isContinueMode">
<picker mode="selector" :range="ageOptions" @change="onAgeChange">
<view class="form-select-box">
<text :class="formData.age ? 'select-value' : 'select-placeholder'">
{{ formData.age || '请选择' }}
@ -552,7 +463,7 @@ onUnload(() => {
<!-- 学业阶段 -->
<view class="form-item">
<view class="form-label"><text class="required">*</text>学业阶段</view>
<picker mode="selector" :range="educationOptions" @change="onEducationChange" :disabled="isContinueMode">
<picker mode="selector" :range="educationOptions" @change="onEducationChange">
<view class="form-select-box">
<text :class="formData.educationStage ? 'select-value' : 'select-placeholder'">
{{ formData.educationStage || '请选择' }}
@ -565,7 +476,7 @@ onUnload(() => {
<!-- 所在城市 -->
<view class="form-item form-item-last">
<view class="form-label"><text class="required">*</text>所在城市</view>
<picker mode="region" @change="onRegionChange" :disabled="isContinueMode">
<picker mode="region" @change="onRegionChange">
<view class="form-region-row">
<view class="region-box">
<text :class="formData.province ? 'select-value' : 'select-placeholder'">
@ -592,41 +503,14 @@ onUnload(() => {
<!-- 底部按钮 -->
<view class="btn-group">
<view v-if="!isContinueMode" class="btn-invite" @click="openInvitePopup">
<view class="btn-invite" @click="openInvitePopup">
<text>邀请码免费测评</text>
</view>
<view class="btn-pay" :class="{ 'btn-full': isContinueMode }" @click="handlePayAssessment">
<view class="btn-pay" @click="handlePayAssessment">
<text>{{ payBtnText }}</text>
</view>
</view>
<!-- 进行中测评弹窗 -->
<view v-if="showPendingPopup" class="popup-mask" @click="handleDismissPending">
<view class="popup-container" @click.stop>
<view class="popup-header">
<text class="popup-title">提示</text>
<view class="popup-close" @click="handleDismissPending">
<text>×</text>
</view>
</view>
<view class="popup-body">
<view class="pending-msg">您有一次未完成的测评是否继续上次的测评</view>
<view class="pending-info">
<text>姓名{{ pendingRecord?.name }}</text>
<text>手机号{{ pendingRecord?.phone }}</text>
</view>
</view>
<view class="popup-footer pending-footer">
<view class="popup-btn-outline" @click="handleDismissPending">
<text>重新开始</text>
</view>
<view class="popup-btn" @click="handleContinuePending">
<text>继续测评</text>
</view>
</view>
</view>
</view>
<!-- 邀请码弹窗 -->
<view v-if="showInvitePopup" class="popup-mask" @click="closeInvitePopup">
<view class="popup-container" @click.stop>
@ -866,10 +750,6 @@ onUnload(() => {
&:active {
opacity: 0.8;
}
&.btn-full {
flex: 1;
}
}
// ========== ==========
@ -975,38 +855,6 @@ onUnload(() => {
}
}
// ========== ==========
.pending-msg {
font-size: $font-size-md;
color: $text-color;
text-align: center;
margin-bottom: $spacing-lg;
}
.pending-info {
display: flex;
flex-direction: column;
gap: $spacing-sm;
padding: $spacing-md $spacing-lg;
background-color: $bg-gray;
border-radius: $border-radius-md;
text {
font-size: $font-size-sm;
color: $text-secondary;
}
}
.pending-footer {
display: flex;
gap: $spacing-md;
.popup-btn-outline,
.popup-btn {
flex: 1;
}
}
// ========== ==========
.invite-input {
width: 100%;

View File

@ -90,8 +90,7 @@
<Loading type="inline" :loading="true" />
</view>
<!-- 底部安全区域 -->
<view class="safe-bottom"></view>
</scroll-view>
</view>
</template>