This commit is contained in:
@@ -216,11 +216,30 @@ export default {
|
|||||||
uni.showToast({ title: '请至少添加一个属性', icon: 'none' })
|
uni.showToast({ title: '请至少添加一个属性', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.log('准备保存属性:', JSON.stringify(validAttrs))
|
||||||
try {
|
try {
|
||||||
await productApi.saveCategoryAttributes(this.currentCategory.categoryId, validAttrs)
|
const token = uni.getStorageSync('token')
|
||||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
const role = uni.getStorageSync('role') || ''
|
||||||
this.closeAttrDialog()
|
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) {
|
} catch (e) {
|
||||||
|
console.error('保存失败:', e)
|
||||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user