增加退款权限校验
This commit is contained in:
parent
bf588ca7fb
commit
b37510e804
|
|
@ -49,6 +49,8 @@
|
||||||
import tuicaiVue from './components/tuicai.vue';
|
import tuicaiVue from './components/tuicai.vue';
|
||||||
import go from '@/commons/utils/go.js'
|
import go from '@/commons/utils/go.js'
|
||||||
import infoBox from '@/commons/utils/infoBox.js'
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
import {$hasPermission} from '@/http/yskApi/shop.js'
|
||||||
|
import {hasPermission} from '@/commons/utils/hasPermission.js'
|
||||||
import {
|
import {
|
||||||
onLoad,
|
onLoad,
|
||||||
onShow,
|
onShow,
|
||||||
|
|
@ -70,9 +72,18 @@
|
||||||
tuicai.isSeatFee = seatFee
|
tuicai.isSeatFee = seatFee
|
||||||
tuicai.selGoods = seatFee
|
tuicai.selGoods = seatFee
|
||||||
}
|
}
|
||||||
|
//是否有允许退款权限
|
||||||
|
async function hasTuiKuan(){
|
||||||
|
const isHas=await hasPermission('允许退款')
|
||||||
|
return isHas
|
||||||
|
}
|
||||||
|
|
||||||
function onSeatFeeTuiKuan(seatFee) {
|
async function onSeatFeeTuiKuan(seatFee) {
|
||||||
console.log(seatFee);
|
console.log(seatFee);
|
||||||
|
const canTuikuan=await hasTuiKuan()
|
||||||
|
if(!canTuikuan){
|
||||||
|
return
|
||||||
|
}
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
productId,
|
productId,
|
||||||
|
|
@ -139,7 +150,12 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTuikuan(goods, index) {
|
|
||||||
|
async function onTuikuan(goods, index) {
|
||||||
|
const canTuikuan=await hasTuiKuan()
|
||||||
|
if(!canTuikuan){
|
||||||
|
return
|
||||||
|
}
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
productId,
|
productId,
|
||||||
|
|
@ -147,6 +163,7 @@
|
||||||
productName,
|
productName,
|
||||||
productSkuName,
|
productSkuName,
|
||||||
cartId,
|
cartId,
|
||||||
|
orderId,
|
||||||
num,
|
num,
|
||||||
priceAmount,
|
priceAmount,
|
||||||
price
|
price
|
||||||
|
|
@ -154,6 +171,7 @@
|
||||||
go.to('PAGES_ORDER_TUIKUAN', {
|
go.to('PAGES_ORDER_TUIKUAN', {
|
||||||
id,
|
id,
|
||||||
cartId,
|
cartId,
|
||||||
|
orderId,
|
||||||
productId,
|
productId,
|
||||||
productSkuId,
|
productSkuId,
|
||||||
productName,
|
productName,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@
|
||||||
<text>退款原因</text>
|
<text>退款原因</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-24 u-flex u-flex-wrap gap-28">
|
<view class="u-m-t-24 u-flex u-flex-wrap gap-28">
|
||||||
<view class="tag" @click="changeTuiKuanSel(index)" v-for="(item,index) in tuikuan.list" :key="index">
|
<view class="tag" @click="changeTuiKuanSel(index)" :class="{active:index==tuikuan.sel}"
|
||||||
|
v-for="(item,index) in tuikuan.list" :key="index">
|
||||||
{{item}}
|
{{item}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -60,7 +61,8 @@
|
||||||
|
|
||||||
<view style="height: 200rpx;"></view>
|
<view style="height: 200rpx;"></view>
|
||||||
<view class="fixed-b">
|
<view class="fixed-b">
|
||||||
<up-button text="确认退款" shape="circle" type="primary" size="large" :color="color.ColorMain"></up-button>
|
<up-button text="确认退款" @click="tuikuanConfirm" shape="circle" type="primary" size="large"
|
||||||
|
:color="color.ColorMain"></up-button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -68,7 +70,12 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import color from '@/commons/color.js';
|
import color from '@/commons/color.js';
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js';
|
||||||
import * as orderApi from '@/http/yskApi/order.js'
|
import * as orderApi from '@/http/yskApi/order.js'
|
||||||
|
import {hasPermission} from '@/commons/utils/hasPermission.js'
|
||||||
|
import {
|
||||||
|
$returnOrder
|
||||||
|
} from '@/http/yskApi/Instead.js'
|
||||||
import {
|
import {
|
||||||
onLoad,
|
onLoad,
|
||||||
onShow,
|
onShow,
|
||||||
|
|
@ -84,7 +91,7 @@
|
||||||
let note = ref('')
|
let note = ref('')
|
||||||
const tuikuan = reactive({
|
const tuikuan = reactive({
|
||||||
list: ['点错', '数量点错', '客人要求', '协商退费'],
|
list: ['点错', '数量点错', '客人要求', '协商退费'],
|
||||||
sel: 0
|
sel: -1
|
||||||
})
|
})
|
||||||
|
|
||||||
function changeTuiKuanSel(i) {
|
function changeTuiKuanSel(i) {
|
||||||
|
|
@ -98,40 +105,79 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(()=>allTui.value,(newval)=>{
|
watch(() => allTui.value, (newval) => {
|
||||||
orderDetail.goodsList.map(v=>{
|
orderDetail.goodsList.map(v => {
|
||||||
v.number=newval?v.num:0
|
v.number = newval ? v.num : 0
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const totalNumber = computed(() => {
|
||||||
|
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||||
|
return prve + cur.num * 1
|
||||||
|
}, 0)
|
||||||
|
})
|
||||||
|
const tuikuanNumber = computed(() => {
|
||||||
|
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||||
|
return prve + cur.number * 1
|
||||||
|
}, 0)
|
||||||
|
})
|
||||||
|
|
||||||
const totalPrice = computed(() => {
|
const totalPrice = computed(() => {
|
||||||
return orderDetail.goodsList.reduce((prve, cur) => {
|
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||||
return prve+cur.priceAmount*1
|
return prve + cur.priceAmount * 1
|
||||||
}, 0)
|
}, 0)
|
||||||
})
|
})
|
||||||
const tuikuanPrice = computed(() => {
|
const tuikuanPrice = computed(() => {
|
||||||
return orderDetail.goodsList.reduce((prve, cur) => {
|
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||||
return prve+cur.number*cur.price
|
return prve + cur.number * cur.price
|
||||||
}, 0)
|
}, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function to2(n){
|
function to2(n) {
|
||||||
return Number(n).toFixed(2)
|
return Number(n).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeItem(item, step) {
|
function changeItem(item, step) {
|
||||||
console.log(item);
|
console.log(item);
|
||||||
let newval = item.number * 1 + step * 1
|
let newval = item.number * 1 + step * 1;
|
||||||
if (newval <= 0) {
|
if (newval <= 0) {
|
||||||
newval = 0
|
newval = 0;
|
||||||
}
|
}
|
||||||
if (newval >= item.num) {
|
if (newval >= item.num) {
|
||||||
newval = item.num
|
newval = item.num;
|
||||||
}
|
}
|
||||||
item.number = newval
|
item.number = newval;
|
||||||
|
allTui.value = totalNumber.value == tuikuanNumber.value ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function tuikuanConfirm() {
|
||||||
|
const canTuikuan=await hasPermission('允许退款')
|
||||||
|
if(!canTuikuan){
|
||||||
|
return infoBox.showToast('您没有退款权限')
|
||||||
|
}
|
||||||
|
if (tuikuanNumber.value <= 0) {
|
||||||
|
return infoBox.showToast('退款商品数量不能为0!')
|
||||||
|
}
|
||||||
|
const selTag=tuikuan.list[tuikuan.sel]
|
||||||
|
await $returnOrder({
|
||||||
|
"orderId": option.orderId,
|
||||||
|
"note":`${selTag?selTag:''}${note.value?(','+note.value):''}` ,
|
||||||
|
"orderDetails":orderDetail.goodsList.filter(v=>v.number*1).map(v=>{
|
||||||
|
return {
|
||||||
|
id:v.id,
|
||||||
|
num:v.number*1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
infoBox.showToast('退款请求提交成功')
|
||||||
|
setTimeout(()=>{
|
||||||
|
uni.navigateBack({delta:1})
|
||||||
|
},500)
|
||||||
|
}
|
||||||
|
const option=reactive({})
|
||||||
onLoad((opt) => {
|
onLoad((opt) => {
|
||||||
|
Object.assign(option,opt)
|
||||||
if (Array.isArray(opt)) {
|
if (Array.isArray(opt)) {
|
||||||
orderDetail.goodsList = opt
|
orderDetail.goodsList = opt
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue