This commit is contained in:
@@ -79,7 +79,19 @@ export default {
|
||||
* 获取种类的属性定义
|
||||
*/
|
||||
getCategoryAttributes(categoryId) {
|
||||
return api.request(`/products/categories/${categoryId}/attributes`, 'GET')
|
||||
const token = uni.getStorageSync('token')
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `${import.meta.env.VITE_API_BASE_URL}/products/categories/${categoryId}/attributes`,
|
||||
method: 'GET',
|
||||
header: { 'Authorization': token ? `Bearer ${token}` : '' },
|
||||
success: (res) => {
|
||||
if (res.data.code === 0) resolve(res.data.data)
|
||||
else reject(res.data)
|
||||
},
|
||||
fail: reject
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -87,6 +99,7 @@ export default {
|
||||
*/
|
||||
saveCategoryAttributes(categoryId, attrs) {
|
||||
const token = uni.getStorageSync('token')
|
||||
const role = uni.getStorageSync('role') || ''
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `${import.meta.env.VITE_API_BASE_URL}/products/categories/${categoryId}/attributes`,
|
||||
@@ -94,7 +107,8 @@ export default {
|
||||
data: attrs,
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : ''
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
'X-User-Role': role
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.code === 0) {
|
||||
|
||||
Reference in New Issue
Block a user