|
|
@@ -1,6 +1,8 @@
|
|
|
<script setup lang="ts">
|
|
|
import {deliverOrder, getOrder, getOrderById, payOrder, commentOrder} from "../../api/order.ts";
|
|
|
import {ref, computed} from "vue";
|
|
|
+import {getAvailableCouponsByStoreId} from "../../api/coupon.ts";
|
|
|
+import {ElTable} from "element-plus";
|
|
|
|
|
|
const props = defineProps({
|
|
|
orderId: {
|
|
|
@@ -23,6 +25,9 @@ const rating = ref(0)
|
|
|
const status = ref('')
|
|
|
const createTime= ref('')
|
|
|
const finishTime = ref('')
|
|
|
+const storeId = ref(0)
|
|
|
+
|
|
|
+const couponId = ref(0)
|
|
|
|
|
|
getOrderDetail()
|
|
|
|
|
|
@@ -39,10 +44,10 @@ function getOrderDetail() {
|
|
|
status.value = res.result.status
|
|
|
createTime.value = res.result.createTime
|
|
|
finishTime.value = res.result.finishTime
|
|
|
+ storeId.value = res.result.storeId
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 对于变化的内容使用计算属性返回响应式结果
|
|
|
const statusText = computed(() => {
|
|
|
switch (status.value) {
|
|
|
@@ -84,10 +89,11 @@ function parseType() {
|
|
|
|
|
|
function handlePay() {
|
|
|
orderDialogVisible.value = true
|
|
|
+ getAvailableCouponList()
|
|
|
}
|
|
|
|
|
|
function handleConfirmOrder() {
|
|
|
- payOrder(props.orderId).then(res => {
|
|
|
+ payOrder(props.orderId, couponId.value).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
ElMessage({
|
|
|
message: '订单支付成功!',
|
|
|
@@ -145,7 +151,6 @@ function handleGet() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function handleComment() {
|
|
|
commentDialogVisible.value = true
|
|
|
}
|
|
|
@@ -177,7 +182,6 @@ function handleSendComment() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function switchButtonFunction() {
|
|
|
switch (status.value) {
|
|
|
case 'UNPAID': handlePay(); break;
|
|
|
@@ -188,7 +192,45 @@ function switchButtonFunction() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 处理优惠券
|
|
|
+interface Coupon {
|
|
|
+ id: number
|
|
|
+ groupId: number
|
|
|
+ type: string
|
|
|
+ satisfaction: number
|
|
|
+ minus: number
|
|
|
+}
|
|
|
+
|
|
|
+const availableCouponList = ref<Coupon[]>([])
|
|
|
+const currentRow = ref()
|
|
|
+const singleTableRef = ref<InstanceType<typeof ElTable>>()
|
|
|
+
|
|
|
+function getAvailableCouponList() {
|
|
|
+ getAvailableCouponsByStoreId(storeId.value).then(res => {
|
|
|
+ availableCouponList.value = res.result
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
+const handleCurrentChange = (val: Coupon | undefined) => {
|
|
|
+ if (val) {
|
|
|
+ couponId.value = val.id
|
|
|
+ } else {
|
|
|
+ couponId.value = 0
|
|
|
+ }
|
|
|
+ currentRow.value = val
|
|
|
+}
|
|
|
+
|
|
|
+const setCurrent = (row?: User) => {
|
|
|
+ singleTableRef.value!.setCurrentRow(row)
|
|
|
+}
|
|
|
+
|
|
|
+function handleCouponType(type) {
|
|
|
+ if (type === "FULL_REDUCTION") {
|
|
|
+ return "满减"
|
|
|
+ } else if (type === "SPECIAL") {
|
|
|
+ return "折扣"
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -242,7 +284,6 @@ function switchButtonFunction() {
|
|
|
{{ content }}
|
|
|
</el-descriptions-item >
|
|
|
</el-descriptions>
|
|
|
-
|
|
|
</el-card>
|
|
|
|
|
|
<el-dialog v-model="orderDialogVisible">
|
|
|
@@ -260,14 +301,23 @@ function switchButtonFunction() {
|
|
|
{{ parseType() }}
|
|
|
</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>-->
|
|
|
+ <label for="type">优惠券:</label> <el-button @click="setCurrent()">不使用优惠券</el-button>
|
|
|
+ <el-table
|
|
|
+ ref="singleTableRef"
|
|
|
+ :data="availableCouponList"
|
|
|
+ highlight-current-row
|
|
|
+ style="width: 100%"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ >
|
|
|
+ <el-table-column type="index" width="50"/>
|
|
|
+ <el-table-column prop="type" label="类型" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ handleCouponType(scope.row.type) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="satisfaction" label="满(元)" width="180"/>
|
|
|
+ <el-table-column prop="minus" label="减(元)" width="180"/>
|
|
|
+ </el-table>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<el-button @click="handleConfirmOrder">确认支付</el-button>
|