|
@@ -13,7 +13,8 @@
|
|
|
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
|
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
|
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
|
|
import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
|
import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
|
|
-import { orderList, orderStatusEnum } from '@/api/order'
|
|
|
|
|
|
|
+import { getConfigByCode } from '@/api/common'
|
|
|
|
|
+import { orderList, orderStatusEnum, recycleOrder, userCanRecycleNum } from '@/api/order'
|
|
|
import { DialogBox } from '@/components/DialogBox'
|
|
import { DialogBox } from '@/components/DialogBox'
|
|
|
import { t } from '@/locale'
|
|
import { t } from '@/locale'
|
|
|
import { formatNumber } from '@/utils'
|
|
import { formatNumber } from '@/utils'
|
|
@@ -53,6 +54,41 @@ const tabList = ref<any>([
|
|
|
value: 4,
|
|
value: 4,
|
|
|
},
|
|
},
|
|
|
])
|
|
])
|
|
|
|
|
+
|
|
|
|
|
+// 搜索结果
|
|
|
|
|
+const dataList = ref<any[]>([])
|
|
|
|
|
+
|
|
|
|
|
+const maxSelectCount = ref<number>(0) // 最大可选订单数量
|
|
|
|
|
+const selectedOrders = ref<string[]>([]) // 已选中的订单ID列表
|
|
|
|
|
+
|
|
|
|
|
+const recycleProportion = ref<string>('')
|
|
|
|
|
+const recycleRate = ref<number>(0)
|
|
|
|
|
+
|
|
|
|
|
+async function getRecycleProportion() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await getConfigByCode({ code: 'recycle_proportion' })
|
|
|
|
|
+ if (res.code === '200' && res.data?.valueInfo) {
|
|
|
|
|
+ let rate = Number(res.data.valueInfo) || 0
|
|
|
|
|
+ if (rate > 1)
|
|
|
|
|
+ rate = rate / 100
|
|
|
|
|
+ recycleRate.value = rate
|
|
|
|
|
+ recycleProportion.value = String(rate * 100)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch {
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function getUserCanRecycleNum() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await userCanRecycleNum()
|
|
|
|
|
+ if (res.code === '200') {
|
|
|
|
|
+ maxSelectCount.value = Number(res.data) || 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch {
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
const orderStatusEnumData = ref<any>([])
|
|
const orderStatusEnumData = ref<any>([])
|
|
|
async function getOrderStatus() {
|
|
async function getOrderStatus() {
|
|
|
try {
|
|
try {
|
|
@@ -66,13 +102,6 @@ async function getOrderStatus() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 搜索结果
|
|
|
|
|
-const dataList = ref<any[]>([])
|
|
|
|
|
-
|
|
|
|
|
-// TODO: 后期从接口获取最大可选订单数量
|
|
|
|
|
-const maxSelectCount = ref<number>(5) // 最大可选订单数量
|
|
|
|
|
-const selectedOrders = ref<string[]>([]) // 已选中的订单ID列表
|
|
|
|
|
-
|
|
|
|
|
// 判断订单是否已选中
|
|
// 判断订单是否已选中
|
|
|
function isOrderSelected(orderId: string) {
|
|
function isOrderSelected(orderId: string) {
|
|
|
return selectedOrders.value.includes(orderId)
|
|
return selectedOrders.value.includes(orderId)
|
|
@@ -99,6 +128,7 @@ function toggleOrderSelection(orderId: string) {
|
|
|
// 切换tab时清空选中状态
|
|
// 切换tab时清空选中状态
|
|
|
function handleTabChange() {
|
|
function handleTabChange() {
|
|
|
selectedOrders.value = []
|
|
selectedOrders.value = []
|
|
|
|
|
+ getUserCanRecycleNum()
|
|
|
queryList(1, 20)
|
|
queryList(1, 20)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -115,6 +145,10 @@ const totalAmount = computed(() => {
|
|
|
}, 0)
|
|
}, 0)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const recycleAmount = computed(() => {
|
|
|
|
|
+ return totalAmount.value * recycleRate.value
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
// 弹框状态
|
|
// 弹框状态
|
|
|
const showRecycleDialog = ref(false)
|
|
const showRecycleDialog = ref(false)
|
|
|
|
|
|
|
@@ -126,28 +160,32 @@ function handleRecycleOrder() {
|
|
|
// 确认回收订单
|
|
// 确认回收订单
|
|
|
async function confirmRecycle() {
|
|
async function confirmRecycle() {
|
|
|
try {
|
|
try {
|
|
|
- // TODO: 后续调用回收订单的接口
|
|
|
|
|
- console.log('选中的订单ID:', selectedOrders.value)
|
|
|
|
|
- console.log('总金额:', totalAmount.value)
|
|
|
|
|
|
|
+ if (selectedOrders.value.length === 0) {
|
|
|
|
|
+ toast.info(t('myOrders.selectTip', [maxSelectCount.value]))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 模拟接口调用
|
|
|
|
|
- // const res = await recycleOrderApi({ orderIds: selectedOrders.value })
|
|
|
|
|
- // if (res.code === '200') {
|
|
|
|
|
- // toast.success(t('myOrders.recycleSuccess'))
|
|
|
|
|
- // selectedOrders.value = []
|
|
|
|
|
- // queryList(1, 20) // 刷新列表
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: t('common.loading'),
|
|
|
|
|
+ mask: true,
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- // 临时模拟成功
|
|
|
|
|
- toast.success(t('myOrders.recycleSuccess'))
|
|
|
|
|
|
|
+ const res = await recycleOrder({ orderNos: selectedOrders.value })
|
|
|
|
|
+ if (res.code === '200') {
|
|
|
|
|
+ toast.success(t('myOrders.recycleSuccess'))
|
|
|
|
|
+ }
|
|
|
selectedOrders.value = []
|
|
selectedOrders.value = []
|
|
|
// 刷新列表
|
|
// 刷新列表
|
|
|
paging.value?.reload()
|
|
paging.value?.reload()
|
|
|
|
|
+ getUserCanRecycleNum()
|
|
|
}
|
|
}
|
|
|
catch (error) {
|
|
catch (error) {
|
|
|
console.error('回收订单失败:', error)
|
|
console.error('回收订单失败:', error)
|
|
|
toast.error(t('myOrders.recycleFailed'))
|
|
toast.error(t('myOrders.recycleFailed'))
|
|
|
}
|
|
}
|
|
|
|
|
+ finally {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
async function queryList(pageNo: number, pageSize: number) {
|
|
async function queryList(pageNo: number, pageSize: number) {
|
|
|
// 此处请求仅为演示,请替换为自己项目中的请求
|
|
// 此处请求仅为演示,请替换为自己项目中的请求
|
|
@@ -163,6 +201,9 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
type: tab.value, // 根据tab的值来查询不同状态的订单
|
|
type: tab.value, // 根据tab的值来查询不同状态的订单
|
|
|
})
|
|
})
|
|
|
paging.value.complete(res.data.list)
|
|
paging.value.complete(res.data.list)
|
|
|
|
|
+ if (pageNo === 1) {
|
|
|
|
|
+ getUserCanRecycleNum()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
catch {
|
|
catch {
|
|
|
paging.value.complete(false)
|
|
paging.value.complete(false)
|
|
@@ -176,6 +217,8 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
}
|
|
}
|
|
|
onLoad((options) => {
|
|
onLoad((options) => {
|
|
|
getOrderStatus()
|
|
getOrderStatus()
|
|
|
|
|
+ getUserCanRecycleNum()
|
|
|
|
|
+ getRecycleProportion()
|
|
|
|
|
|
|
|
// 处理页面参数,如果有type参数则切换到对应的tab
|
|
// 处理页面参数,如果有type参数则切换到对应的tab
|
|
|
if (options) {
|
|
if (options) {
|
|
@@ -300,7 +343,7 @@ onLoad((options) => {
|
|
|
{{ $t('myOrders.total') }}:
|
|
{{ $t('myOrders.total') }}:
|
|
|
</text>
|
|
</text>
|
|
|
<text class="text-[var(--wot-color-theme)]">
|
|
<text class="text-[var(--wot-color-theme)]">
|
|
|
- ৳{{ formatNumber(totalAmount) }}
|
|
|
|
|
|
|
+ ৳{{ formatNumber(recycleAmount) }}
|
|
|
</text>
|
|
</text>
|
|
|
</view>
|
|
</view>
|
|
|
<wd-button
|
|
<wd-button
|
|
@@ -330,14 +373,14 @@ onLoad((options) => {
|
|
|
<view class="pb-32rpx text-24rpx text-#666">
|
|
<view class="pb-32rpx text-24rpx text-#666">
|
|
|
<view class="space-y-16rpx">
|
|
<view class="space-y-16rpx">
|
|
|
<view>{{ $t('myOrders.dialog.note1') }}</view>
|
|
<view>{{ $t('myOrders.dialog.note1') }}</view>
|
|
|
- <view>{{ $t('myOrders.dialog.note2') }}</view>
|
|
|
|
|
|
|
+ <view>{{ $t('myOrders.dialog.note2', [recycleProportion]) }}</view>
|
|
|
<view>{{ $t('myOrders.dialog.note3') }}</view>
|
|
<view>{{ $t('myOrders.dialog.note3') }}</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="mb-44rpx text-center">
|
|
<view class="mb-44rpx text-center">
|
|
|
<text>{{ $t('myOrders.dialog.priceLabel') }}: </text>
|
|
<text>{{ $t('myOrders.dialog.priceLabel') }}: </text>
|
|
|
<text class="text-[var(--wot-color-theme)]">
|
|
<text class="text-[var(--wot-color-theme)]">
|
|
|
- ৳{{ formatNumber(totalAmount) }}
|
|
|
|
|
|
|
+ ৳{{ formatNumber(recycleAmount) }}
|
|
|
</text>
|
|
</text>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|