|
|
@@ -1,32 +1,44 @@
|
|
|
<script setup lang="ts">
|
|
|
-import {deliverOrder, getOrder, payOrder} from "../../api/order.ts";
|
|
|
+import {deliverOrder, getOrder, getOrderById, payOrder} from "../../api/order.ts";
|
|
|
import {ref} from "vue";
|
|
|
|
|
|
const props = defineProps({
|
|
|
- orderVO: {
|
|
|
- type: Object,
|
|
|
- required: true
|
|
|
- },
|
|
|
- getOrderList: {
|
|
|
- type: Function,
|
|
|
+ orderId: {
|
|
|
+ type: Number,
|
|
|
required: true
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const orderId = props.orderVO.id
|
|
|
-const userId = props.orderVO.userId
|
|
|
-const productId = props.orderVO.productId
|
|
|
-const amount = props.orderVO.amount
|
|
|
-const paid = props.orderVO.paid
|
|
|
-const type = props.orderVO.type
|
|
|
-const content = props.orderVO.content
|
|
|
-const rating = props.orderVO.rating
|
|
|
-const status = props.orderVO.status
|
|
|
-const createTime = props.orderVO.createTime
|
|
|
-const finishTime = props.orderVO.finishTime
|
|
|
+const userId = ref(0)
|
|
|
+const productId = ref(0)
|
|
|
+const amount = ref(0)
|
|
|
+const paid = ref(0)
|
|
|
+const type = ref('')
|
|
|
+const content = ref('')
|
|
|
+const rating = ref(0)
|
|
|
+const status = ref('')
|
|
|
+const createTime= ref('')
|
|
|
+const finishTime = ref('')
|
|
|
+
|
|
|
+getOrderDetail()
|
|
|
+
|
|
|
+function getOrderDetail() {
|
|
|
+ getOrderById(props.orderId).then(res => {
|
|
|
+ userId.value = res.result.userId
|
|
|
+ productId.value = res.result.productId
|
|
|
+ amount.value = res.result.amount
|
|
|
+ paid.value = res.result.paid
|
|
|
+ type.value = res.result.type
|
|
|
+ content.value = res.result.content
|
|
|
+ rating.value = res.result.rating
|
|
|
+ status.value = res.result.status
|
|
|
+ createTime.value = res.result.createTime
|
|
|
+ finishTime.value = res.result.finishTime
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
function handleType() {
|
|
|
- if (type === 'DELIVERY') {
|
|
|
+ if (type.value === 'DELIVERY') {
|
|
|
return "快递到家"
|
|
|
} else if (type === 'PICKUP') {
|
|
|
return "到店自取"
|
|
|
@@ -34,15 +46,15 @@ function handleType() {
|
|
|
}
|
|
|
|
|
|
function handleStatus() {
|
|
|
- if (status === 'UNPAID') {
|
|
|
+ if (status.value === 'UNPAID') {
|
|
|
return "待支付"
|
|
|
- } else if (status === 'UNSEND') {
|
|
|
+ } else if (status.value === 'UNSEND') {
|
|
|
return "待发货"
|
|
|
- } else if (status === 'UNGET') {
|
|
|
+ } else if (status.value === 'UNGET') {
|
|
|
return "待收货"
|
|
|
- } else if (status === 'UNCOMMENT') {
|
|
|
+ } else if (status.value === 'UNCOMMENT') {
|
|
|
return "待评价"
|
|
|
- } else if (status === 'DONE') {
|
|
|
+ } else if (status.value === 'DONE') {
|
|
|
return "已完成"
|
|
|
}
|
|
|
}
|
|
|
@@ -62,7 +74,7 @@ function handlePay() {
|
|
|
}
|
|
|
|
|
|
function handleConfirmOrder() {
|
|
|
- payOrder(orderId).then(res => {
|
|
|
+ payOrder(props.orderId).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
ElMessage({
|
|
|
message: '订单支付成功!',
|
|
|
@@ -70,7 +82,7 @@ function handleConfirmOrder() {
|
|
|
center: true,
|
|
|
})
|
|
|
orderDialogVisible.value = false
|
|
|
- //props.getOrderList()
|
|
|
+ getOrderDetail()
|
|
|
} else if (res.code === '400') {
|
|
|
ElMessage({
|
|
|
message: res.msg,
|
|
|
@@ -82,14 +94,14 @@ function handleConfirmOrder() {
|
|
|
}
|
|
|
|
|
|
function handleDeliver() {
|
|
|
- deliverOrder(orderId).then(res => {
|
|
|
+ deliverOrder(props.orderId).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
ElMessage({
|
|
|
message: '订单发货成功!',
|
|
|
type: 'success',
|
|
|
center: true,
|
|
|
})
|
|
|
- props.getOrderList()
|
|
|
+ getOrderDetail()
|
|
|
} else if (res.code === '400') {
|
|
|
ElMessage({
|
|
|
message: res.msg,
|
|
|
@@ -101,14 +113,14 @@ function handleDeliver() {
|
|
|
}
|
|
|
|
|
|
function handleGet() {
|
|
|
- getOrder(orderId).then(res => {
|
|
|
+ getOrder(props.orderId).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
ElMessage({
|
|
|
message: '订单收货成功!',
|
|
|
type: 'success',
|
|
|
center: true,
|
|
|
})
|
|
|
- props.getOrderList()
|
|
|
+ getOrderDetail()
|
|
|
} else if (res.code === '400') {
|
|
|
ElMessage({
|
|
|
message: res.msg,
|