代码更新

This commit is contained in:
GaoHao
2025-03-10 09:14:57 +08:00
parent 4f65b08c06
commit 490c513f48
48 changed files with 1162 additions and 537 deletions

View File

@@ -15,10 +15,10 @@
v-for="(item,index) in orderDetail.goodsList" :key="index">
<view>
<view>{{item.productName}}</view>
<view class="u-m-t-10 color-999 u-font-24">{{item.productSkuName||""}}</view>
<view class="u-m-t-10 color-999 u-font-24">{{item.skuName||""}}</view>
<view class="u-m-t-10 color-999 u-font-24">最多可退×{{item.num}}</view>
</view>
<template v-if="option.productId=='-999'">
<template v-if="item.productId=='-999'">
<view class="u-flex">
<view class="color-red" >{{item.priceAmount}}</view>
<view class="u-flex u-m-l-32 u-col-center">
@@ -28,7 +28,7 @@
</template>
<template v-else>
<view class="u-flex">
<view class="color-red" v-if="!option.userCouponId">{{item.priceAmount}}</view>
<view class="color-red" v-if="!item.userCouponId">{{item.priceAmount}}</view>
<view class="u-flex u-m-l-32 u-col-center">
<up-icon @click="changeItem(item,-1)" :size="20" name="minus-circle"></up-icon>
<view class="u-m-l-28 u-m-r-28">{{item.number}}</view>
@@ -86,31 +86,39 @@
</template>
<script setup>
import { computed, reactive, ref, watch } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import color from '@/commons/color.js';
import infoBox from '@/commons/utils/infoBox.js';
import * as orderApi from '@/http/yskApi/order.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import {
$returnOrder
} from '@/http/yskApi/Instead.js'
import {
onLoad,
onShow,
onHide
} from '@dcloudio/uni-app';
import {
computed,
reactive,
ref,
watch
} from 'vue';
import { refundOrder } from '@/api/order.js'
let allTui = ref(false)
let note = ref('')
const tuikuan = reactive({
list: ['点错', '数量点错', '客人要求', '协商退费'],
sel: -1
})
const option=reactive({
productId:'-999'
})
onLoad((opt) => {
console.log(JSON.parse(opt.goodsList));
orderDetail.goodsList = JSON.parse(opt.goodsList)
option.productId = orderDetail.goodsList[0].productId
option.orderId = orderDetail.goodsList[0].orderId
if(option.productId=='-999'){
allTui.value=true
}
})
watch(() => allTui.value, (newval) => {
orderDetail.goodsList.map(v => {
v.number = newval ? v.num : 0
})
})
function changeTuiKuanSel(i) {
tuikuan.sel = i
}
@@ -122,11 +130,6 @@
}
})
watch(() => allTui.value, (newval) => {
orderDetail.goodsList.map(v => {
v.number = newval ? v.num : 0
})
})
const totalNumber = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
@@ -147,7 +150,10 @@
const tuikuanPrice = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
const n=(cur.number/cur.num*100) * cur.priceAmount
return prve + (n/100).toFixed(2)
console.log(n)
console.log((n/100).toFixed(2))
console.log(parseFloat(prve) + parseFloat((n/100).toFixed(2)))
return parseFloat(prve) + parseFloat((n/100).toFixed(2))
}, 0)
})
@@ -171,7 +177,10 @@
item.number = newval;
allTui.value = totalNumber.value == tuikuanNumber.value ? true : false;
}
/**
* 确认退款
*/
async function tuikuanConfirm() {
const canTuikuan=await hasPermission('允许退款')
if(!canTuikuan){
@@ -185,36 +194,27 @@
if (!noteResult) {
return infoBox.showToast('请输入或选择退款原因!')
}
await $returnOrder({
"orderId": option.orderId,
"note":noteResult,
"orderDetails":orderDetail.goodsList.filter(v=>v.number*1).map(v=>{
let params = {
orderId: option.orderId,
refundAmount: orderDetail.goodsList.reduce((prve, cur) => {
return prve + (cur.number * 1 * cur.unitPrice)
}, 0),
refundReason: noteResult,
refundDetails: orderDetail.goodsList.filter(v=>v.number*1).map(v=>{
return {
id:v.id,
num:v.number*1
returnAmount: v.number * 1 * v.unitPrice,
num: v.number * 1
}
})
})
}
await refundOrder(params)
infoBox.showToast('退款请求提交成功')
setTimeout(()=>{
uni.navigateBack({delta:1})
},500)
}
const option=reactive({
productId:'-999'
})
onLoad((opt) => {
Object.assign(option,opt)
if(opt.productId=='-999'){
allTui.value=true
}
if (Array.isArray(opt)) {
orderDetail.goodsList = opt
} else {
orderDetail.goodsList = [opt]
}
console.log(opt);
})
</script>
<style lang="scss" scoped>