|
|
@@ -0,0 +1,204 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import {deliverOrder, getOrder, payOrder} from "../../api/order.ts";
|
|
|
+import {ref} from "vue";
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ orderVO: {
|
|
|
+ type: Object,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ getOrderList: {
|
|
|
+ type: Function,
|
|
|
+ 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
|
|
|
+
|
|
|
+function handleType() {
|
|
|
+ if (type === 'DELIVERY') {
|
|
|
+ return "快递到家"
|
|
|
+ } else if (type === 'PICKUP') {
|
|
|
+ return "到店自取"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handleStatus() {
|
|
|
+ if (status === 'UNPAID') {
|
|
|
+ return "待支付"
|
|
|
+ } else if (status === 'UNSEND') {
|
|
|
+ return "待发货"
|
|
|
+ } else if (status === 'UNGET') {
|
|
|
+ return "待收货"
|
|
|
+ } else if (status === 'UNCOMMENT') {
|
|
|
+ return "待评价"
|
|
|
+ } else if (status === 'DONE') {
|
|
|
+ return "已完成"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handleTime(time) {
|
|
|
+ if (time === null) {
|
|
|
+ return "暂未完成"
|
|
|
+ }
|
|
|
+ let times = time.split(/T|\./)
|
|
|
+ return times[0] + " " + times[1]
|
|
|
+}
|
|
|
+
|
|
|
+let orderDialogVisible = ref(false)
|
|
|
+
|
|
|
+function handlePay() {
|
|
|
+ orderDialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+function handleConfirmOrder() {
|
|
|
+ payOrder(orderId).then(res => {
|
|
|
+ if (res.code === '000') {
|
|
|
+ ElMessage({
|
|
|
+ message: '订单支付成功!',
|
|
|
+ type: 'success',
|
|
|
+ center: true,
|
|
|
+ })
|
|
|
+ orderDialogVisible.value = false
|
|
|
+ //props.getOrderList()
|
|
|
+ } else if (res.code === '400') {
|
|
|
+ ElMessage({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error',
|
|
|
+ center: true,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function handleDeliver() {
|
|
|
+ deliverOrder(orderId).then(res => {
|
|
|
+ if (res.code === '000') {
|
|
|
+ ElMessage({
|
|
|
+ message: '订单发货成功!',
|
|
|
+ type: 'success',
|
|
|
+ center: true,
|
|
|
+ })
|
|
|
+ props.getOrderList()
|
|
|
+ } else if (res.code === '400') {
|
|
|
+ ElMessage({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error',
|
|
|
+ center: true,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function handleGet() {
|
|
|
+ getOrder(orderId).then(res => {
|
|
|
+ if (res.code === '000') {
|
|
|
+ ElMessage({
|
|
|
+ message: '订单收货成功!',
|
|
|
+ type: 'success',
|
|
|
+ center: true,
|
|
|
+ })
|
|
|
+ props.getOrderList()
|
|
|
+ } else if (res.code === '400') {
|
|
|
+ ElMessage({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error',
|
|
|
+ center: true,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-card class="order-item-card">
|
|
|
+ <el-row style="font-size: 15px">
|
|
|
+ 数量:{{ amount }} 件
|
|
|
+ </el-row>
|
|
|
+ <el-row style="font-size: 15px">
|
|
|
+ 支付金额:{{ paid }} 元
|
|
|
+ </el-row>
|
|
|
+ <el-row style="font-size: 15px">
|
|
|
+ 取货类型:{{ handleType() }}
|
|
|
+ </el-row>
|
|
|
+ <el-row style="font-size: 15px">
|
|
|
+ 评分:{{ rating }}
|
|
|
+ </el-row>
|
|
|
+ <el-row style="font-size: 15px">
|
|
|
+ 状态:{{ handleStatus() }}
|
|
|
+ <el-button v-if="status === 'UNPAID'"
|
|
|
+ class="status-change-button" size="small" type="primary"
|
|
|
+ @click="handlePay">去支付
|
|
|
+ </el-button>
|
|
|
+ <el-button v-if="status === 'UNSEND'"
|
|
|
+ class="status-change-button" size="small" type="primary"
|
|
|
+ @click="handleDeliver">去发货
|
|
|
+ </el-button>
|
|
|
+ <el-button v-if="status === 'UNGET'"
|
|
|
+ class="status-change-button" size="small" type="primary"
|
|
|
+ @click="handleGet">去收货
|
|
|
+ </el-button>
|
|
|
+ <el-button v-if="status === 'UNCOMMENT'"
|
|
|
+ class="status-change-button" size="small" type="primary">去评价
|
|
|
+ </el-button>
|
|
|
+ </el-row>
|
|
|
+ <el-row style="font-size: 15px">
|
|
|
+ 创建时间: {{ handleTime(createTime) }}
|
|
|
+ </el-row>
|
|
|
+ <el-row style="font-size: 15px">
|
|
|
+ 完成时间: {{ handleTime(finishTime) }}
|
|
|
+ </el-row>
|
|
|
+ </el-card>
|
|
|
+
|
|
|
+ <el-dialog v-model="orderDialogVisible">
|
|
|
+ <el-form>
|
|
|
+ <el-form-item>
|
|
|
+ <label for="amount">购买数量:</label>
|
|
|
+ {{ amount }} 件
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <label for="discountPrice">总价:</label>
|
|
|
+ {{ paid }} 元
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <label for="type">提货方式:</label>
|
|
|
+ {{ handleType() }}
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <label for="type">优惠券:</label>
|
|
|
+ <!-- <el-select id="type"-->
|
|
|
+ <!-- v-model="type"-->
|
|
|
+ <!-- placeholder="请选择"-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- <el-option value="DELIVERY">到店自提</el-option>-->
|
|
|
+ <!-- <el-option value="PICKUP">快递到家</el-option>-->
|
|
|
+ <!-- </el-select>-->
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-button @click="handleConfirmOrder">确认支付</el-button>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.order-item-card {
|
|
|
+ margin-bottom: 10px;
|
|
|
+ width: 30%;
|
|
|
+ border-radius: 8px;
|
|
|
+}
|
|
|
+
|
|
|
+.status-change-button {
|
|
|
+ margin-left: 10px;
|
|
|
+}
|
|
|
+</style>
|