意向字段全部改成使用招聘分类
This commit is contained in:
+11
-11
@@ -447,18 +447,18 @@ const filters = ref<FilterItem[]>([
|
||||
{ label: '城市', key: 'city', selected: '' },
|
||||
{ label: '岗位', key: 'position', selected: '' },
|
||||
{ label: '行业', key: 'industry', selected: '' },
|
||||
{ label: '工作类型', key: 'jobType', selected: '' },
|
||||
{ label: '招聘分类', key: 'jobType', selected: '' },
|
||||
])
|
||||
|
||||
/** 工作类型选项映射:从全局 store 常量统一引入 */
|
||||
/** 招聘分类选项映射:从全局 store 常量统一引入 */
|
||||
const jobTypeOptions = JOB_TYPE_OPTIONS
|
||||
|
||||
/** 工作类型下拉菜单是否显示 */
|
||||
/** 招聘分类下拉菜单是否显示 */
|
||||
const showJobTypeDropdown = ref(false)
|
||||
|
||||
/** 当前选中的工作类型 — 直接读 store.jobIntention.employmentType */
|
||||
/** 当前选中的招聘分类 — 直接读 store.jobIntention.recruitCategory */
|
||||
const selectedEmploymentType = computed<number | null>(
|
||||
() => store.state.jobIntention.employmentType ?? null,
|
||||
() => store.state.jobIntention.recruitCategory ?? null,
|
||||
)
|
||||
|
||||
/** 选中的行业 id 数组 — 直接读 store.jobIntention.industryIds */
|
||||
@@ -500,24 +500,24 @@ function onRegionChange(codes: string[]) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 点击筛选条件按钮 — 仅工作类型展开下拉 */
|
||||
/** 点击筛选条件按钮 — 仅招聘分类展开下拉 */
|
||||
function handleFilterClick(filter: FilterItem) {
|
||||
if (filter.key === 'jobType') {
|
||||
showJobTypeDropdown.value = !showJobTypeDropdown.value
|
||||
}
|
||||
}
|
||||
|
||||
/** 选中工作类型选项 */
|
||||
/** 选中招聘分类选项 */
|
||||
function selectJobType(filter: FilterItem, option: { label: string; value: number }) {
|
||||
filter.selected = option.label
|
||||
showJobTypeDropdown.value = false
|
||||
store.dispatch('saveJobIntention', {
|
||||
...store.state.jobIntention,
|
||||
employmentType: option.value,
|
||||
recruitCategory: option.value,
|
||||
})
|
||||
}
|
||||
|
||||
/** 监听 store 中 employmentType 变化,同步工作类型筛选按钮的显示文字 */
|
||||
/** 监听 store 中 recruitCategory 变化,同步招聘分类筛选按钮的显示文字 */
|
||||
watch(selectedEmploymentType, (val) => {
|
||||
const jobTypeFilter = filters.value.find(f => f.key === 'jobType')
|
||||
if (jobTypeFilter && val !== null) {
|
||||
@@ -765,9 +765,9 @@ function buildParams(): JobListParams {
|
||||
if (selectedIndustryIds.value.length) {
|
||||
params.industryIds = selectedIndustryIds.value
|
||||
}
|
||||
// 工作类型筛选
|
||||
// 招聘分类筛选
|
||||
if (selectedEmploymentType.value !== null) {
|
||||
params.employmentType = selectedEmploymentType.value
|
||||
params.recruitCategory = selectedEmploymentType.value
|
||||
}
|
||||
// 搜索关键词
|
||||
if (keyword.value.trim()) {
|
||||
|
||||
+29
-47
@@ -109,17 +109,25 @@
|
||||
<span v-else-if="idx === otpValue.length && !isLoggingIn" class="login-view__otp-cursor"></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 状态按钮(非触发登录) -->
|
||||
<button class="login-view__status-btn" disabled>
|
||||
<!-- 状态按钮 — 三种状态:登录中 / 倒计时 / 再次发送 -->
|
||||
<button
|
||||
class="login-view__status-btn"
|
||||
:disabled="isLoggingIn || countdown > 0"
|
||||
@click="handleResendCode"
|
||||
>
|
||||
<!-- 登录中状态 -->
|
||||
<template v-if="isLoggingIn">
|
||||
<span class="login-view__spinner"></span>
|
||||
<span>登录中</span>
|
||||
</template>
|
||||
<!-- 倒计时状态 -->
|
||||
<template v-else>
|
||||
<template v-else-if="countdown > 0">
|
||||
{{ countdown }} 秒后可继续发送
|
||||
</template>
|
||||
<!-- 可再次发送 -->
|
||||
<template v-else>
|
||||
再次发送验证码
|
||||
</template>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@@ -170,14 +178,6 @@ const countdown = ref(0)
|
||||
let countdownTimer: ReturnType<typeof setInterval> | null = null
|
||||
/** 是否正在调用登录接口 */
|
||||
const isLoggingIn = ref(false)
|
||||
/** 用户最后一次输入验证码的时间戳 */
|
||||
let lastOtpInputTime = 0
|
||||
/** 倒计时结束后等待用户输入冷却的定时器 */
|
||||
let returnWaitTimer: ReturnType<typeof setTimeout> | null = null
|
||||
/** 延长倒计时的定时器(每秒递减) */
|
||||
let extendTimer: ReturnType<typeof setInterval> | null = null
|
||||
/** 标记60秒倒计时已结束,等待返回中 */
|
||||
let countdownFinished = false
|
||||
/** OTP 输入框引用 */
|
||||
const otpInputRef = ref<HTMLInputElement | null>(null)
|
||||
|
||||
@@ -207,33 +207,6 @@ function startCountdown() {
|
||||
if (countdown.value <= 0 && countdownTimer) {
|
||||
clearInterval(countdownTimer)
|
||||
countdownTimer = null
|
||||
// 倒计时结束,进入"即将返回"提示阶段
|
||||
triggerReturn()
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
/** 倒计时结束后的返回逻辑 — 考虑用户最近操作 */
|
||||
function triggerReturn() {
|
||||
countdownFinished = true
|
||||
scheduleReturn()
|
||||
}
|
||||
|
||||
/** 安排返回:用户停止输入5秒后回步骤一,每次输入都重置5秒 */
|
||||
function scheduleReturn() {
|
||||
// 清除之前所有定时器,重新开始5秒倒计时
|
||||
if (returnWaitTimer) { clearTimeout(returnWaitTimer); returnWaitTimer = null }
|
||||
if (extendTimer) { clearInterval(extendTimer); extendTimer = null }
|
||||
|
||||
// 直接重置为5秒倒计时
|
||||
countdown.value = 5
|
||||
extendTimer = setInterval(() => {
|
||||
countdown.value--
|
||||
if (countdown.value <= 0) {
|
||||
if (extendTimer) { clearInterval(extendTimer); extendTimer = null }
|
||||
countdownFinished = false
|
||||
step.value = 1
|
||||
otpValue.value = ''
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
@@ -276,21 +249,30 @@ async function handleSendCode() {
|
||||
function handleOtpInput() {
|
||||
// 过滤非数字字符
|
||||
otpValue.value = otpValue.value.replace(/\D/g, '').slice(0, 6)
|
||||
// 记录用户最后输入时间
|
||||
lastOtpInputTime = Date.now()
|
||||
// 如果倒计时已结束且用户还在输入(未满6位),重新安排返回计时
|
||||
if (countdownFinished && otpValue.value.length < 6) {
|
||||
scheduleReturn()
|
||||
}
|
||||
// 满6位自动触发登录
|
||||
if (otpValue.value.length === 6) {
|
||||
// 取消返回流程
|
||||
if (returnWaitTimer) { clearTimeout(returnWaitTimer); returnWaitTimer = null }
|
||||
if (extendTimer) { clearInterval(extendTimer); extendTimer = null }
|
||||
handleLogin()
|
||||
}
|
||||
}
|
||||
|
||||
/** 步骤二:再次发送验证码 */
|
||||
async function handleResendCode() {
|
||||
if (isLoggingIn.value || countdown.value > 0) return
|
||||
try {
|
||||
const res = await sendSmsCode(phone.value)
|
||||
if (res.code === '0') {
|
||||
ElMessage.success('验证码已发送')
|
||||
otpValue.value = ''
|
||||
startCountdown()
|
||||
nextTick(() => focusOtpInput())
|
||||
} else {
|
||||
ElMessage.error(res.msg || '验证码发送失败')
|
||||
}
|
||||
} catch {
|
||||
// 错误已在 request 拦截器中统一处理
|
||||
}
|
||||
}
|
||||
|
||||
/** 调用登录接口 */
|
||||
async function handleLogin() {
|
||||
isLoggingIn.value = true
|
||||
|
||||
Reference in New Issue
Block a user