flat: bug修复

This commit is contained in:
Apcallover
2025-12-25 12:52:54 +08:00
parent ef669f23be
commit 8280cc9fae
5 changed files with 305 additions and 55 deletions

View File

@@ -1,15 +1,8 @@
<template>
<AppLayout title="就业服务程序">
<AppLayout :title="pageTitle">
<view v-if="isMachineEnv && !hasLogin" class="alipay-login-container">
<!-- 切换 -->
<view class="login-method-switch">
<view
class="method-item"
:class="{ active: loginMethod === 'face' }"
@click="switchLoginMethod('face')"
>
扫脸登录
</view>
<view
class="method-item"
:class="{ active: loginMethod === 'qrcode' }"
@@ -17,6 +10,13 @@
>
扫码登录
</view>
<view
class="method-item"
:class="{ active: loginMethod === 'face' }"
@click="switchLoginMethod('face')"
>
扫脸登录
</view>
</view>
<view class="login-scan-area">
@@ -64,7 +64,8 @@
</view>
<view class="countdown-container">
<view class="countdown-wrapper">
<!-- 刷脸不限时间 -->
<view class="countdown-wrapper" v-if="loginMethod === 'qrcode'">
<text class="countdown-number">{{ countdown }}</text>
<text class="countdown-text">秒后自动返回</text>
</view>
@@ -236,7 +237,7 @@ let scanInterval = null;
const countdown = ref(60);
let countdownTimer = null;
const loginMethod = ref('qrcode'); // 'qrcode' / 'face'
const pageTitle = ref('就享家服务程序');
onLoad((parmas) => {
getTreeselect();
if (!isMachineEnv.value) {
@@ -264,6 +265,7 @@ onMounted(() => {
}, 1000);
}
});
onUnmounted(() => {
stopScanAnimation();
stopCountdown();
@@ -274,7 +276,7 @@ const startCountdown = () => {
countdown.value = 60;
countdownTimer = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
if (countdown.value <= 0 && loginMethod.value === 'qrcode') {
returnToHome();
}
}, 1000);
@@ -316,6 +318,7 @@ const switchLoginMethod = (method) => {
faceService.close();
qrHandler.start();
playTextDirectly('扫码登录');
resetCountdown();
break;
case 'face':
qrHandler.close();
@@ -323,14 +326,16 @@ const switchLoginMethod = (method) => {
playTextDirectly('扫脸登录');
break;
}
resetCountdown();
}
};
async function handleFaceLogin() {
try {
const authCode = await faceService.startFaceLogin();
console.log('拿到 AuthCode:', authCode);
console.log('authCode获取:', authCode);
if (authCode.name) {
pageTitle.value = `就享家服务程序(${authCode.name})`;
}
$api.createRequest('/app/alipay/scanLogin', authCode, 'POST').then((resData) => {
loginSetToken(resData.token).then((resume) => {
if (resume.data.jobTitleId) {
@@ -338,6 +343,11 @@ async function handleFaceLogin() {
uni.reLaunch({
url: '/pages/index/index',
});
// 登录成功、数据回填
if (resume.data.sex) {
pageTitle.value = `就享家服务程序(${name})`;
fromValue.sex = resume.data.sex === '男' ? 0 : 1;
}
}
});
});