feat: 创建订单接口
This commit is contained in:
@@ -5,50 +5,63 @@ import request from '@/utils/request'
|
||||
* @param data - 包含邮箱的参数
|
||||
* @param data.listingId - 商品ID
|
||||
* @param data.listingIds - 商品ID列表
|
||||
*/
|
||||
*/
|
||||
export const AddShoppingCart = (data, loading?: boolean) => {
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/add',
|
||||
method: 'post',
|
||||
data,
|
||||
loading
|
||||
})
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/add',
|
||||
method: 'post',
|
||||
data,
|
||||
loading
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空购物车
|
||||
*/
|
||||
*/
|
||||
export const ClearShoppingCart = (loading?: boolean) => {
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/clear',
|
||||
method: 'delete',
|
||||
loading
|
||||
})
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/clear',
|
||||
method: 'delete',
|
||||
loading
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取购物车列表
|
||||
* @param loading - 是否显示loading
|
||||
* @returns 购物车列表数据
|
||||
*/
|
||||
*/
|
||||
export const GetShoppingCartList = (loading?: boolean) => {
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/list',
|
||||
method: 'get',
|
||||
loading
|
||||
})
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/list',
|
||||
method: 'get',
|
||||
loading
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 从购物车移除商品
|
||||
* @param params - 包含邮箱的参数
|
||||
* @param params.listingId - 商品ID
|
||||
*/
|
||||
*/
|
||||
export const RemoveShoppingCartItem = (params, loading?: boolean) => {
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/remove',
|
||||
method: 'delete',
|
||||
params,
|
||||
loading
|
||||
})
|
||||
return request({
|
||||
url: '/buyer/buyer/cart/remove',
|
||||
method: 'delete',
|
||||
params,
|
||||
loading
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @param { Array } data - 商品id数组
|
||||
* @returns
|
||||
*/
|
||||
export const CreateOrder = (data) => {
|
||||
return request({
|
||||
url: '/buyer/buyer/order/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export interface WardrobeItem {
|
||||
buyerId: number
|
||||
categories: string[]
|
||||
@@ -14,14 +16,15 @@ export const fetchMyWardrobe = (data: WardrobeItem): Promise<ApiResponse> => {
|
||||
}
|
||||
|
||||
export interface OrderItem {
|
||||
status: number
|
||||
status: number // 0未支付 1已支付 2已取消 不穿查全部
|
||||
page: number
|
||||
size: number
|
||||
}
|
||||
export const fetchMyOrders = (data: OrderItem): Promise<ApiResponse> => {
|
||||
return request({
|
||||
url: '/buyer/buyer/order/page',
|
||||
method: 'post',
|
||||
data
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -74,8 +74,9 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, shallowRef } from 'vue'
|
||||
import { computed, shallowRef, onMounted,ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { fetchMyOrders } from '@/api/user'
|
||||
import ScItem from '@/views/shoppingCart/sc-item.vue'
|
||||
|
||||
type OrderStatus = 'all' | 'paid' | 'unpaid' | 'cancelled'
|
||||
@@ -211,6 +212,20 @@ const getOrderActionLabel = (status: ActualOrderStatus) => {
|
||||
if (status === 'unpaid') return t('Wardrobe.orders.actions.completePayment')
|
||||
return t('Wardrobe.orders.actions.buyAgain')
|
||||
}
|
||||
|
||||
const orderParams =ref({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
status: ''
|
||||
})
|
||||
const fetchAllOrders = () => {
|
||||
fetchMyOrders(orderParams.value)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchAllOrders()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user