代码更新
This commit is contained in:
182
pagesOrder/choose-buyer/choose-buyer.vue
Normal file
182
pagesOrder/choose-buyer/choose-buyer.vue
Normal file
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<view class="page-gray u-font-28">
|
||||
<view class="search bg-fff u-flex u-col-center ">
|
||||
<view class="u-flex-1">
|
||||
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search" @clear="search"
|
||||
v-model="query.keywords">
|
||||
</uni-search-bar>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list ">
|
||||
<view class="bg-fff u-row-between u-flex no-choose border-r-12" @tap="chooseUser">
|
||||
<view>不选择挂账人</view>
|
||||
<my-radio v-model="nouser" :size="18" border-color="#d1d1d1" @change="chooseUser"></my-radio>
|
||||
</view>
|
||||
<template v-if="list.length>0">
|
||||
<view class="u-m-t-32 bg-fff box bg-fff">
|
||||
<view class="u-flex item u-row-between" v-for="(item,index) in list" :key="index"
|
||||
@tap="chooseUser(index,item)">
|
||||
<view class="u-flex">
|
||||
<view class="u-m-l-32">
|
||||
<view class="u-m-t-12">挂账人:{{item.debtor}}</view>
|
||||
<view class=" u-font-24 u-m-t-12 u-flex">
|
||||
<view class=" u-flex">
|
||||
<text class="">挂账额度:</text>
|
||||
<text class="color-main">{{item.creditAmount}}</text>
|
||||
</view>
|
||||
<view class="u-m-l-30 u-flex">
|
||||
<text class="">账户余额:</text>
|
||||
<text class="color-main">{{item.accountBalance}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<my-radio @change="chooseUser(index,item)" v-model="item.checked" :size="18"
|
||||
border-color="#d1d1d1"></my-radio>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32">
|
||||
<my-pagination :page="query.page" :totalElements="query.totalElements" :size="query.size"
|
||||
@change="pageChange"></my-pagination>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template v-if="hasAjax&&list.length<=0">
|
||||
<my-img-empty tips="未找到相关用户"></my-img-empty>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { reactive, onBeforeMount, ref } from 'vue';
|
||||
import { getCreditBuyerPage } from '@/api/buyer.js';
|
||||
|
||||
let nouser = ref(false)
|
||||
let timer = null
|
||||
onLoad(() => {
|
||||
getBuyer()
|
||||
})
|
||||
onBeforeMount(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
|
||||
const query = reactive({
|
||||
keywords: "",
|
||||
page: 1,
|
||||
size: 10,
|
||||
status: 1
|
||||
})
|
||||
const list = reactive([])
|
||||
let hasAjax = ref(false)
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
async function getBuyer() {
|
||||
const res = await getCreditBuyerPage(query)
|
||||
hasAjax.value = true
|
||||
list.length = res.records.length
|
||||
for (let i in res.records) {
|
||||
list[i] = {
|
||||
...res.records[i],
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
query.totalElements = res.totalRow
|
||||
console.log(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂账人选择
|
||||
* @param {Object} index
|
||||
* @param {Object} item
|
||||
*/
|
||||
function chooseUser(index, item) {
|
||||
if (index === undefined || item === undefined) {
|
||||
nouser.value = true
|
||||
return emitChooser({
|
||||
id: '',
|
||||
debtor: '',
|
||||
creditAmount: '0.00',
|
||||
accountBalance: '0.00'
|
||||
})
|
||||
} else {
|
||||
list[index].checked = true
|
||||
emitChooser(item)
|
||||
}
|
||||
}
|
||||
function emitChooser(data) {
|
||||
uni.$emit('choose-buyer', data)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 100)
|
||||
}
|
||||
function pageChange(e) {
|
||||
query.page = e
|
||||
getBuyer()
|
||||
}
|
||||
|
||||
function search() {
|
||||
query.page = 1
|
||||
getBuyer()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.scale7 {
|
||||
transform: scale(0.7);
|
||||
}
|
||||
|
||||
.search {
|
||||
padding-right: 28rpx;
|
||||
|
||||
.icon-saoma {
|
||||
margin-left: 20rpx;
|
||||
width: 34rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
padding: 32rpx 24rpx;
|
||||
|
||||
.no-choose {
|
||||
padding: 36rpx 30rpx 36rpx 24rpx;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 32rpx 30rpx 78rpx 24rpx;
|
||||
|
||||
.item {
|
||||
padding: 24rpx 0;
|
||||
|
||||
.headimg {
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
font-size: 0;
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
background-color: #eee;
|
||||
overflow: hidden;
|
||||
|
||||
.img {
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item:not(:first-child) {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -4,13 +4,13 @@
|
||||
<text class="">桌号:</text>
|
||||
<text class="">{{orderInfo.tableName||""}}</text>
|
||||
</view>
|
||||
<view class=" font-bold u-p-b-32 border-bottom u-m-b-24" v-if="orderInfo.tableName&&orderInfo.status=='unpaid'">
|
||||
<!-- <view class=" font-bold u-p-b-32 border-bottom u-m-b-24" v-if="orderInfo.tableName&&orderInfo.status=='unpaid'">
|
||||
<view class="block" @tap="rotatingTables"
|
||||
style="display: flex;align-items: center;justify-content: space-between;">
|
||||
<view>转桌/并桌</view>
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class=" color-999 border-bottom u-p-b-24">
|
||||
<text>共</text>
|
||||
<text class="color-333 "> {{goodsNumber}}</text>
|
||||
@@ -55,7 +55,7 @@
|
||||
</view>
|
||||
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnAmount">
|
||||
<view class="color-666">退款金额:</view>
|
||||
<view class="color-999 u-m-l-6">{{item.returnAmount}}</view>
|
||||
<view class="color-999 u-m-l-6">{{item.returnAmount*item.returnNum}}</view>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnNum">
|
||||
<view class="color-666">退菜数量:</view>
|
||||
@@ -70,7 +70,6 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-text-right u-m-t-28">
|
||||
{{isTui(item)}}
|
||||
<template v-if="isTui(item)">
|
||||
<view>¥0.00</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}</view>
|
||||
@@ -79,6 +78,10 @@
|
||||
<view>¥0.00</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else-if="user.isVip == 1">
|
||||
<view>¥{{item.num*item.memberPrice}}</view>
|
||||
<view class="line-th color-666 ">¥{{item.num*item.price}}</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="returnCanTuiMoney(item)*1!=returnTotalMoney(item)*1">
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
@@ -96,7 +99,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="canTuicai(orderInfo,item)">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-24">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-24" v-if="item.returnNum*item.returnAmount<item.payAmount">
|
||||
<!-- <my-button :height="60" color="#333" plain type="cancel" shape="circle">更多操作</my-button> -->
|
||||
<my-button :width="128" :height="48" plain shape="circle" @tap="tuicai(item,index)"><text
|
||||
class="no-wrap">退菜</text></my-button>
|
||||
@@ -134,10 +137,10 @@
|
||||
已优惠¥{{youhuiAllPrice}}
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<!-- <view>
|
||||
<text>小计¥</text>
|
||||
<text class="font-bold u-font-32">{{allPrice}}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@@ -162,18 +165,25 @@
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="canTuiKuan(orderInfo)">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-20">
|
||||
<my-button :width="168" :height="48" plain shape="circle" @tap="tuikuan(data,index)"><text
|
||||
class="no-wrap">全部退款</text> </my-button>
|
||||
</view>
|
||||
</template>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
|
||||
<view></view>
|
||||
<template v-if="orderInfo.status=='unpaid'">
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.orderAmount }}</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.orderAmount.toFixed(2)}}</text>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.payAmount}}</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.payAmount.toFixed(2)}}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -358,7 +368,20 @@
|
||||
function returnTotalMoney(item) {
|
||||
return (item.payAmount).toFixed(2)
|
||||
}
|
||||
|
||||
function returnCanTuiMoney(item) {
|
||||
// if (props.orderInfo.status == 'unpaid') {
|
||||
// return returnTotalMoney(item)
|
||||
// } else {
|
||||
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
|
||||
return item.canReturnAmount
|
||||
} else if (item.price != item.unitPrice) {
|
||||
return item.price*item.num
|
||||
} else {
|
||||
return item.payAmount
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
const canTuiKuanPrice = computed(() => {
|
||||
const goodsTotal = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => !isTui(v) && !v.userCouponId)
|
||||
@@ -396,19 +419,7 @@
|
||||
return seatFee
|
||||
})
|
||||
|
||||
function returnCanTuiMoney(item) {
|
||||
if (props.orderInfo.status == 'unpaid') {
|
||||
return returnTotalMoney(item)
|
||||
} else {
|
||||
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
|
||||
return item.canReturnAmount
|
||||
} else if (item.price != item.unitPrice) {
|
||||
return item.price*item.num
|
||||
} else {
|
||||
return item.payAmount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function to2(n) {
|
||||
if (!n) {
|
||||
@@ -424,10 +435,27 @@
|
||||
function tuikuan(item, index) {
|
||||
hasPermission('允许退款').then(res => {
|
||||
if (res) {
|
||||
emits('tuikuan', {
|
||||
...item,
|
||||
payAmount: item.payAmount
|
||||
}, index)
|
||||
if (Array.isArray(item)) {
|
||||
let arr = [];
|
||||
console.log(item)
|
||||
item.map(v=>{
|
||||
v.info.map(obj=>{
|
||||
obj.number = 0
|
||||
obj.skuName = obj.skuName || ''
|
||||
obj.priceAmount = obj.priceAmount ? obj.priceAmount : (obj.num*obj.unitPrice).toFixed(2)
|
||||
obj.unitPrice = obj.unitPrice
|
||||
})
|
||||
|
||||
arr = [...arr,...v.info]
|
||||
})
|
||||
emits('tuikuan', arr)
|
||||
} else {
|
||||
emits('tuikuan', {
|
||||
...item,
|
||||
payAmount: item.payAmount
|
||||
}, index)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -448,7 +476,6 @@
|
||||
if (props.orderInfo.discountAmount) {
|
||||
return props.orderInfo.discountAmount
|
||||
}
|
||||
console.log(props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio));
|
||||
return (props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio))
|
||||
})
|
||||
const goodsOriginAllPrice = computed(() => {
|
||||
@@ -513,7 +540,7 @@
|
||||
* 已优惠金额
|
||||
*/
|
||||
const youhuiAllPrice = computed(() => {
|
||||
const n = props.orderInfo.orderAmount - props.orderInfo.payAmount + vipDiscountPrice.value * 1
|
||||
const n = props.orderInfo.originAmount - props.orderInfo.orderAmount + vipDiscountPrice.value * 1
|
||||
return (n < 0 ? 0 : n).toFixed(2)
|
||||
})
|
||||
|
||||
@@ -531,7 +558,6 @@
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
|
||||
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.reduce((a,
|
||||
b) => {
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
</template>
|
||||
<view class="u-flex u-m-t-24 u-row-between u-font-28">
|
||||
<view class="">
|
||||
<view class="font-bold ">{{user.amount}}</view>
|
||||
<view class="font-bold ">{{user.amount||0}}</view>
|
||||
<view class="color-666 u-m-t-8 u-font-24">余额</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="font-bold">{{user.accountPoints}}</view>
|
||||
<view class="font-bold">{{user.accountPoints||0}}</view>
|
||||
<view class="color-666 u-m-t-8 u-font-24">积分</view>
|
||||
</view>
|
||||
<view class="">
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<view style="height: 200rpx;"></view>
|
||||
<view class="u-fixed bottom bg-fff ">
|
||||
<view class="u-flex u-abso">
|
||||
<template v-if="orderDetail.info.useType=='take-out'||!orderDetail.info.tableCode||orderDetail.info.useType=='dine-in-before'">
|
||||
<template v-if="orderDetail.info.dineMode=='take-out'||!orderDetail.info.tableCode||pageData.shopInfo.registerType=='before'">
|
||||
<view class="u-flex-1" v-if="orderDetail.info.status=='unpaid'">
|
||||
<my-button @tap="toPay" borderRadius="100rpx" shape="circle"
|
||||
type="primary">结账</my-button>
|
||||
@@ -41,6 +41,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { reactive, ref } from 'vue';
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import userVue from './components/user.vue';
|
||||
import orderVue from './components/order.vue';
|
||||
@@ -48,19 +50,16 @@
|
||||
import stepVue from './components/step.vue';
|
||||
import extraVue from './components/extra.vue';
|
||||
import tuicaiVue from './components/tuicai.vue';
|
||||
|
||||
import go from '@/commons/utils/go.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import {hasPermission} from '@/commons/utils/hasPermission.js'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import {
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
|
||||
import OrderDetail from './page.js'
|
||||
import { getHistoryOrder, refundOrder,getOrderById } from '@/api/order.js'
|
||||
import { getHistoryOrder, refundOrder,getOrderById,printOrder } from '@/api/order.js'
|
||||
import { shopStaffDetail } from '@/api/staff.js'
|
||||
import { shopUserDetail } from '@/api/shopUser.js'
|
||||
|
||||
import { getShopInfo } from '@/api/shop.js'
|
||||
|
||||
const tuicai = reactive({
|
||||
show: false,
|
||||
@@ -82,9 +81,13 @@
|
||||
amount:'0.00',
|
||||
accountPoints:'0.00'
|
||||
})
|
||||
const pageData = reactive({
|
||||
shopInfo: {},
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt)
|
||||
console.log(options);
|
||||
console.log("opt===",options);
|
||||
getShopInfoData()
|
||||
})
|
||||
onShow(() => {
|
||||
watchEmit()
|
||||
@@ -92,7 +95,14 @@
|
||||
getOrderDetail()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 获取店铺信息
|
||||
*/
|
||||
function getShopInfoData () {
|
||||
getShopInfo({id:uni.getStorageSync('shopInfo').id}).then(res=>{
|
||||
pageData.shopInfo = res;
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
@@ -101,7 +111,7 @@
|
||||
let res = await getHistoryOrder({orderId: options.id})
|
||||
console.log(res)
|
||||
if(res.userId){
|
||||
shopUserDetail({id:res.userId}).then(res=>{
|
||||
shopUserDetail({userId:res.userId}).then(res=>{
|
||||
if(res){
|
||||
user.value = res
|
||||
}
|
||||
@@ -115,7 +125,7 @@
|
||||
info: value,
|
||||
placeNum: key
|
||||
}))
|
||||
console.log(orderDetail.goodsList);
|
||||
console.log("goodsList===",orderDetail.goodsList);
|
||||
orderDetail.info = res
|
||||
}
|
||||
|
||||
@@ -156,7 +166,7 @@
|
||||
productName,
|
||||
num,
|
||||
number: 0,
|
||||
productSkuName: '',
|
||||
skuName: '',
|
||||
priceAmount,
|
||||
price
|
||||
})
|
||||
@@ -177,28 +187,24 @@
|
||||
getOrderDetail()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function printDishes() {
|
||||
try {
|
||||
const res = await Api.$printDishes({
|
||||
tableId: orderDetail.info.tableId
|
||||
})
|
||||
infoBox.showToast('已发送打印请求')
|
||||
} catch (e) {
|
||||
infoBox.showToast('发送打印请求失败')
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打印订单
|
||||
*/
|
||||
function onPrintOrder() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否打印当前台桌菜品',
|
||||
success(res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
printDishes()
|
||||
try {
|
||||
const res = await printOrder({
|
||||
id: orderDetail.info.id
|
||||
})
|
||||
infoBox.showToast('已发送打印请求')
|
||||
} catch (e) {
|
||||
infoBox.showToast('发送打印请求失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -211,32 +217,22 @@
|
||||
return
|
||||
}
|
||||
console.log(goods,'debug');
|
||||
const {
|
||||
id,
|
||||
productId,
|
||||
productSkuId,
|
||||
productName,
|
||||
productSkuName,
|
||||
cartId,
|
||||
orderId,
|
||||
num,
|
||||
priceAmount,
|
||||
price,userCouponId
|
||||
} = goods
|
||||
go.to('PAGES_ORDER_TUIKUAN', {
|
||||
id,
|
||||
cartId,
|
||||
orderId,
|
||||
productId,
|
||||
productSkuId,
|
||||
productName,
|
||||
num,
|
||||
number: 0,
|
||||
productSkuName: productSkuName || '',
|
||||
priceAmount:priceAmount?priceAmount:(num*price).toFixed(2),
|
||||
price,
|
||||
userCouponId:userCouponId?userCouponId:''
|
||||
})
|
||||
if (Array.isArray(goods)) {
|
||||
go.to('PAGES_ORDER_TUIKUAN', {
|
||||
goodsList:JSON.stringify(goods)
|
||||
|
||||
})
|
||||
} else {
|
||||
goods.number = 0
|
||||
goods.skuName = goods.skuName || ''
|
||||
goods.priceAmount = goods.priceAmount ? goods.priceAmount : (goods.num*goods.unitPrice).toFixed(2)
|
||||
goods.unitPrice = goods.unitPrice
|
||||
goods.userCouponId = goods.userCouponId ? goods.userCouponId:''
|
||||
go.to('PAGES_ORDER_TUIKUAN', {
|
||||
goodsList:JSON.stringify([goods])
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -256,10 +252,10 @@
|
||||
clearEmit()
|
||||
go.to('PAGES_CREATE_ORDER', {
|
||||
tableId: options.tableId || orderDetail.info.tableId,
|
||||
tableCode: options.tableCode || orderDetail.info.tableCode,
|
||||
name: options.name || orderDetail.info.tableName,
|
||||
masterId:orderDetail.info.masterId,
|
||||
type: 'add',
|
||||
vipUserId:orderDetail.userId?orderDetail.userId:''
|
||||
vipUserId: orderDetail.info.userId?orderDetail.info.userId:''
|
||||
})
|
||||
}
|
||||
|
||||
@@ -272,8 +268,8 @@
|
||||
clearEmit()
|
||||
go.to('PAGES_ORDER_PAY', {
|
||||
tableId: options.tableId|| orderDetail.info.tableId,
|
||||
tableName: options.name,
|
||||
masterId: options.masterId,
|
||||
tableCode: options.tableCode || orderDetail.info.tableCode,
|
||||
tableName: options.name || orderDetail.info.tableName,
|
||||
orderId: orderDetail.info.id,
|
||||
discount: 1,
|
||||
userId
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
<view class="u-m-t-32">
|
||||
<view class="u-flex u-row-right">
|
||||
<text>总计¥</text>
|
||||
<text class="font-bold u-font-32">{{data.orderAmount}}</text>
|
||||
<text class="font-bold u-font-32">{{data.originAmount}}</text>
|
||||
</view>
|
||||
<view class="u-flex u-row-right u-m-t-24">
|
||||
<view class="print" @click.stop="print(item)">重新打印</view>
|
||||
|
||||
@@ -21,12 +21,11 @@
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import {onLoad,onShow,onPullDownRefresh} from '@dcloudio/uni-app'
|
||||
import LIST from '@/commons/class/list.js'
|
||||
import {$printOrder} from '@/http/yskApi/Instead.js'
|
||||
import filterVue from './compoents/filter.vue';
|
||||
import orderList from './compoents/order-list.vue';
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import {getTodayTimestamps} from '@/commons/utils/dayjs-time.js';
|
||||
import { getOrderList } from '@/api/order.js'
|
||||
import { getOrderList,printOrder } from '@/api/order.js'
|
||||
|
||||
const search = reactive({
|
||||
placeholder: '搜索单号/商品名称',
|
||||
@@ -84,33 +83,25 @@
|
||||
* 是否打印该订单
|
||||
* @param {Object} e
|
||||
*/
|
||||
function onPrintOrder(e){
|
||||
function onPrintOrder(item){
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否打印该订单',
|
||||
success(res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
printOrder(e)
|
||||
try{
|
||||
const res= await printOrder({
|
||||
id :item.id
|
||||
})
|
||||
infoBox.showToast('已发送打印请求')
|
||||
}catch(e){
|
||||
infoBox.showToast('发送打印请求失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印该订单
|
||||
* @param {Object} item
|
||||
*/
|
||||
async function printOrder(item){
|
||||
try{
|
||||
const res= await $printOrder({
|
||||
tableId:item.tableId
|
||||
})
|
||||
infoBox.showToast('已发送打印请求')
|
||||
}catch(e){
|
||||
infoBox.showToast('发送打印请求失败')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页加载
|
||||
* @param {Object} e
|
||||
|
||||
@@ -99,7 +99,19 @@
|
||||
<text class="u-m-l-10 no-wrap">{{item.payName}}</text>
|
||||
</view>
|
||||
<view class="u-flex color-999 u-font-24">
|
||||
<view class="u-m-r-20" v-if="item.payType=='virtual'&&pageData.user.id"
|
||||
<view class="u-m-r-20" v-if="item.payType=='virtual'&&pageData.buyer.id"
|
||||
@click.stop="chooseBuyer">
|
||||
<view>
|
||||
<text>挂账人:</text>
|
||||
<text class="u-m-r-4">{{pageData.buyer.debtor}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text>挂账额度:</text>
|
||||
<text>¥{{pageData.buyer.creditAmount||'0'}}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="u-m-r-20" v-if="item.payType=='member-account'&&pageData.user.id"
|
||||
@click.stop="chooseUser">
|
||||
<view>
|
||||
<text>会员:</text>
|
||||
@@ -228,7 +240,6 @@
|
||||
import { reactive, onMounted, watch, ref, onBeforeUnmount, computed } from 'vue';
|
||||
import { onLoad, onBackPress, onShow } from '@dcloudio/uni-app'
|
||||
import go from '@/commons/utils/go.js'
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
@@ -244,8 +255,9 @@
|
||||
import { getCouponList } from '@/api/coupon.js'
|
||||
import { getHistoryOrder } from '@/api/order.js'
|
||||
import { getPayTypeList } from '@/api/payType.js'
|
||||
import { cashPay,vipPay,getOrderPayUrl } from '@/api/pay.js'
|
||||
import { scanPay,microPay,cashPay,vipPay,creditPay,getOrderPayUrl } from '@/api/pay.js'
|
||||
import { shopUserDetail } from '@/api/shopUser.js'
|
||||
import { calcUsablePoints,calcDeductionAmount,payedDeductPoints,consumeAwardPoints } from '@/api/points.js'
|
||||
|
||||
|
||||
const modal = reactive({
|
||||
@@ -265,7 +277,8 @@
|
||||
user: { //会员信息
|
||||
userId: null,
|
||||
amount: 0
|
||||
}
|
||||
},
|
||||
buyer: {}
|
||||
})
|
||||
const order = reactive({
|
||||
orderAmount: 0
|
||||
@@ -279,7 +292,8 @@
|
||||
list: [],
|
||||
selIndex: 0
|
||||
},
|
||||
quan: []
|
||||
quan: [],
|
||||
seatNum: 0
|
||||
})
|
||||
//打折相关数据
|
||||
const discount = reactive({
|
||||
@@ -305,6 +319,7 @@
|
||||
let payCodeUrl = ref('') //收款二维码地址
|
||||
onShow(() => {
|
||||
watchChooseuser()
|
||||
watchChoosebuyer()
|
||||
watchChooseQuan()
|
||||
})
|
||||
onLoad(async (opt) => {
|
||||
@@ -345,19 +360,20 @@
|
||||
setQuan([...fullReductionCoupon, ...productCoupon])
|
||||
|
||||
// 获取用户信息
|
||||
console.log(order.userId)
|
||||
console.log(!pageData.user.userId)
|
||||
if (order.userId&&!pageData.user.userId) {
|
||||
calcUsablePoints()
|
||||
if (orderRes.pointsNum) {
|
||||
accountPoints.sel = true
|
||||
}
|
||||
console.log("pageData.user===",pageData.user)
|
||||
if (order.userId||pageData.user.userId) {
|
||||
|
||||
shopUserDetail({
|
||||
userId: order.userId || pageData.user.userId
|
||||
}).then(res => {
|
||||
pageData.user = res
|
||||
getCalcUsablePoints()
|
||||
if (orderRes.pointsNum) {
|
||||
accountPoints.sel = true
|
||||
}
|
||||
})
|
||||
}
|
||||
pageData.seatNum = order.tableId!=null&&order.tableId!="undefined" ? order.seatNum : 0;
|
||||
}
|
||||
const coupAllPrice = computed(() => {
|
||||
const n = pays.quan.reduce((prve, cur) => {
|
||||
@@ -383,13 +399,12 @@
|
||||
* 订单金额
|
||||
*/
|
||||
const originPrice = computed(() => {
|
||||
console.log(order)
|
||||
console.log(packAmount)
|
||||
console.log("order===",order)
|
||||
if(pageData.goodsList){
|
||||
let goodsPrice = pageData.goodsList.filter(v => v.price != 0 && v.status !== "return").reduce((a, b) => {
|
||||
return a + (b.num * b.price)
|
||||
}, 0)
|
||||
return (goodsPrice + order.seatNum + packAmount.value).toFixed(2)
|
||||
return (goodsPrice + (pageData.seatNum||0) + packAmount.value).toFixed(2)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -462,6 +477,16 @@
|
||||
console.log("accountPoints===",accountPoints)
|
||||
let total = (originPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
|
||||
.value - fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
|
||||
console.log("payPrice===",total)
|
||||
return (total < 0 ? 0 : total).toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 积分使用前金额
|
||||
*/
|
||||
const orderAmount = computed(() => {
|
||||
let total = (originPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
|
||||
.value - fullCouponDiscountAmount.value
|
||||
console.log(total)
|
||||
return (total < 0 ? 0 : total).toFixed(2)
|
||||
})
|
||||
@@ -473,12 +498,14 @@
|
||||
}
|
||||
})
|
||||
watch(() => pointCanDicountPrice.value, (newval) => {
|
||||
calcUsablePoints()
|
||||
if( pageData.user.id ){
|
||||
getCalcUsablePoints()
|
||||
}
|
||||
})
|
||||
watch(() => payPrice.value, (newval) => {
|
||||
getPayUrl()
|
||||
if (newval <= 0) {
|
||||
const arr = ['cash', 'virtual']
|
||||
const arr = ['cash', 'member-account']
|
||||
pays.payTypes.list.map(v => {
|
||||
if (arr.includes(v.payType)) {
|
||||
v.disabled = false
|
||||
@@ -514,27 +541,37 @@
|
||||
}, 2000)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function getPayParam () {
|
||||
return {
|
||||
shopId: uni.getStorageSync("shopInfo").id,
|
||||
orderId: order.id,
|
||||
originAmount: originPrice.value, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
orderAmount: payPrice.value, // 订单金额
|
||||
seatNum: pageData.seatNum, // 用餐人数
|
||||
discountAmount: discount.value, // 手动优惠金额
|
||||
fullCouponDiscountAmount: fullCouponDiscountAmount.value, // 满减金额
|
||||
vipPrice: vipDiscount.value != 0 ? 1: 0, // 是否使用会员价
|
||||
pointsDiscountAmount: accountPoints.sel ? accountPoints.price : 0,
|
||||
pointsNum: accountPoints.sel ? accountPoints.num : 0,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺订单支付URL
|
||||
*/
|
||||
function getPayUrl() {
|
||||
console.log(vipDiscount.value)
|
||||
let par = {
|
||||
console.log(discount)
|
||||
console.log(getPayParam())
|
||||
let par = getPayParam()
|
||||
let params = {
|
||||
shopId: uni.getStorageSync("shopInfo").id,
|
||||
orderId: order.id,
|
||||
orderAmount: payPrice.value,
|
||||
seatNum: order.seatNum, // 用餐人数
|
||||
discountRatio: (discount.discount/100).toFixed(0), // 折扣比例
|
||||
discountAmount: discount.value, // 手动优惠金额
|
||||
fullCouponDiscountAmount: fullCouponDiscountAmount.value, // 满减金额
|
||||
pointsNum: accountPoints.sel ? accountPoints.num : 0,
|
||||
vipPrice: vipDiscount.value > 0 ? 1: 0, // 是否使用会员价
|
||||
...par
|
||||
}
|
||||
if( order.userId||pageData.user.userId ){
|
||||
par.userId = order.userId||pageData.user.userId
|
||||
params.userId = order.userId||pageData.user.userId
|
||||
}
|
||||
getOrderPayUrl(par).then(res => {
|
||||
getOrderPayUrl(params).then(res => {
|
||||
payCodeUrl.value = res
|
||||
})
|
||||
}
|
||||
@@ -545,10 +582,14 @@
|
||||
*/
|
||||
async function getPayType() {
|
||||
const payTypeList = await getPayTypeList()
|
||||
pays.payTypes.list = payTypeList.map(v => {
|
||||
return {
|
||||
...v,
|
||||
disabled: false
|
||||
pays.payTypes.list = [];
|
||||
payTypeList.map(v => {
|
||||
if( v.payType != 'bank'){
|
||||
|
||||
pays.payTypes.list.push({
|
||||
...v,
|
||||
disabled: false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -558,13 +599,12 @@
|
||||
* @param {Object} arr
|
||||
*/
|
||||
function setQuan(arr) {
|
||||
console.log(arr);
|
||||
console.log("choose-quan===",arr)
|
||||
discount.discount = 100
|
||||
discount.value = 0
|
||||
discount.currentPrice = order.orderAmount
|
||||
const manjianCoup = arr.filter(v => v.type == 1 && v.number >= 1)
|
||||
let productCoup = arr.filter(v => v.type == 2)
|
||||
console.log(productCoup);
|
||||
//商品券分组
|
||||
let coupMap = {}
|
||||
for (let i in productCoup) {
|
||||
@@ -575,7 +615,6 @@
|
||||
coupMap[coup.proId] = [coup]
|
||||
}
|
||||
}
|
||||
console.log(coupMap);
|
||||
for (let key in coupMap) {
|
||||
const arr = coupMap[key]
|
||||
for (let i in arr) {
|
||||
@@ -594,9 +633,7 @@
|
||||
}
|
||||
}
|
||||
productCoup = productCoup.filter(v => v.number >= 1)
|
||||
console.log(productCoup);
|
||||
pays.quan = [...manjianCoup, ...productCoup]
|
||||
console.log(pays.quan);
|
||||
}
|
||||
|
||||
|
||||
@@ -625,12 +662,18 @@
|
||||
function pointsConfirm(e) {
|
||||
accountPoints.num = e
|
||||
}
|
||||
async function calcUsablePoints(orderAmount) {
|
||||
|
||||
/**
|
||||
* 获取积分信息
|
||||
* @param {Object} orderAmount
|
||||
*/
|
||||
async function getCalcUsablePoints(orderAmount) {
|
||||
if (!order.userId&&!pageData.user.userId) {
|
||||
return
|
||||
}
|
||||
const res = await Api.$calcUsablePoints({
|
||||
userId: order.userId||pageData.user.userId,
|
||||
console.log("calcUsablePoints",pageData.user)
|
||||
const res = await calcUsablePoints({
|
||||
userId: pageData.user.id,
|
||||
orderAmount: orderAmount ? orderAmount : payPrice.value
|
||||
})
|
||||
accountPoints.calcRes = res
|
||||
@@ -643,9 +686,9 @@
|
||||
accountPoints.price = 0
|
||||
return ''
|
||||
}
|
||||
const res = await Api.$calcDeDuctionPoints({
|
||||
userId: order.userId||pageData.user.userId,
|
||||
orderAmount: originPrice.value,
|
||||
const res = await calcDeductionAmount({
|
||||
userId: pageData.user.id,
|
||||
orderAmount: orderAmount.value,
|
||||
points: accountPoints.num
|
||||
})
|
||||
if (res) {
|
||||
@@ -733,6 +776,25 @@
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择挂账人
|
||||
*/
|
||||
function chooseBuyer() {
|
||||
go.to('PAGES_CHOOSE_BUYER')
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新选择挂账人
|
||||
*/
|
||||
function watchChoosebuyer() {
|
||||
uni.$off('choose-buyer')
|
||||
uni.$on('choose-buyer', (data) => {
|
||||
console.log(data);
|
||||
pageData.buyer = data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改价格确认
|
||||
* @param {Object} form
|
||||
@@ -768,9 +830,13 @@
|
||||
pays.payTypes.selIndex = i
|
||||
console.log(item.payType)
|
||||
console.log(pageData.user.id)
|
||||
if (item.payType == 'virtual' && !pageData.user.id) {
|
||||
if (item.payType == 'member-account' && !pageData.user.id) {
|
||||
chooseUser()
|
||||
}
|
||||
if (item.payType == 'virtual' && !pageData.buyer.id) {
|
||||
chooseBuyer()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -799,13 +865,16 @@
|
||||
function payOrderClick() {
|
||||
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
|
||||
console.log(payType);
|
||||
if (payType == 'scanCode' || payType == 'deposit' || payType == 'bank') {
|
||||
if (payType == 'scanCode' || payType == 'deposit') {
|
||||
return saomaPay(payType)
|
||||
}
|
||||
if (payType == 'cash' && payPrice.value * 1 > 0) {
|
||||
return cashConfirmShow()
|
||||
}
|
||||
if (payType == 'virtual' && pageData.user.amount * 1 < order.orderAmount * 1) {
|
||||
if (payType == 'virtual') {
|
||||
// return cashConfirmShow()
|
||||
}
|
||||
if (payType == 'member-account' && pageData.user.amount * 1 < payPrice.value * 1) {
|
||||
infoBox.showToast('余额不足')
|
||||
return
|
||||
}
|
||||
@@ -826,55 +895,60 @@
|
||||
*/
|
||||
async function pay(par) {
|
||||
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
|
||||
let pars = getPayParam()
|
||||
console.log(payType)
|
||||
console.log(discount)
|
||||
payStatus = 'paying'
|
||||
let params = {
|
||||
shopId: uni.getStorageSync("shopInfo").id,
|
||||
checkOrderPay: {
|
||||
orderId: order.id || order.orderId,
|
||||
seatNum: order.seatNum, // 用餐人数
|
||||
discountRatio: (discount.discount/100).toFixed(0), // 折扣比例
|
||||
discountAmount: discount.value, // 手动优惠金额
|
||||
fullCouponDiscountAmount: fullCouponDiscountAmount.value, // 满减金额
|
||||
orderAmount: payPrice.value, // 订单金额
|
||||
vipPrice: vipDiscount.value > 0 ? 1: 0, // 是否使用会员价
|
||||
pointsNum: accountPoints.sel ? accountPoints.num : 0,
|
||||
couponList: pays.quan.map(v => {
|
||||
return {
|
||||
userCouponId: v.id,
|
||||
num: v.number
|
||||
}
|
||||
}),
|
||||
...par
|
||||
...pars
|
||||
},
|
||||
|
||||
...par
|
||||
}
|
||||
if( order.userId||pageData.user.userId ){
|
||||
params.checkOrderPay.userId = order.userId||pageData.user.userId
|
||||
}
|
||||
if( payType == 'virtual' ){
|
||||
params.creditBuyerId = pageData.buyer.id
|
||||
}
|
||||
|
||||
|
||||
|
||||
console.log(params)
|
||||
if (payType == 'scanCode' || payType == 'deposit' || payType == 'bank') {
|
||||
}
|
||||
if (payType == 'cash' && payPrice.value * 1 > 0) {
|
||||
try {
|
||||
try {
|
||||
if (payType == 'scanCode') {
|
||||
await microPay(params)
|
||||
}
|
||||
if (payType == 'cash') {
|
||||
await cashPay(params)
|
||||
} catch (error) {
|
||||
payStatus = '';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (payType == 'virtual' && pageData.user.amount * 1 > order.orderAmount * 1) {
|
||||
params.payType = 'userPay'
|
||||
params.shopUserId = pageData.user.id
|
||||
try {
|
||||
await vipPay(params)
|
||||
} catch (error) {
|
||||
payStatus = '';
|
||||
return false;
|
||||
if (payType == 'virtual') {
|
||||
await creditPay(params)
|
||||
}
|
||||
if( payType == 'member-account' || payType == 'deposit' ) {
|
||||
if (pageData.user.amount * 1 >= payPrice.value * 1) {
|
||||
params.payType = 'userPay'
|
||||
params.shopUserId = pageData.user.id
|
||||
await vipPay(params)
|
||||
} else {
|
||||
infoBox.showToast('余额不足')
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
payStatus = '';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
paySuccess()
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
console.log(pageData.order);
|
||||
const res = await getFindCoupon({
|
||||
shopUserId: option.shopUserId,
|
||||
type: pageData.types.sel
|
||||
type: pageData.types.sel+1
|
||||
})
|
||||
let fullReductionCoupon = res.filter(v => v.type == 1)
|
||||
let productCoupon = res.filter(v => v.type == 2)
|
||||
@@ -340,7 +340,7 @@
|
||||
*/
|
||||
function changeFullReductionCouponSel(item) {
|
||||
if (!item.use) {
|
||||
// return
|
||||
return
|
||||
}
|
||||
console.log(item);
|
||||
if (item.id == pageData.fullReductionCouponSel.id) {
|
||||
|
||||
@@ -132,10 +132,11 @@ export function returnProCoupStartIndex(coupArr,index){
|
||||
}
|
||||
//返回商品数量从0到n每一个对应的价格对照表
|
||||
export function returnGoodsPayPriceMap(goodsArr){
|
||||
let goods_arr = []
|
||||
let goods_arr = [{}]
|
||||
Object.values(goodsArr).forEach(item=>{
|
||||
goods_arr = [...goods_arr,...item]
|
||||
})
|
||||
console.log(goods_arr)
|
||||
return goods_arr.reduce((prve,cur)=>{
|
||||
if(!prve.hasOwnProperty(cur.productId)){
|
||||
prve[cur.productId]=[]
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user