xc-app/API/product.js

262 lines
6.4 KiB
JavaScript

import {
httpUrlFormat,
ajaxCarryAuthorization,ajaxSync
} from '@/utils/httpUtils.js'
import { ApiVersion,AppVersion } from '@/config/baseConfig.js'
const headerVersion = {
'API-Version': ApiVersion(),
'APP-Version':AppVersion()
}
const _flag = 'apiBaseUrl' // 请求的api空间
const apiUrl = {
'productApi': httpUrlFormat('/product', _flag),
'productTagsApi': httpUrlFormat('/product/tags', _flag),
'boxesTagsApi': httpUrlFormat('/boxes/tags', _flag),
'boxesApi': httpUrlFormat('/boxes', _flag),
'favorItemApi': httpUrlFormat('/user/favor/item', _flag),
'favorItemProductApi': httpUrlFormat('/user/favor/item/product', _flag),
'orderPreview': httpUrlFormat('/order/preview', _flag),
'orderReceive': httpUrlFormat('/order/receive', _flag),
'orderList': httpUrlFormat('/order/mall_order', _flag),
'boxOrder': httpUrlFormat('/order/box_order', _flag),
'boxRecord': httpUrlFormat('/order/box_record', _flag),
'boxOpen': httpUrlFormat('/order/box_open', _flag),
'boxPickup': httpUrlFormat('/order/box_pickup', _flag),
'boxRecycle': httpUrlFormat('/order/box_recycle', _flag),
'boxInfo': httpUrlFormat('/order/box_info', _flag),
'orderCancel': httpUrlFormat('/order/cancel', _flag),
'boxOpenByBoxId': httpUrlFormat('/order/box_open_by_box_id', _flag),
}
//商品标签
export function productTagsApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.productTagsApi,
method: 'GET',
data: data
})
}
//商品分页
export function productApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.productApi,
method: 'GET',
data: data
})
}
//盲盒标签
export function boxesTagsApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.boxesTagsApi,
method: 'GET',
data: data
})
}
export function productDetailApi(data,header = {}) {
const headerObj = {...header,...headerVersion}
return ajaxCarryAuthorization({
header:headerObj,
url: httpUrlFormat(`/product/${data.id}`, _flag),
method: 'GET',
data: data
})
}
// 收藏
export function favorItemApi(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.favorItemApi,
method: 'POST',
data: data
})
}
// 删除收藏
export function delFavorItemApi(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.favorItemProductApi,
method: 'DELETE',
data: data
})
}
//商城订单列表
export function orderList(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.order,
method: 'GET',
data: data
})
}
// 删除订单
export function delOrder(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
// url: apiUrl.cart_item,
url: apiUrl.order,
method: 'DELETE',
data: data
})
}
// 取消订单
export function orderCancel(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
// url: apiUrl.cart_item,
url: apiUrl.orderCancel,
method: 'PUT',
data: data
})
}
// 确认收货
export function orderReceive(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
// url: apiUrl.cart_item,
url: apiUrl.orderReceive,
method: 'POST',
data: data
})
}
//创建商城订单
export function createOrder(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.orderList,
method: 'POST',
data: data
})
}
//订单预览
export function orderPreview(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.orderPreview,
method: 'POST',
data: data
})
}
//盲盒订单列表
export function boxOrderList(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.boxOrder,
method: 'GET',
data: data
})
}
//创建盲盒订单
export function boxCreateOrder(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.boxOrder,
method: 'POST',
data: data
})
}
//礼盒/物品列表
export function boxRecord(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.boxRecord,
method: 'GET',
data: data
})
}
//开盲盒
export function boxOpen(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
header: headerObj,
url: apiUrl.boxOpen,
method: 'POST',
data: data
})
}
//提取盲盒
export function boxPickup(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.boxPickup,
method: 'POST',
data: data
})
}
//回收盲盒
export function boxRecycle(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.boxRecycle,
method: 'POST',
data: data
})
}
// 订单详情
export function orderDetail(no,data) {
return ajaxCarryAuthorization({
header: headerVersion,
url: httpUrlFormat(`/order/${no}`, _flag),
method: 'GET',
data: data
})
}
//盲盒详情
export function boxInfo(data) {
return ajaxCarryAuthorization({
header: headerVersion,
url: apiUrl.boxInfo,
method: 'GET',
data: data
})
}
// 根据盲盒id开盒
export function boxOpenByBoxId(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.boxOpenByBoxId,
method: 'POST',
data: data
})
}