|
@@ -14,30 +14,17 @@
|
|
|
{{ formatOrderStatus(val) }}
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div v-for="k in val.items" :key="k.id" class="order-item-goods px-3 pt-3 cursor-pointer" @click="handleDetail(val)">
|
|
|
- <div class="d-flex align-center">
|
|
|
- <div style="width: 90px; height: 90px">
|
|
|
- <v-img :src="k.picUrl"></v-img>
|
|
|
- </div>
|
|
|
- <div class="ml-5">
|
|
|
- <p class="font-size-15">{{ k.spuName }}</p>
|
|
|
- <p class="color-999 font-size-14">{{ k.properties.map((property) => property.valueName).join(' ') }}</p>
|
|
|
- <p>
|
|
|
- <span class="color-333">¥{{ fen2yuan(k.price) }}</span>
|
|
|
- <span v-if="k.count" class="color-999 font-size-13 ml-1">x {{ k.count }}</span>
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <v-divider class="mt-3"></v-divider>
|
|
|
- </div>
|
|
|
+ <!-- 商品列表 -->
|
|
|
+ <GoodsItem v-for="k in val.items" :key="k.id" :item="k" />
|
|
|
+ <!-- 操作按钮 -->
|
|
|
<div class="text-end pa-3 font-size-13 color-666">
|
|
|
<div>共{{ val.productCount }}件商品,合计:¥{{ fen2yuan(val.payPrice) }}</div>
|
|
|
<v-btn v-if="val.buttons.length === 0" class="mt-2" variant="tonal" rounded="xl" @click.stop="handleDetail(val)">查看详情</v-btn>
|
|
|
<v-btn v-if="val.buttons.includes('confirm')" class="mt-2" variant="tonal" color="success" rounded="xl" @click.stop="handleConfirm(val)">确认收货</v-btn>
|
|
|
- <v-btn v-if="val.buttons.includes('comment')" class="mt-2" variant="tonal" rounded="xl">评价</v-btn>
|
|
|
+ <v-btn v-if="val.buttons.includes('comment')" class="mt-2" variant="tonal" rounded="xl" @click.stop="handleComment(val)">评价</v-btn>
|
|
|
<v-btn v-if="val.buttons.includes('express')" class="mt-2" variant="tonal" rounded="xl">查看物流</v-btn>
|
|
|
- <v-btn v-if="val.buttons.includes('cancel')" class="mt-2" variant="tonal" rounded="xl">取消订单</v-btn>
|
|
|
- <v-btn v-if="val.buttons.includes('delete')" class="mt-2" variant="tonal" color="error" rounded="xl">删除订单</v-btn>
|
|
|
+ <v-btn v-if="val.buttons.includes('cancel')" class="mt-2" variant="tonal" rounded="xl" @click.stop="handleCancel(val)">取消订单</v-btn>
|
|
|
+ <v-btn v-if="val.buttons.includes('delete')" class="mt-2" variant="tonal" color="error" rounded="xl" @click.stop="handleDelete(val)">删除订单</v-btn>
|
|
|
<v-btn v-if="val.buttons.includes('pay')" class="mt-2 ml-3" variant="tonal" rounded="xl">继续支付</v-btn>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -45,19 +32,25 @@
|
|
|
</div>
|
|
|
<Empty v-else :elevation="false" :message="tab === -1 ? '暂无订单' : '暂无' + tabList.find(e => e.value === tab).title + '订单'"></Empty>
|
|
|
</div>
|
|
|
+
|
|
|
+ <CtDialog :visible="showDialog" titleClass="text-h6" :footer="true" :widthType="3" title="商品评论" @submit="handleSubmit" @close="handleClose">
|
|
|
+ <CommentForm ref="commentFormRef" v-if="showDialog" :orderId="commentOrderId" />
|
|
|
+ </CtDialog>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
defineOptions({ name: 'mall-user-order-index'})
|
|
|
import { ref } from 'vue'
|
|
|
-import { getMallOrderPage, receiveOrder } from '@/api/mall/user'
|
|
|
+import { getMallOrderPage, receiveOrder, deleteTradeOrder, cancelTradeOrder, createOrderItemComment } from '@/api/mall/user'
|
|
|
import { timesTampChange } from '@/utils/date'
|
|
|
import { fen2yuan, handleOrderButtons, formatOrderStatus, formatOrderColor } from '@/hooks/web/useGoods'
|
|
|
import Confirm from '@/plugins/confirm'
|
|
|
import Snackbar from '@/plugins/snackbar'
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
+import GoodsItem from '../../components/GoodsItem/index.vue'
|
|
|
+import CommentForm from './commentForm.vue'
|
|
|
+// import { useRouter } from 'vue-router'
|
|
|
|
|
|
-const router = useRouter()
|
|
|
+// const router = useRouter()
|
|
|
const tab = ref(-1)
|
|
|
const tabList = [
|
|
|
{ title: '全部', value: -1 },
|
|
@@ -99,6 +92,53 @@ const handleDetail = ({ id }) => {
|
|
|
window.open(`/mall/user/order/detail/${id}`)
|
|
|
}
|
|
|
|
|
|
+// 删除订单
|
|
|
+const handleDelete = async ({ id }) => {
|
|
|
+ Confirm('系统提示', '是否确认删除该订单?').then(async () => {
|
|
|
+ await deleteTradeOrder(id)
|
|
|
+ Snackbar.success('删除成功')
|
|
|
+ await getOrderPage()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 取消订单
|
|
|
+const handleCancel = async ({ id }) => {
|
|
|
+ Confirm('系统提示', '是否确认取消该订单?').then(async () => {
|
|
|
+ await cancelTradeOrder(id)
|
|
|
+ Snackbar.success('取消成功')
|
|
|
+ await getOrderPage()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 商品评论
|
|
|
+const showDialog = ref(false)
|
|
|
+const commentOrderId = ref(null) // 订单id
|
|
|
+const commentFormRef = ref()
|
|
|
+const handleComment = (val) => {
|
|
|
+ commentOrderId.value = val.id
|
|
|
+ showDialog.value = true
|
|
|
+}
|
|
|
+const handleClose = () => {
|
|
|
+ commentOrderId.value = null
|
|
|
+ showDialog.value = false
|
|
|
+}
|
|
|
+const handleSubmit = async () => {
|
|
|
+ const commentList = commentFormRef.value.commentList
|
|
|
+ for (const comment of commentList) {
|
|
|
+ await createOrderItemComment(comment)
|
|
|
+ }
|
|
|
+ Snackbar.success('评论成功')
|
|
|
+ handleClose()
|
|
|
+ getOrderPage()
|
|
|
+}
|
|
|
+
|
|
|
+// 收货成功后提示去评论
|
|
|
+const handlePromptComment = (id) => {
|
|
|
+ Confirm('确认收货成功', '是否前往评价?', { sureText: '立即评价', cancelText: '关闭' }).then(() => {
|
|
|
+ handleComment({ id })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
// 确认收货
|
|
|
const handleConfirm = ({ id }) => {
|
|
|
if (!id) return
|
|
@@ -107,8 +147,10 @@ const handleConfirm = ({ id }) => {
|
|
|
Snackbar.success('收货成功')
|
|
|
queryParams.value.pageNo = 1
|
|
|
await getOrderPage()
|
|
|
+ handlePromptComment(id) // 收货成功后提示去评论
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|