Files
yshop-pro-uniapp/pages/selectRefundGood/selectRefundGood.vue

209 lines
4.4 KiB
Vue
Raw Normal View History

2023-10-11 11:27:47 +08:00
<template>
<layout>
<uv-navbar
2023-11-14 17:21:03 +08:00
:fixed="false"
title="选择商品"
left-arrow
@leftClick="goBack"
2023-10-11 11:27:47 +08:00
/>
<uv-checkbox-group
2023-11-14 17:21:03 +08:00
v-if="goodsList"
v-model="goodsSelect"
shape="circle"
activeColor="#ec6e47"
@change="handleGoodsSelect"
2023-10-11 11:27:47 +08:00
>
<space
2023-11-14 17:21:03 +08:00
direction="vertical"
fill
2023-10-11 11:27:47 +08:00
>
<card class="shopping-checkbox">
<view
2023-11-14 17:21:03 +08:00
v-for="(item, index) in goodsList"
class="shopping-checkbox-cell"
2023-10-11 11:27:47 +08:00
>
<uv-checkbox
2023-11-14 17:21:03 +08:00
:name="item.cartInfo.productAttrUnique"
:disabled="item.isAfterSales != 1"
2023-10-11 11:27:47 +08:00
/>
<goods
2023-11-14 17:21:03 +08:00
list
interval
showAction
model
:price="item.cartInfo.truePrice"
:data="item.cartInfo.productInfo"
2023-10-11 11:27:47 +08:00
>
</goods>
</view>
</card>
</space>
</uv-checkbox-group>
<view class="action-bar column">
<view class="action-info">
<view class="action-checkbox">
2023-11-14 17:21:03 +08:00
<uv-checkbox-group
shape="circle"
activeColor="#ec6e47"
>
2023-10-11 11:27:47 +08:00
<uv-checkbox
2023-11-14 17:21:03 +08:00
name="all"
:checked="goodsSelectAll"
@change="handleGoodsSelectAll"
2023-10-11 11:27:47 +08:00
>
全选
</uv-checkbox>
</uv-checkbox-group>
</view>
<view class="action-total">
{{ goodsSelect.length }} 件商品
</view>
<view class="action-total">
总计{{ totalPrice }}
</view>
</view>
<view class="action-btns">
2023-11-14 17:21:03 +08:00
<view
class="button only-button"
@click="toRefund(0)"
>
仅退款
</view>
<view
v-if="status !== 0"
class="button"
@click="toRefund(1)"
>
退货退款
</view>
2023-10-11 11:27:47 +08:00
</view>
</view>
</layout>
</template>
<script setup>
import { ref, watch } from 'vue'
import { applyForAfterSalesInfo } from '@/api/order'
import { onLoad } from '@dcloudio/uni-app'
2023-11-14 17:21:03 +08:00
import { useRouter } from "@/hooks/useRouter";
2023-10-11 11:27:47 +08:00
2023-11-14 17:21:03 +08:00
const {getParams, push, goBack} = useRouter()
2023-10-11 11:27:47 +08:00
const goodsList = ref([])
const goodsSelect = ref([])
const goodsSelectAll = ref(false)
const totalPrice = ref(0);
const orderId = ref(null)
const id = ref(null)
const refundType = ref(null)
2023-11-14 17:21:03 +08:00
const status = ref(0)
2023-10-11 11:27:47 +08:00
const handleGoodsSelectAll = (e) => {
goodsSelectAll.value = e
if (!goodsSelectAll.value) {
goodsSelect.value = []
return
}
2023-11-14 17:21:03 +08:00
goodsSelect.value = goodsList.value.map(item => item.cartInfo.productAttrUnique)
2023-10-11 11:27:47 +08:00
}
const handleGoodsSelect = (value) => {
2023-11-14 17:21:03 +08:00
goodsSelectAll.value = value.length === goodsList.value.length
2023-10-11 11:27:47 +08:00
}
watch(goodsSelect, (goodsSelect) => {
let price = 0
2023-11-14 17:21:03 +08:00
goodsList.value.filter(item => goodsSelect.includes(item.cartInfo.productAttrUnique)).forEach(item => {
2023-10-11 11:27:47 +08:00
price += item.cartInfo.truePrice * item.cartInfo.cartNum
})
totalPrice.value = price
})
const handleOrderInfo = async (option) => {
const res = await applyForAfterSalesInfo(option)
// orderInfoData.value = res
goodsList.value = res
}
const toRefund = (type) => {
if (goodsSelect.value.length <= 0) {
return
}
refundType.value = type
2023-11-14 17:21:03 +08:00
push({url: '/pages/refund/refund'}, {
data: {
2023-10-11 11:27:47 +08:00
refundType: refundType.value,
goods: goodsSelect.value.toString(),
orderId: orderId.value,
id: id.value
}
})
}
2023-11-14 17:21:03 +08:00
onLoad((options) => {
const params = getParams(options)
orderId.value = params.orderId
id.value = params.id
status.value = params.status
2023-10-11 11:27:47 +08:00
handleOrderInfo({
2023-11-14 17:21:03 +08:00
key: params.id
2023-10-11 11:27:47 +08:00
})
})
</script>
2023-11-14 17:21:03 +08:00
<style lang="scss">
.shopping-checkbox {
}
2023-10-11 11:27:47 +08:00
.shopping-action {
padding-left: 34rpx;
flex: 1;
display: flex;
justify-content: space-between;
&-checkbox {
flex: 1
}
&-total {
line-height: 48rpx;
font-size: 34rpx;
color: #333333;
margin-right: 10rpx;
}
&-btn {
width: 224rpx;
}
}
2023-11-14 17:21:03 +08:00
.action-btns {
gap: 20rpx;
justify-content: center;
display: flex;
.button {
flex: 1;
height: 80%;
display: flex;
align-items: center;
justify-content: center;
background: $primary-color;
color: $white-color;
}
.only-button {
box-sizing: border-box;
border: 1rpx solid #333;
color: #333;
background: $white-color;
}
}
2023-10-11 11:27:47 +08:00
</style>