feat(订单)

This commit is contained in:
Ankkaya 2024-08-22 16:32:15 +08:00
parent 05ce9595e7
commit bfe36ac0e8
6 changed files with 152 additions and 4 deletions

View File

@ -38,7 +38,7 @@
<view class="item" v-for="(item, index) in state.more" :key="item.name"> <view class="item" v-for="(item, index) in state.more" :key="item.name">
<view class="label">{{ item.name }}</view> <view class="label">{{ item.name }}</view>
<view class="value">{{ index !== 0 ? item.value : fen2yuan(item.value) }}</view> <view class="value">{{ index !== 0 ? item.value : fen2yuan(item.value) }}</view>
<view class="last"> 昨日 {{ item.last }} </view> <view class="last"> 昨日 {{ index === 0 ? fen2yuan(item.last) : item.last }} </view>
</view> </view>
</view> </view>
</view> </view>

View File

@ -22,7 +22,7 @@
v-for="order in state.pagination.list" v-for="order in state.pagination.list"
:key="order.id" :key="order.id"
> >
<view @tap="onOrderDetail(order.id)"> <view @tap="onOrderDetail(order.id, state.currentTab)">
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20"> <view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
<view class="order-no">订单号{{ order.no }}</view> <view class="order-no">订单号{{ order.no }}</view>
<view class="order-state ss-font-26" :class="formatOrderColor(order)"> <view class="order-state ss-font-26" :class="formatOrderColor(order)">
@ -153,13 +153,15 @@ const tabMaps = [
{ {
name: '已付款', name: '已付款',
value: '50,60', value: '50,60',
commentStatus: 2,
}, },
{ {
name: '已评价', name: '已评价',
value: '30', value: '30',
commentStatus: 1,
}, },
{ {
name: '已退', name: '已退',
value: '10,20', value: '10,20',
}, },
] ]
@ -211,6 +213,7 @@ function onTabsChange(e) {
function onOrderDetail(id) { function onOrderDetail(id) {
peach.$router.go('/pages/order/detail', { peach.$router.go('/pages/order/detail', {
id, id,
currentTabIndex: state.value.currentTab,
}) })
} }
@ -222,6 +225,11 @@ async function getOrderList() {
pageSize: state.value.pagination.pageSize, pageSize: state.value.pagination.pageSize,
status: state.value.currentTab !== 3 ? tabMaps[state.value.currentTab].value : undefined, status: state.value.currentTab !== 3 ? tabMaps[state.value.currentTab].value : undefined,
refundStatus: state.value.currentTab === 3 ? tabMaps[state.value.currentTab].value : undefined, refundStatus: state.value.currentTab === 3 ? tabMaps[state.value.currentTab].value : undefined,
commentStatus: tabMaps[state.value.currentTab].commentStatus
? state.value.currentTab === 1
? false
: true
: undefined,
}) })
data.list.forEach((item) => { data.list.forEach((item) => {

View File

@ -115,6 +115,56 @@
</button> </button>
</view> </view>
</template> --> </template> -->
<template #refund>
<view
class="refund-content"
v-if="
(state.currentTabIndex == 3 || state.currentTabIndex == 0) &&
item.refundStatus === 4
"
>
<view class="refund-item">
<view class="ss-flex ss-flex-1">
<text class="title">退款原因</text>
<text class="detail">{{ item.refundReason }}</text>
</view>
</view>
<view class="refund-item">
<view class="ss-flex ss-flex-1">
<text class="title">备注</text>
<text class="detail">{{ item.refundRemark || '-' }}</text>
</view>
</view>
</view>
</template>
<template #comment>
<view
class="form-item"
v-if="(state.currentTabIndex == 2 || state.currentTabIndex == 0) && item.comment"
>
<view class="divide-line"></view>
<view class="star-box ss-flex ss-col-center">
<view class="star-title ss-m-r-40">商品质量</view>
<uni-rate v-model="item.comment.descriptionScores" />
</view>
<view class="star-box ss-flex ss-col-center">
<view class="star-title ss-m-r-40">服务态度</view>
<uni-rate v-model="item.comment.benefitScores" />
</view>
<!-- 评价 -->
<view class="area-box">
<uni-easyinput
:inputBorder="false"
type="textarea"
maxlength="120"
autoHeight
v-model="item.comment.content"
/>
</view>
</view>
</template>
<template #priceSuffix> <template #priceSuffix>
<button class="ss-reset-button tag-btn" v-if="item.status_text"> <button class="ss-reset-button tag-btn" v-if="item.status_text">
{{ item.status_text }} {{ item.status_text }}
@ -269,6 +319,7 @@ import OrderApi from '@/peach/api/trade/order'
const statusBarHeight = peach.$platform.device.statusBarHeight * 2 const statusBarHeight = peach.$platform.device.statusBarHeight * 2
const state = reactive({ const state = reactive({
currentTabIndex: -1,
orderInfo: {}, orderInfo: {},
merchantTradeNo: '', // merchantTradeNo: '', //
comeinType: '', // comeinType: '', //
@ -396,8 +447,24 @@ async function getOrderDetail(id) {
handleOrderButtons(state.orderInfo) handleOrderButtons(state.orderInfo)
} }
async function getOrderComment(id) {
let res = await OrderApi.orderComment(id)
if (res.data.length > 0) {
for (let item of state.orderInfo.items) {
let temp = res.data.find((sitem) => item.id === sitem.orderItemId)
if (temp) {
item.comment = temp
}
}
}
}
onLoad(async (options) => { onLoad(async (options) => {
state.currentTabIndex = options.currentTabIndex
await getOrderDetail(options.id) await getOrderDetail(options.id)
await getOrderComment(options.id)
}) })
</script> </script>
@ -488,6 +555,55 @@ onLoad(async (options) => {
border-radius: 14rpx; border-radius: 14rpx;
padding: 0 4rpx; padding: 0 4rpx;
} }
.refund-content {
padding: 20rpx;
.refund-item {
display: flex;
align-items: center;
line-height: normal;
margin-bottom: 24rpx;
.title {
font-size: 28rpx;
color: #999;
}
.detail {
font-size: 28rpx;
color: #333;
flex: 1;
}
}
}
.form-item {
.divide-line {
height: 1px;
background-color: #f9fafb;
width: 100%;
margin: 20rpx;
}
background: #fff;
.star-box {
height: 50rpx;
padding: 0 25rpx;
}
.star-title {
font-weight: 600;
}
.area-box {
width: 690rpx;
border-radius: 20rpx;
padding: 28rpx;
margin: auto;
.img-box {
margin-top: 20rpx;
}
}
}
} }
} }
} }

View File

@ -36,6 +36,14 @@ const OrderUtil = {
data: data, data: data,
}) })
}, },
// 订单商品评论
orderComment: (id) => {
return request({
url: '/product/comment/get-by-order-id/' + id,
method: 'GET',
})
},
} }
export default OrderUtil export default OrderUtil

