This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 93 KiB |
@@ -1058,6 +1058,33 @@ const getRequestUrl = () => {
|
|||||||
return `${baseUrl}/api/v1/${selectedProduct.value.code}`
|
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 () => {
|
const encryptParams = async () => {
|
||||||
if (!canDebug.value) {
|
if (!canDebug.value) {
|
||||||
@@ -1089,8 +1116,14 @@ const encryptWithAES = async (data, secretKey) => {
|
|||||||
try {
|
try {
|
||||||
console.log('开始调用后端加密接口,参数:', data, '密钥:', secretKey)
|
console.log('开始调用后端加密接口,参数:', data, '密钥:', secretKey)
|
||||||
|
|
||||||
|
// 解析JSON字符串(如果是字符串)
|
||||||
|
let parsedData = typeof data === 'string' ? JSON.parse(data) : data
|
||||||
|
|
||||||
|
// 根据字段类型进行类型转换
|
||||||
|
parsedData = convertFieldTypes(parsedData)
|
||||||
|
|
||||||
// 使用项目的标准API调用方式,传递密钥参数
|
// 使用项目的标准API调用方式,传递密钥参数
|
||||||
const result = await apiApi.encryptParams(typeof data === 'string' ? JSON.parse(data) : data, secretKey)
|
const result = await apiApi.encryptParams(parsedData, secretKey)
|
||||||
|
|
||||||
console.log('加密接口响应数据:', result)
|
console.log('加密接口响应数据:', result)
|
||||||
|
|
||||||
@@ -1155,8 +1188,9 @@ const handleDebug = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将表单数据转换为JSON格式
|
// 将表单数据转换为JSON格式,并根据字段类型进行类型转换
|
||||||
debugForm.params = JSON.stringify(formData.value, null, 2)
|
const processedData = convertFieldTypes(formData.value)
|
||||||
|
debugForm.params = JSON.stringify(processedData, null, 2)
|
||||||
} else {
|
} else {
|
||||||
// 原有的JSON验证逻辑
|
// 原有的JSON验证逻辑
|
||||||
if (!validateJsonParams()) {
|
if (!validateJsonParams()) {
|
||||||
|
|||||||
@@ -191,11 +191,14 @@
|
|||||||
class="usage-dialog"
|
class="usage-dialog"
|
||||||
>
|
>
|
||||||
<div v-if="selectedSubscription" class="space-y-6">
|
<div v-if="selectedSubscription" class="space-y-6">
|
||||||
<div class="grid grid-cols-2 gap-6">
|
<div v-if="loadingUsage" class="flex justify-center items-center py-8">
|
||||||
<!-- <div class="usage-stat-card">
|
<el-loading />
|
||||||
<div class="usage-stat-value">{{ selectedSubscription.api_used || 0 }}</div>
|
</div>
|
||||||
<div class="usage-stat-label">已使用API调用次数</div>
|
<div v-else class="grid grid-cols-2 gap-6">
|
||||||
</div> -->
|
<div class="usage-stat-card">
|
||||||
|
<div class="usage-stat-value">{{ usageData?.api_used || 0 }}</div>
|
||||||
|
<div class="usage-stat-label">API调用次数</div>
|
||||||
|
</div>
|
||||||
<div class="usage-stat-card">
|
<div class="usage-stat-card">
|
||||||
<div class="usage-stat-value">¥{{ formatPrice(selectedSubscription.price) }}</div>
|
<div class="usage-stat-value">¥{{ formatPrice(selectedSubscription.price) }}</div>
|
||||||
<div class="usage-stat-label">订阅价格</div>
|
<div class="usage-stat-label">订阅价格</div>
|
||||||
@@ -235,6 +238,8 @@ const currentPage = ref(1)
|
|||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
const usageDialogVisible = ref(false)
|
const usageDialogVisible = ref(false)
|
||||||
const selectedSubscription = ref(null)
|
const selectedSubscription = ref(null)
|
||||||
|
const usageData = ref(null)
|
||||||
|
const loadingUsage = ref(false)
|
||||||
|
|
||||||
// 统计数据
|
// 统计数据
|
||||||
const stats = ref({
|
const stats = ref({
|
||||||
@@ -376,9 +381,24 @@ const handleViewProduct = (product) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查看使用情况
|
// 查看使用情况
|
||||||
const handleViewUsage = (subscription) => {
|
const handleViewUsage = async (subscription) => {
|
||||||
selectedSubscription.value = subscription
|
selectedSubscription.value = subscription
|
||||||
usageDialogVisible.value = true
|
usageDialogVisible.value = true
|
||||||
|
usageData.value = null
|
||||||
|
|
||||||
|
// 加载使用情况数据
|
||||||
|
if (subscription && subscription.id) {
|
||||||
|
loadingUsage.value = true
|
||||||
|
try {
|
||||||
|
const response = await subscriptionApi.getMySubscriptionUsage(subscription.id)
|
||||||
|
usageData.value = response.data
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载使用情况失败:', error)
|
||||||
|
ElMessage.error('加载使用情况失败')
|
||||||
|
} finally {
|
||||||
|
loadingUsage.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转到在线调试页面
|
// 跳转到在线调试页面
|
||||||
|
|||||||
Reference in New Issue
Block a user