diff --git a/public/qrcode.jpg b/public/qrcode.jpg index f955344..05bf97d 100644 Binary files a/public/qrcode.jpg and b/public/qrcode.jpg differ diff --git a/src/pages/api/ApiDebugger.vue b/src/pages/api/ApiDebugger.vue index dc94f6d..4c9d948 100644 --- a/src/pages/api/ApiDebugger.vue +++ b/src/pages/api/ApiDebugger.vue @@ -1058,6 +1058,33 @@ const getRequestUrl = () => { return `${baseUrl}/api/v1/${selectedProduct.value.code}` } +// 根据字段类型转换数据 +const convertFieldTypes = (data) => { + if (!formFields.value || formFields.value.length === 0) { + return data + } + + const processedData = { ...data } + formFields.value.forEach(field => { + const value = processedData[field.name] + // 如果字段值为空字符串、null 或 undefined,跳过转换 + if (value === '' || value === null || value === undefined) { + return + } + + // 根据字段类型进行转换 + if (field.type === 'number') { + // 将字符串转换为数字(整数) + const numValue = parseInt(value, 10) + if (!isNaN(numValue)) { + processedData[field.name] = numValue + } + } + }) + + return processedData +} + // 加密参数 const encryptParams = async () => { if (!canDebug.value) { @@ -1089,8 +1116,14 @@ const encryptWithAES = async (data, secretKey) => { try { console.log('开始调用后端加密接口,参数:', data, '密钥:', secretKey) + // 解析JSON字符串(如果是字符串) + let parsedData = typeof data === 'string' ? JSON.parse(data) : data + + // 根据字段类型进行类型转换 + parsedData = convertFieldTypes(parsedData) + // 使用项目的标准API调用方式,传递密钥参数 - const result = await apiApi.encryptParams(typeof data === 'string' ? JSON.parse(data) : data, secretKey) + const result = await apiApi.encryptParams(parsedData, secretKey) console.log('加密接口响应数据:', result) @@ -1155,8 +1188,9 @@ const handleDebug = async () => { return } - // 将表单数据转换为JSON格式 - debugForm.params = JSON.stringify(formData.value, null, 2) + // 将表单数据转换为JSON格式,并根据字段类型进行类型转换 + const processedData = convertFieldTypes(formData.value) + debugForm.params = JSON.stringify(processedData, null, 2) } else { // 原有的JSON验证逻辑 if (!validateJsonParams()) { diff --git a/src/pages/subscriptions/index.vue b/src/pages/subscriptions/index.vue index fff67b9..8dbaaf2 100644 --- a/src/pages/subscriptions/index.vue +++ b/src/pages/subscriptions/index.vue @@ -191,11 +191,14 @@ class="usage-dialog" >