fix: 直接在页面发送请求并加日志
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Agent
2026-03-29 15:33:22 +00:00
parent 74ff26c5a4
commit 74df67abf9

View File

@@ -216,11 +216,30 @@ export default {
uni.showToast({ title: '请至少添加一个属性', icon: 'none' })
return
}
console.log('准备保存属性:', JSON.stringify(validAttrs))
try {
await productApi.saveCategoryAttributes(this.currentCategory.categoryId, validAttrs)
uni.showToast({ title: '保存成功', icon: 'success' })
this.closeAttrDialog()
const token = uni.getStorageSync('token')
const role = uni.getStorageSync('role') || ''
const res = await uni.request({
url: `${import.meta.env.VITE_API_BASE_URL}/products/categories/${this.currentCategory.categoryId}/attributes`,
method: 'POST',
data: {
attributes: validAttrs
},
header: {
'Authorization': token ? `Bearer ${token}` : '',
'X-User-Role': role
}
})
console.log('保存结果:', res.data)
if (res.data.code === 0) {
uni.showToast({ title: '保存成功', icon: 'success' })
this.closeAttrDialog()
} else {
uni.showToast({ title: res.data.message || '保存失败', icon: 'none' })
}
} catch (e) {
console.error('保存失败:', e)
uni.showToast({ title: '保存失败', icon: 'none' })
}
}