|
|
@@ -1,7 +1,9 @@
|
|
|
<script setup lang="ts">
|
|
|
import {ref, computed} from "vue"
|
|
|
-import {deliverOrder, getOrder, getOrderById, commentOrder, payOrder} from "../api/order"
|
|
|
-import {parseOrderType, parseRating, parseTime} from "../utils";
|
|
|
+import PayDialog from "./PayDialog.vue"
|
|
|
+import {deliverOrder, getOrder, getOrderById, commentOrder} from "../api/order.ts"
|
|
|
+import {parseOrderType, parseRating, parseTime} from "../utils"
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
orderId: {
|
|
|
type: Number,
|
|
|
@@ -11,36 +13,36 @@ const props = defineProps({
|
|
|
|
|
|
const role = sessionStorage.getItem("role")
|
|
|
|
|
|
-const orderDialogVisible = ref(false)
|
|
|
-const commentDialogVisible = ref(false)
|
|
|
-
|
|
|
+//订单详细信息
|
|
|
const userId = ref(0)
|
|
|
const productId = ref(0)
|
|
|
-const productName = ref('')
|
|
|
-const price = ref(0)
|
|
|
-const amount = ref(0)
|
|
|
-const paid = ref(0)
|
|
|
-const type = ref('')
|
|
|
-const content = ref('')
|
|
|
-const rating = ref(0)
|
|
|
-const status = ref('')
|
|
|
+const productName = ref('') //商品名字
|
|
|
+const price = ref(0) //商品单价
|
|
|
+const amount = ref(0) //购买数量
|
|
|
+const type = ref('') //订单类型
|
|
|
+const rating = ref(0) //订单评分
|
|
|
+const content = ref('') //订单评论
|
|
|
+const status = ref('') //订单状态
|
|
|
const createTime = ref('')
|
|
|
const finishTime = ref('')
|
|
|
const storeId = ref(0)
|
|
|
-
|
|
|
+//订单总价(折扣前)
|
|
|
const totalPrice = ref(0)
|
|
|
|
|
|
+//评论dialog
|
|
|
+const commentDialogVisible = ref(false)
|
|
|
+
|
|
|
+const dialogRef = ref()
|
|
|
+
|
|
|
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
|
|
|
amount.value = res.data.result.amount
|
|
|
price.value = res.data.result.price
|
|
|
- paid.value = res.data.result.paid
|
|
|
type.value = res.data.result.type
|
|
|
content.value = res.data.result.content
|
|
|
rating.value = parseRating(res.data.result.rating)
|
|
|
@@ -48,35 +50,24 @@ function getOrderDetail() {
|
|
|
createTime.value = res.data.result.createTime
|
|
|
finishTime.value = res.data.result.finishTime
|
|
|
storeId.value = res.data.result.storeId
|
|
|
-
|
|
|
- totalPrice.value = amount.value * price.value
|
|
|
+ //根据单价和购买数量计算总价
|
|
|
+ totalPrice.value = price.value * amount.value
|
|
|
})
|
|
|
}
|
|
|
|
|
|
function handlePay() {
|
|
|
- orderDialogVisible.value = true
|
|
|
+ //触发支付订单弹窗,传入当前orderId
|
|
|
+ dialogRef.value.open(props.orderId)
|
|
|
}
|
|
|
|
|
|
-function handleConfirmOrder() {
|
|
|
- payOrder(props.orderId).then(res => {
|
|
|
- if (res.data.code === '000') {
|
|
|
- ElMessage({
|
|
|
- message: '订单提交成功!',
|
|
|
- type: 'success',
|
|
|
- center: true,
|
|
|
- })
|
|
|
- getOrderDetail()
|
|
|
- orderDialogVisible.value = false
|
|
|
- } else if (res.data.code === '400') {
|
|
|
- ElMessage({
|
|
|
- message: res.data.msg,
|
|
|
- type: 'error',
|
|
|
- center: true,
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+//注册回调,用于更新当前订单详情(如果不用这个,可能只能强制刷新整个界面了,用户体验不好)
|
|
|
+function handleConfirmOrder(success: boolean) {
|
|
|
+ if (success) {
|
|
|
+ getOrderDetail()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+//发货
|
|
|
function handleDeliver() {
|
|
|
deliverOrder(props.orderId).then(res => {
|
|
|
if (res.data.code === '000') {
|
|
|
@@ -96,6 +87,7 @@ function handleDeliver() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+//收货
|
|
|
function handleGet() {
|
|
|
getOrder(props.orderId).then(res => {
|
|
|
if (res.data.code === '000') {
|
|
|
@@ -115,10 +107,12 @@ function handleGet() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+//打开评论dialog
|
|
|
function handleComment() {
|
|
|
commentDialogVisible.value = true
|
|
|
}
|
|
|
|
|
|
+//评论
|
|
|
function handleSendComment() {
|
|
|
const payload = {
|
|
|
orderId: props.orderId,
|
|
|
@@ -232,38 +226,10 @@ const statusText = computed(() => {
|
|
|
</el-descriptions>
|
|
|
</el-card>
|
|
|
|
|
|
- <el-dialog v-model="orderDialogVisible">
|
|
|
- <el-row>
|
|
|
- <span class="pay-dialog-title">订单支付</span>
|
|
|
- </el-row>
|
|
|
-
|
|
|
- <div>
|
|
|
- <el-form>
|
|
|
- <el-form-item>
|
|
|
- <label>购买数量:</label>
|
|
|
- {{ amount }} 件
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <label>提货方式:</label>
|
|
|
- {{ parseOrderType(type) }}
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <label>总价:</label>
|
|
|
- {{ totalPrice }} 元
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <el-button @click="handleConfirmOrder" type="primary" plain>
|
|
|
- 确认支付
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
+ <PayDialog ref="dialogRef" @operation-finish="handleConfirmOrder"/>
|
|
|
|
|
|
- <el-dialog
|
|
|
- v-model="commentDialogVisible"
|
|
|
- title="发起评价"
|
|
|
- >
|
|
|
+ <el-dialog v-model="commentDialogVisible" title="发起评价">
|
|
|
<el-form>
|
|
|
-
|
|
|
<el-form-item>
|
|
|
<span style="margin-right: 30px">商品满意度</span>
|
|
|
<el-rate v-model="rating" clearable
|
|
|
@@ -284,7 +250,6 @@ const statusText = computed(() => {
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-dialog>
|
|
|
-
|
|
|
</template>
|
|
|
|
|
|
|
|
|
@@ -304,9 +269,4 @@ const statusText = computed(() => {
|
|
|
.status-change-button {
|
|
|
margin-left: 10px;
|
|
|
}
|
|
|
-
|
|
|
-.pay-dialog-title {
|
|
|
- font-size: 30px;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
</style>
|