From d9a8f67c88f3dea03a81667de949a8ba23ad26a2 Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Thu, 18 Dec 2025 22:28:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=20hasOnlyUserId?= =?UTF-8?q?=20=E5=88=A4=E6=96=AD=E5=B9=B6=E6=9B=B4=E6=96=B0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E7=BB=84=E4=BB=B6=E7=9A=84=E7=A6=81=E7=94=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 api.js 中新增 hasOnlyUserId 方法,用于检测 URL 中是否仅包含 userId 参数 - 在 main.js 里通过计算属性引入 hasOnlyUserId 状态 - 修改 index.html 中导出订单数据创建者选择框的禁用条件,从 hasUserId 改为 hasOnlyUserId - 优化了导出表单组件对用户 ID 参数的判断逻辑,提高交互准确性 --- web/index.html | 4 ++-- web/main.js | 2 ++ web/modules/api.js | 13 ++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/web/index.html b/web/index.html index 0ce4628..d1f02b5 100644 --- a/web/index.html +++ b/web/index.html @@ -262,7 +262,7 @@ - + @@ -285,7 +285,7 @@ - + diff --git a/web/main.js b/web/main.js index 5cb2aa7..e289487 100644 --- a/web/main.js +++ b/web/main.js @@ -23,6 +23,7 @@ const app = createApp({ // ==================== 计算属性 ==================== const hasUserId = Vue.computed(() => !!Api.getUserId()); + const hasOnlyUserId = Vue.computed(() => Api.hasOnlyUserId()); const currentUserId = Vue.computed(() => { const userId = Api.getUserId(); return userId ? Number(userId) : null; @@ -1019,6 +1020,7 @@ const app = createApp({ isOrder, exportTitle, hasUserId, + hasOnlyUserId, currentUserId, hasCreators, hasReseller, diff --git a/web/modules/api.js b/web/modules/api.js index e787c24..ea2ff21 100644 --- a/web/modules/api.js +++ b/web/modules/api.js @@ -20,7 +20,7 @@ const getApiBase = () => { const API_BASE = getApiBase(); /** - * 从URL 参数中获取用户 ID + * 从 URL 参数中获取用户 ID * @returns {string} 用户 ID,不存在返回空字符串 */ const getUserId = () => { @@ -29,6 +29,16 @@ const getUserId = () => { return value && String(value).trim() ? String(value).trim() : ''; }; +/** + * 检查 URL 中是否有 userId 参数(不包含 current_user_id) + * @returns {boolean} + */ +const hasOnlyUserId = () => { + const params = new URLSearchParams(window.location.search || ''); + const value = params.get('userId') || params.get('userid') || params.get('user_id'); + return !!(value && String(value).trim()); +}; + /** * 从 URL 参数中获取商户 ID * @returns {string} 商户 ID,不存在返回空字符串 @@ -399,6 +409,7 @@ window.ApiService = { // 基础方法 API_BASE, getUserId, + hasOnlyUserId, getMerchantId, buildUserQueryString, get,