|
|
@@ -1,8 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import {ref, computed} from "vue"
|
|
|
-import {deliverOrder, getOrder, getOrderById, payOrder, commentOrder} from "../api/order"
|
|
|
-import {parseOrderType, parseTime} from "../utils";
|
|
|
-
|
|
|
+import {deliverOrder, getOrder, getOrderById, commentOrder, payOrder} from "../api/order"
|
|
|
+import {parseOrderType, parseRating, parseTime} from "../utils";
|
|
|
const props = defineProps({
|
|
|
orderId: {
|
|
|
type: Number,
|
|
|
@@ -30,12 +29,12 @@ const finishTime = ref('')
|
|
|
const storeId = ref(0)
|
|
|
|
|
|
const totalPrice = ref(0)
|
|
|
-const discountPrice = ref(0)
|
|
|
|
|
|
getOrderDetail()
|
|
|
|
|
|
function getOrderDetail() {
|
|
|
getOrderById(props.orderId).then(res => {
|
|
|
+ //console.log(res)
|
|
|
userId.value = res.data.result.userId
|
|
|
productId.value = res.data.result.productId
|
|
|
productName.value = res.data.result.productName
|
|
|
@@ -44,14 +43,13 @@ function getOrderDetail() {
|
|
|
paid.value = res.data.result.paid
|
|
|
type.value = res.data.result.type
|
|
|
content.value = res.data.result.content
|
|
|
- rating.value = res.data.result.rating
|
|
|
+ rating.value = parseRating(res.data.result.rating)
|
|
|
status.value = res.data.result.status
|
|
|
createTime.value = res.data.result.createTime
|
|
|
finishTime.value = res.data.result.finishTime
|
|
|
storeId.value = res.data.result.storeId
|
|
|
|
|
|
totalPrice.value = amount.value * price.value
|
|
|
- discountPrice.value = totalPrice.value
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -68,6 +66,7 @@ function handleConfirmOrder() {
|
|
|
center: true,
|
|
|
})
|
|
|
getOrderDetail()
|
|
|
+ orderDialogVisible.value = false
|
|
|
} else if (res.data.code === '400') {
|
|
|
ElMessage({
|
|
|
message: res.data.msg,
|
|
|
@@ -78,10 +77,6 @@ function handleConfirmOrder() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function handlePayDialogClose() {
|
|
|
- orderDialogVisible.value = false
|
|
|
-}
|
|
|
-
|
|
|
function handleDeliver() {
|
|
|
deliverOrder(props.orderId).then(res => {
|
|
|
if (res.data.code === '000') {
|
|
|
@@ -125,7 +120,6 @@ function handleComment() {
|
|
|
}
|
|
|
|
|
|
function handleSendComment() {
|
|
|
-
|
|
|
const payload = {
|
|
|
orderId: props.orderId,
|
|
|
comment: content.value,
|
|
|
@@ -151,14 +145,6 @@ function handleSendComment() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function parsePaid() {
|
|
|
- if (paid.value === null) {
|
|
|
- return "暂未支付"
|
|
|
- } else {
|
|
|
- return paid.value + " 元"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// 对于变化的内容使用计算属性返回响应式结果
|
|
|
const statusText = computed(() => {
|
|
|
switch (status.value) {
|
|
|
@@ -189,6 +175,7 @@ const statusText = computed(() => {
|
|
|
<el-tag style="margin-left: 8px" v-if="status!=='DONE'" type="info"> {{ statusText }}</el-tag>
|
|
|
<el-tag style="margin-left: 8px" v-if="status==='DONE'" type="success"> {{ statusText }}</el-tag>
|
|
|
</div>
|
|
|
+
|
|
|
<el-button @click="handlePay" v-if="status==='UNPAID' && role==='CUSTOMER'"
|
|
|
class="status-change-button" size="small" type="primary">
|
|
|
支付
|
|
|
@@ -217,12 +204,9 @@ const statusText = computed(() => {
|
|
|
<el-descriptions-item style="font-size: 15px" label="数量">
|
|
|
{{ amount }} 件
|
|
|
</el-descriptions-item>
|
|
|
- <el-descriptions-item style="font-size: 15px" label="订单原价">
|
|
|
+ <el-descriptions-item style="font-size: 15px" label="总价">
|
|
|
{{ totalPrice }} 元
|
|
|
</el-descriptions-item>
|
|
|
- <el-descriptions-item style="font-size: 15px" label="实付金额">
|
|
|
- {{ parsePaid() }}
|
|
|
- </el-descriptions-item>
|
|
|
<el-descriptions-item style="font-size: 15px" label="取货类型">
|
|
|
<el-tag> {{ parseOrderType(type) }}</el-tag>
|
|
|
</el-descriptions-item>
|
|
|
@@ -248,7 +232,7 @@ const statusText = computed(() => {
|
|
|
</el-descriptions>
|
|
|
</el-card>
|
|
|
|
|
|
- <el-dialog v-model="orderDialogVisible" :before-close="handlePayDialogClose">
|
|
|
+ <el-dialog v-model="orderDialogVisible">
|
|
|
<el-row>
|
|
|
<span class="pay-dialog-title">订单支付</span>
|
|
|
</el-row>
|
|
|
@@ -259,17 +243,13 @@ const statusText = computed(() => {
|
|
|
<label>购买数量:</label>
|
|
|
{{ amount }} 件
|
|
|
</el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <label>折扣前总价:</label>
|
|
|
- {{ totalPrice }} 元
|
|
|
- </el-form-item>
|
|
|
<el-form-item>
|
|
|
<label>提货方式:</label>
|
|
|
{{ parseOrderType(type) }}
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <label>折扣后金额:</label>
|
|
|
- {{ discountPrice }} 元
|
|
|
+ <label>总价:</label>
|
|
|
+ {{ totalPrice }} 元
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<el-button @click="handleConfirmOrder" type="primary" plain>
|
|
|
@@ -299,7 +279,7 @@ const statusText = computed(() => {
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" @click="handleSendComment">评价</el-button>
|
|
|
+ <el-button type="primary" @click="handleSendComment">确定评价</el-button>
|
|
|
<el-button @click="commentDialogVisible = false">取消</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|