|
|
@@ -1,7 +1,4 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { StaticUrl } from '@/config'
|
|
|
-import router from '@/router'
|
|
|
-
|
|
|
definePage({
|
|
|
name: 'common-afterSales',
|
|
|
islogin: true,
|
|
|
@@ -11,8 +8,8 @@ definePage({
|
|
|
})
|
|
|
const afterSalesType = ref(1)
|
|
|
const isSeletAllGoods = ref(false)
|
|
|
-const selectGoods = ref([])
|
|
|
-const fileList = ref([])
|
|
|
+const selectGoods = ref<number[]>([])
|
|
|
+const fileList = ref<{ url: string }[]>([])
|
|
|
const showReson = ref(false)
|
|
|
const resonId = ref()
|
|
|
const resonName = ref('请选择退款原因')
|
|
|
@@ -23,22 +20,71 @@ const resonList = [
|
|
|
{ id: 4, name: '商品斤两不足' },
|
|
|
{ id: 5, name: '商品临期到期' },
|
|
|
{ id: 6, name: '商品破损/包装破损' },
|
|
|
+ { id: 7, name: '其他' },
|
|
|
]
|
|
|
const orderList = ref<Api.xsbOmsOrderItem[]>([])
|
|
|
+const remark = ref('')
|
|
|
onLoad((options: any) => {
|
|
|
orderList.value = JSON.parse(options.order)
|
|
|
- if (orderList.value.length) {
|
|
|
- orderList.value.map((it) => {
|
|
|
- it.num = undefined
|
|
|
- return it
|
|
|
- })
|
|
|
- }
|
|
|
+ orderList.value = orderList.value.map((item: Api.xsbOmsOrderItem) => {
|
|
|
+ item.num = 1
|
|
|
+ return item
|
|
|
+ })
|
|
|
})
|
|
|
+const refunMoney = ref(0)
|
|
|
+const isSubmit = ref(false)
|
|
|
|
|
|
-function handleSubmit() {
|
|
|
+async function handleSubmit() {
|
|
|
console.log(fileList.value, 'fileList')
|
|
|
- router.push({ name: 'xsb-afterSalesDetail' })
|
|
|
+ if (!selectGoods.value.length) {
|
|
|
+ useGlobalToast().show({ msg: '请选择需要退款的商品' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!resonId.value) {
|
|
|
+ useGlobalToast().show({ msg: '请选择退款原因' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!orderList.value[0].orderNumber) {
|
|
|
+ useGlobalToast().show({ msg: '订单数据异常' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ isSubmit.value = true
|
|
|
+ try {
|
|
|
+ await cathcApplRefund()
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ isSubmit.value = false
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ // router.push({ name: 'common-afterSalesDetail' })
|
|
|
+}
|
|
|
+
|
|
|
+function cathcApplRefund() {
|
|
|
+ uni.showLoading({ mask: true })
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const filerData = orderList.value.filter(it => selectGoods.value.includes(Number(it.skuId)))
|
|
|
+ Apis.xsb.applyRefund({
|
|
|
+ data: {
|
|
|
+ orderNumber: orderList.value[0].orderNumber,
|
|
|
+ businessType: 1,
|
|
|
+ applyType: afterSalesType.value,
|
|
|
+ refundType: 2,
|
|
|
+ buyerReason: resonName.value,
|
|
|
+ buyerDesc: remark.value,
|
|
|
+ photoFiles: fileList.value.map(it => it.url).join(','),
|
|
|
+ orderRefundSkuList: filerData.map((it) => {
|
|
|
+ return {
|
|
|
+ orderItemId: it.orderItemId,
|
|
|
+ productCount: it.num,
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ }).then((res) => { resolve(res) }).catch((err) => {
|
|
|
+ reject(err)
|
|
|
+ }).finally(() => { uni.hideLoading() })
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
function handleSelectReson() {
|
|
|
if (!resonId.value)
|
|
|
return uni.showToast({ title: '请选择退款原因', icon: 'none' })
|
|
|
@@ -46,9 +92,50 @@ function handleSelectReson() {
|
|
|
resonName.value = resonList.find(item => item.id === resonId.value)?.name || '请选择退款原因'
|
|
|
}
|
|
|
|
|
|
-watch(() => orderList.value, () => {
|
|
|
- console.log(orderList.value, '=============')
|
|
|
+function handleSelectGoods() {
|
|
|
+ console.log(orderList.value, 'orderList', selectGoods.value)
|
|
|
+ if (selectGoods.value.length === orderList.value.length) {
|
|
|
+ isSeletAllGoods.value = true
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ isSeletAllGoods.value = false
|
|
|
+ refunMoney.value = 0
|
|
|
+ }
|
|
|
+}
|
|
|
+function handleChangeAll() {
|
|
|
+ console.log(isSeletAllGoods.value, 'isSeletAllGoods')
|
|
|
+ if (isSeletAllGoods.value) {
|
|
|
+ selectGoods.value = orderList.value.map(it => it.skuId) as number[]
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ selectGoods.value = []
|
|
|
+ refunMoney.value = 0
|
|
|
+ }
|
|
|
+}
|
|
|
+watch(() => [selectGoods.value, orderList.value], () => {
|
|
|
+ if (selectGoods.value.length) {
|
|
|
+ getReufndMoney()
|
|
|
+ }
|
|
|
})
|
|
|
+async function getReufndMoney() {
|
|
|
+ console.log(orderList.value[0].orderNumber, 'orderList.value')
|
|
|
+ const filerData = orderList.value.filter(it => selectGoods.value.includes(Number(it.skuId)))
|
|
|
+ const res = await Apis.xsb.calculateMoney({ data: {
|
|
|
+ orderNumber: String(orderList.value[0].orderNumber),
|
|
|
+ orderRefundSkuList: filerData.map((it) => {
|
|
|
+ return {
|
|
|
+ orderItemId: it.orderItemId,
|
|
|
+ productCount: it.num,
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ } })
|
|
|
+ refunMoney.value = res.data
|
|
|
+}
|
|
|
+function handleChangeMoney() {
|
|
|
+ if (selectGoods.value.length) {
|
|
|
+ getReufndMoney()
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -96,23 +183,23 @@ watch(() => orderList.value, () => {
|
|
|
退款商品
|
|
|
</view>
|
|
|
<view class="text-28rpx text-#FF4D3A font-semibold">
|
|
|
- 退款金额:¥21
|
|
|
+ 退款金额:¥{{ refunMoney }}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="mt24rpx">
|
|
|
- <wd-checkbox v-model="isSeletAllGoods">
|
|
|
+ <wd-checkbox v-model="isSeletAllGoods" @change="handleChangeAll">
|
|
|
全选
|
|
|
</wd-checkbox>
|
|
|
</view>
|
|
|
<view class="mt24rpx h2rpx w-full bg-#F0F0F0" />
|
|
|
<view class="goods mt24rpx">
|
|
|
<CollapsePanel :line-height="150">
|
|
|
- <wd-checkbox-group v-model="selectGoods">
|
|
|
+ <wd-checkbox-group v-model="selectGoods" @change="handleSelectGoods">
|
|
|
<template v-for="item in orderList" :key="item.skuId">
|
|
|
- <view class="mb20rpx flex items-center justify-between">
|
|
|
+ <view class="flex items-center justify-between">
|
|
|
<wd-checkbox :model-value="item.skuId" />
|
|
|
<view class="box-border w-full flex items-center">
|
|
|
- <image :src="`${StaticUrl}/shu.png`" class="h120rpx w120rpx flex-shrink-0" />
|
|
|
+ <image :src="item.pic" class="h120rpx w120rpx flex-shrink-0" />
|
|
|
<view class="ml20rpx box-border flex-1">
|
|
|
<view class="w-full flex justify-between">
|
|
|
<view class="max-w-320rpx whitespace-pre-wrap break-words break-all text-28rpx">
|
|
|
@@ -130,13 +217,13 @@ watch(() => orderList.value, () => {
|
|
|
单价:¥{{ item.price }}
|
|
|
</view>
|
|
|
<view>
|
|
|
- <wd-input-number v-model="item.num" :max="item.prodCount" :min="1" />
|
|
|
+ <wd-input-number v-model="item.num" :max="item.prodCount" :min="1" @change="handleChangeMoney" />
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="mt20rpx h2rpx w-full bg-#F0F0F0" />
|
|
|
+ <view class="my20rpx h2rpx w-full bg-#F0F0F0" />
|
|
|
</template>
|
|
|
</wd-checkbox-group>
|
|
|
</CollapsePanel>
|
|
|
@@ -154,7 +241,7 @@ watch(() => orderList.value, () => {
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="mt20rpx rounded-16rpx bg-#F6F6F6 p24rpx">
|
|
|
- <wd-textarea placeholder="请填写退款原因" show-word-limit :maxlength="200" />
|
|
|
+ <wd-textarea v-model="remark" placeholder="请填写退款原因" show-word-limit :maxlength="200" />
|
|
|
<view class="upload mt18rpx">
|
|
|
<Zupload v-model:value="fileList" />
|
|
|
</view>
|
|
|
@@ -197,7 +284,7 @@ watch(() => orderList.value, () => {
|
|
|
<view
|
|
|
class="ios fixed bottom-0 z-10 box-border w-full w-full rounded-t-32rpx bg-white px32rpx pt-16rpx"
|
|
|
>
|
|
|
- <wd-button block @click="handleSubmit">
|
|
|
+ <wd-button block :loading="isSubmit" @click="handleSubmit">
|
|
|
提交
|
|
|
</wd-button>
|
|
|
</view>
|