This commit is contained in:
@@ -86,7 +86,26 @@ export default {
|
|||||||
* 保存种类的属性定义
|
* 保存种类的属性定义
|
||||||
*/
|
*/
|
||||||
saveCategoryAttributes(categoryId, attrs) {
|
saveCategoryAttributes(categoryId, attrs) {
|
||||||
return api.request(`/products/categories/${categoryId}/attributes`, 'POST', {}, attrs)
|
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: 'POST',
|
||||||
|
data: attrs,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': token ? `Bearer ${token}` : ''
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
resolve(res.data.data)
|
||||||
|
} else {
|
||||||
|
reject(res.data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: reject
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// ============ 商品属性 ============
|
// ============ 商品属性 ============
|
||||||
@@ -94,13 +113,41 @@ export default {
|
|||||||
* 获取商品的属性值
|
* 获取商品的属性值
|
||||||
*/
|
*/
|
||||||
getProductAttributes(productId) {
|
getProductAttributes(productId) {
|
||||||
return api.request(`/products/${productId}/attributes`, 'GET')
|
const token = uni.getStorageSync('token')
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: `${import.meta.env.VITE_API_BASE_URL}/products/${productId}/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
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存商品的属性值
|
* 保存商品的属性值
|
||||||
*/
|
*/
|
||||||
saveProductAttributes(productId, attrs) {
|
saveProductAttributes(productId, attrs) {
|
||||||
return api.request(`/products/${productId}/attributes`, 'POST', {}, attrs)
|
const token = uni.getStorageSync('token')
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: `${import.meta.env.VITE_API_BASE_URL}/products/${productId}/attributes`,
|
||||||
|
method: 'POST',
|
||||||
|
data: attrs,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': token ? `Bearer ${token}` : ''
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
if (res.data.code === 0) resolve(res.data.data)
|
||||||
|
else reject(res.data)
|
||||||
|
},
|
||||||
|
fail: reject
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user