View File

@ -40,6 +40,12 @@
</view> </view>
</view> </view>
</view> </view>
<view>
<slot name="refund"></slot>
</view>
<view>
<slot name="comment"></slot>
</view>
</view> </view>
</template> </template>

View File

@ -88,6 +88,12 @@ export function formatOrderStatusDescription(order) {
} }
export function formatOrderStatus(order) { export function formatOrderStatus(order) {
if (order.refundStatus === 10) {
return '部分退款'
}
if (order.refundStatus === 20) {
return '整单退款'
}
if (order.status === 0) { if (order.status === 0) {
return '待付款' return '待付款'
} }
@ -104,7 +110,7 @@ export function formatOrderStatus(order) {
return '待评价' return '待评价'
} }
if (order.status === 30 && order.commentStatus) { if (order.status === 30 && order.commentStatus) {
return '已完成' return '已评价'
} }
if (order.status === 50) { if (order.status === 50) {
return '待核销' return '待核销'
@ -116,6 +122,10 @@ export function formatOrderStatus(order) {
} }
export function formatOrderColor(order) { export function formatOrderColor(order) {
if (order.refundStatus === 10 || order.refundStatus === 20) {
return 'danger-color'
}
if (order.status === 0) { if (order.status === 0) {
return 'info-color' return 'info-color'
} }