From e9674fcb409592646cfb718fc80180b82af6ff9b Mon Sep 17 00:00:00 2001 From: Apcallover <1503963513@qq.com> Date: Thu, 25 Dec 2025 10:52:14 +0800 Subject: [PATCH] =?UTF-8?q?flat:=20=E6=94=AF=E4=BB=98=E5=AE=9D=E5=88=B7?= =?UTF-8?q?=E8=84=B8=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/all-in-one-listen.js | 21 +-------------------- pages/login/login.vue | 11 ++++++++++- utils/request.js | 7 ++++--- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/common/all-in-one-listen.js b/common/all-in-one-listen.js index ed3a731..2d4ebe2 100644 --- a/common/all-in-one-listen.js +++ b/common/all-in-one-listen.js @@ -101,10 +101,6 @@ export class FaceLoginService { this._retryTimer = null; } - /** - * 【新增】生命周期 - 开始 - * 统一入口,通常在页面加载 (onLoad/onMounted) 时调用 - */ start(scope = null) { // 启动前先清理可能存在的旧状态 this.close(); @@ -113,10 +109,6 @@ export class FaceLoginService { this.init(scope); } - /** - * 【新增】生命周期 - 关闭 - * 统一出口,通常在页面卸载 (onUnload/onUnmounted) 时调用 - */ close() { // 1. 清除正在等待执行的重试定时器 if (this._retryTimer) { @@ -131,10 +123,6 @@ export class FaceLoginService { console.log("[FaceLogin] 服务已关闭"); } - /** - * 1. 初始化刷脸服务 - * (已修改:增加了对定时器的管理) - */ async init(scope = null, retryCount = 1) { const params = { action: "initFace", @@ -154,7 +142,6 @@ export class FaceLoginService { return true; } catch (err) { console.error(`[FaceLogin] 初始化失败: ${err.message}`); - // 如果还有重试次数,且服务没有被手动 close 关闭 if (retryCount > 0) { console.log("[FaceLogin] 3秒后尝试重新初始化..."); this._retryTimer = setTimeout(() => { @@ -162,8 +149,7 @@ export class FaceLoginService { this.init(scope, retryCount - 1); // 递归重试 }, 3000); } else { - // 重试耗尽,抛出错误 - // throw err; // 可选:视业务逻辑决定是否阻断 + // throw err; // 视业务逻辑决定是否阻断 } } } @@ -172,11 +158,9 @@ export class FaceLoginService { * 2. 唤起 1:N 刷脸并获取 AuthCode */ async startFaceLogin() { - // 防御性编程:确保已初始化 if (!this.isInitialized) { console.warn("[FaceLogin] 服务未初始化,尝试自动补救初始化..."); try { - // 尝试一次即时初始化(不重试) await this.init(null, 0); if (!this.isInitialized) throw new Error("初始化未完成"); } catch (e) { @@ -218,9 +202,6 @@ export class FaceLoginService { } } - /** - * 基础 Bridge 调用封装 - */ _bridgeCall(params) { return new Promise((resolve, reject) => { if (typeof hh === 'undefined' || !hh.call) { diff --git a/pages/login/login.vue b/pages/login/login.vue index 362a44d..109407b 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -331,7 +331,16 @@ async function handleFaceLogin() { try { const authCode = await faceService.startFaceLogin(); console.log('拿到 AuthCode:', authCode); - // 调用后端登录接口... + $api.createRequest('/app/alipay/scanLogin', authCode, 'POST').then((resData) => { + loginSetToken(resData.token).then((resume) => { + if (resume.data.jobTitleId) { + useUserStore().initSeesionId(); + uni.reLaunch({ + url: '/pages/index/index', + }); + } + }); + }); } catch (err) { this.$api.msg(err.message); } diff --git a/utils/request.js b/utils/request.js index c354acb..ac089da 100644 --- a/utils/request.js +++ b/utils/request.js @@ -18,7 +18,8 @@ const needToEncrypt = [ ["post", "/app/user/experience/edit"], ["post", "/app/user/experience/delete"], ["get", "/app/user/experience/getSingle/{value}"], - ["get", "/app/user/experience/list"] + ["get", "/app/user/experience/list"], + ["post", "/app/alipay/scanLogin"] ] /** @@ -118,8 +119,8 @@ export function createRequest(url, data = {}, method = 'GET', loading = false, h // ------------------------------------------------------------------ return new Promise((resolve, reject) => { uni.request({ - url: config.baseUrl + '/app/proxy', - // url: config.baseUrl + url, + // url: config.baseUrl + '/app/proxy', + url: config.baseUrl + url, method: method, data: requestData, header,