增加券

This commit is contained in:
2024-11-11 09:38:09 +08:00
parent 1836a5b10b
commit 7f265b7583
4 changed files with 2102 additions and 292 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,195 @@
<template>
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
<template #desc>
<view class="u-text-left u-p-30 color-666">
<view class="u-m-t-32 u-flex ">
<view class="color-red">*</view>
<view class="u-m-l-32">
</view>
</view>
<view class="u-m-t-40 u-flex ">
<view>积分</view>
<view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1">
<uni-easyinput type="number" @input="currentPriceInput" @change="currentPriceChange" paddingNone :inputBorder="false"
v-model="form.currentPrice"
placeholder="输入实际金额"></uni-easyinput>
</view>
</view>
</view>
</template>
<template #btn>
<view class="u-p-30">
<view class="u-m-t-10">
<my-button @tap="confirm" shape="circle" fontWeight="700" >修改</my-button>
<view class="">
<my-button @tap="close" type="cancel" bgColor="#fff" >取消</my-button>
</view>
</view>
</view>
</template>
</my-model>
</template>
<script setup>
import {
reactive,
nextTick,
ref,watch
} from 'vue';
import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue'
import myTabs from '@/components/my-components/my-tabs.vue'
import infoBox from '@/commons/utils/infoBox.js'
const props = defineProps({
title: {
type: String,
default: '积分抵扣'
},
data: {
type: Array,
default: []
},
discount:{
type: [Number,String],
default:100
},
price: {
type: [Number,String],
default: 0
}
})
function currentPriceInput(newval){
form.discount=(newval*100/form.price).toFixed()
}
function discountInput(newval){
form.currentPrice=(form.price*newval/100).toFixed(2)
}
function currentPriceChange(newval){
if(newval<0){
form.currentPrice=0
form.discount=100
return infoBox.showToast('实收金额不能小于0')
}
if(newval>props.price){
form.currentPrice=props.price
form.discount=0
return infoBox.showToast('实收金额不能大于应付金额')
}
}
function discountChange(newval){
if(newval<0){
form.currentPrice=props.price
form.discount=0
return infoBox.showToast('优惠折扣不能小于0')
}
if(newval>100){
form.discount=100
form.currentPrice=0
return infoBox.showToast('优惠折扣不能大于100')
}
}
const $form = {
price:props.price,
currentPrice: props.price,
discount: 100
}
const form = reactive({
...$form
})
watch(()=>props.price,(newval)=>{
console.log(newval);
form.price=newval
form.currentPrice=newval
})
function resetForm() {
Object.assign(form, {
...$form
})
}
const model = ref(null)
function open() {
model.value.open()
form.price=props.price
form.currentPrice=props.price
form.discount=props.discount
}
function close() {
model.value.close()
}
const emits = defineEmits(['confirm'])
function confirm() {
console.log(form);
emits('confirm',{...form,currentPrice:Number(form.currentPrice).toFixed(2)})
close()
}
defineExpose({
open,
close
})
</script>
<style lang="scss" scoped>
.border{
border-radius: 8rpx;
overflow: hidden;
border-color: #999;
}
.lh34 {
line-height: 34rpx;
}
.tag {
background-color: #fff;
border: 1px solid #E5E5E5;
line-height: inherit;
font-size: 24rpx;
color: #666666;
padding: 6rpx 20rpx;
border-radius: 8rpx;
&.active {
border-color: #E6F0FF;
color: $my-main-color;
}
}
.hover-class {
background-color: #E5E5E5;
}
.discount {
.u-absolute {
top: 0;
bottom: 0;
right: 0;
}
}
.bg1 {
background: #F7F7FA;
}
.tab {
padding: 0 80rpx;
}
.border {
border: 1px solid #E5E5E5;
border-radius: 4rpx;
}
.input-box {
padding: 22rpx 32rpx;
font-size: 28rpx;
color: #666;
}
.placeholder-class {
font-size: 28rpx;
}
</style>

View File

@@ -1,17 +1,30 @@
<template>
<view class="bg-gray min-page u-p-30 u-font-28">
<view class="u-p-t-60 u-p-b-60 u-text-center">
<view class="u-font-32 ">
<text class="price-fuhao"></text>
<text class="font-bold price">{{discount.currentPrice?discount.currentPrice:order.amount}}</text>
</view>
<view class="u-m-t-10 color-999 old-price">
<text class=""></text>
<text class=" ">{{order.amount}}</text>
</view>
<view class="u-m-t-10 u-flex u-row-center color-main">
<view @click="discountShow">修改</view>
</view>
<template v-if="order.amount!=payPrice">
<view class="u-font-32 ">
<text class="price-fuhao"></text>
<!-- <text class="font-bold price">{{discount.currentPrice?discount.currentPrice:order.amount}}</text> -->
<text class="font-bold price">{{payPrice}}</text>
</view>
<view class="u-m-t-10 color-999 old-price">
<text class=""></text>
<text class=" ">{{order.amount}}</text>
</view>
<view class="u-m-t-10 u-flex u-row-center color-main">
<view @click="discountShow">修改</view>
</view>
</template>
<template v-else>
<view class="u-font-32 ">
<text class="price-fuhao"></text>
<text class="font-bold price">{{order.amount}}</text>
</view>
<view class="u-m-t-10 u-flex u-row-center color-main">
<view @click="discountShow">修改</view>
</view>
</template>
</view>
<view class="content bg-fff border-r-12">
<view class=" u-p-t-30 u-p-l-26 u-p-r-26 card top u-m-t-30">
@@ -26,7 +39,8 @@
</view>
</view>
<view class="u-m-t-24" v-if="pays.quan.length>0">
<view class="u-flex u-p-l-24 u-p-r-24 u-m-t-24 u-row-between " v-for="(item,index) in pays.quan" :key="index">
<view class="u-flex u-p-l-24 u-p-r-24 u-m-t-24 u-row-between "
v-for="(item,index) in pays.quan" :key="index">
<view class="u-flex">
<view class="hui"></view>
<view class="u-m-l-18">{{item.name}}</view>
@@ -39,14 +53,23 @@
</view>
<view class="u-flex u-p-l-24 u-p-r-24 border-bottom u-row-between u-p-t-30 u-p-b-30"
v-if="discount.price&&discount.currentPrice!=order.amount">
<view>服务员改价</view>
<view class=" u-flex u-col-center">
<text style="color: rgb(255, 95, 46);">-{{to2(order.amount- discount.currentPrice)}}</text>
<view class="border-bottom u-p-b-30">
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
v-if="discount.price&&discount.currentPrice!=order.amount">
<view>服务员改价</view>
<view class=" u-flex u-col-center">
<text style="color: rgb(255, 95, 46);">-{{to2(order.amount- discount.currentPrice)}}</text>
</view>
</view>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
v-if="accountPoints.price">
<view>积分抵扣</view>
<view class=" u-flex u-col-center">
<text style="color: rgb(255, 95, 46);">-{{to2(accountPoints.price)}}</text>
</view>
</view>
</view>
</view>
<view class="bg-fff border-r-12 ">
<view class="u-p-t-30 u-p-l-50 u-p-r-50 card bottom">
@@ -70,6 +93,10 @@
<text>余额</text>
<text>{{user.amount||'0'}}</text>
</view>
<!-- <view>
<text>积分</text>
<text>{{user.accountPoints||'0'}}</text>
</view> -->
</view>
<my-radio @click="changePayType(index,item)"
:modelValue="index==pays.payTypes.selIndex">
@@ -78,6 +105,51 @@
</view>
</view>
</view>
<view class="border-bottom-dashed "></view>
<view class="u-flex u-row-between u-p-t-24" v-if="user.id&&user.accountPoints"
@click="changeAccountPoints">
<view class="u-flex ">
<view class="">积分抵扣</view>
<view class="color-999 u-m-l-10">
<text>(</text>
<text>{{user.accountPoints||'0'}}</text>
<text>)</text>
</view>
<!-- <view><text class="color-red font-bold">{{accountPoints.price}}</text></view> -->
</view>
<view class="u-flex">
<view class="u-flex" @click.stop="refPointsOpen">
<view><text>{{accountPoints.num}}</text></view>
<view v-if="accountPoints.calcRes.usable">
<up-icon name="edit-pen" size="16" color="#999"></up-icon>
</view>
</view>
<view class="u-m-l-32 u-relative" v-if="accountPoints.calcRes.usable" >
<view class="u-absolute position-all"></view>
<my-radio
:modelValue="accountPoints.sel">
</my-radio>
</view>
</view>
</view>
<view class="color-999 u-font-24 u-m-t-16" >
<view class="" v-if="accountPoints.calcRes.unusableReason">
<text class="color-red">*</text>
<text >{{accountPoints.calcRes.unusableReason}}</text>
</view>
<view class="" v-if="accountPoints.calcRes.usable">
<text class="color-red">*</text>
<text class="" v-if="accountPoints.calcRes.equivalentPoints">100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}},</text>
<text>
最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}}
</text>
<text>,
最小抵扣积分0
</text>
</view>
</view>
<view class="u-m-t-60 u-p-b-30">
<my-button @click="payOrderClick">确认付款</my-button>
</view>
@@ -122,6 +194,8 @@
<edit-discount @confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney"
:price="order.amount"></edit-discount>
<edit-accountPoints ref="refPoints"></edit-accountPoints>
</view>
</template>
@@ -131,41 +205,108 @@
onMounted,
watch,
ref,
onBeforeUnmount
onBeforeUnmount,
computed
} from 'vue';
import {
onLoad,
onBackPress,onShow
onBackPress,
onShow
} from '@dcloudio/uni-app'
import go from '@/commons/utils/go.js'
import * as Api from '@/http/yskApi/Instead.js'
import {
queryAllShopUser
} from '@/http/yskApi/shop-user.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import {
hasPermission
} from '@/commons/utils/hasPermission.js'
import * as orderApi from '@/http/yskApi/order.js'
import infoBox from '@/commons/utils/infoBox.js'
import editDiscount from '@/components/my-components/edit-discount.vue'
function toQuan(){
import editAccountPoints from './components/edit-accountPoints.vue'
const refPoints=ref(null)
function refPointsOpen(){
if(!accountPoints.calcRes.usable&&accountPoints.sel){
return
}
refPoints.value.open()
}
const accountPoints = reactive({
sel: false,
num: 0,
calcRes:{
usable:false,
unusableReason:'',
minDeductionPoints:0,
maxUsablePoints:0
},
price:0
})
async function calcUsablePoints(){
const res=await Api.$calcUsablePoints({
memberId:order.memberId,
orderAmount:order.amount
})
accountPoints.calcRes=res
accountPoints.num=res.maxUsablePoints
return res;
}
watch(()=>accountPoints.sel,(newval)=>{
if(newval){
calcUsablePoints()
}
})
async function calcDeDuctionPoints(){
const res=await Api.$calcDeDuctionPoints({
memberId: order.memberId,
orderAmount: order.amount,
points: accountPoints.num
})
accountPoints.price=res
return res
}
watch(()=>accountPoints.num,(newval)=>{
if(!newval){
accountPoints.price=0
return
}
calcDeDuctionPoints()
})
function changeAccountPoints() {
if(!accountPoints.calcRes.usable){
return
}
accountPoints.sel = !accountPoints.sel
if (!accountPoints.sel) {
accountPoints.num = 0
}
}
function toQuan() {
console.log(order);
if(!order.memberId){
return infoBox.showToast('请先选择会员',0.5).then(()=>{
if (!order.memberId) {
return infoBox.showToast('请先选择会员', 0.5).then(() => {
chooseUser()
})
}
go.to('PAGES_ORDER_QUAN',{
orderId:order.id,
memberId:order.memberId
go.to('PAGES_ORDER_QUAN', {
orderId: order.id,
memberId: order.memberId
})
}
async function discountShow(){
const bol=await hasPermission('yun_xu_da_zhe')
if(bol){
showModel('editMoney',true)
async function discountShow() {
const bol = await hasPermission('yun_xu_da_zhe')
if (bol) {
showModel('editMoney', true)
}
}
let option = {isNowPay:false}
let payFinish=ref(false)
let option = {
isNowPay: false
}
let payFinish = ref(false)
onBackPress(() => {
uni.$emit('orderDetail:update')
console.log('onBackPress');
@@ -202,18 +343,18 @@
list: [],
selIndex: 0
},
quan:[]
quan: []
})
function chooseUser() {
go.to('PAGES_CHOOSE_USER')
}
//更新选择用户
function setUser(par) {
function setUser(par) {
console.log(option);
const submitPar = {
tableId: order.tableId,
orderId:order.id,
orderId: order.id,
masterId: order.masterId,
vipUserId: user.value.id ? user.value.id : '',
type: user.value.id ? 0 : 1 //0 设置 1 取消
@@ -221,29 +362,31 @@
Object.assign(submitPar, par)
return Api.$setUser(submitPar)
}
function watchChooseuser() {
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
console.log(data);
setUser({
vipUserId: data.id ? data.id : '',
type: data.id ? 0 : 1 //0 设置 1 取消
}).then(res=>{
user.value = data
order.memberId=data.id
init()
})
setUser({
vipUserId: data.id ? data.id : '',
type: data.id ? 0 : 1 //0 设置 1 取消
}).then(res => {
user.value = data
order.memberId = data.id
init()
})
})
}
function watchChooseQuan() {
uni.$off('choose-quan')
uni.$on('choose-quan', (arr) => {
console.log(arr);
pays.quan=arr
pays.quan = arr
})
}
onShow(()=>{
onShow(() => {
watchChooseuser()
watchChooseQuan()
})
@@ -281,12 +424,22 @@
const discount = reactive({
})
const coupAllPrice=computed(()=>{
return pays.quan.reduce((prve,cur)=>{
return prve+cur.discountAmount*1
},0)
})
const payPrice=computed(()=>{
const discountPrice=discount.currentPrice?discount.currentPrice:order.amount
const calcPrice=discountPrice-coupAllPrice.value-accountPoints.price*(accountPoints.sel?1:0)
return (calcPrice<=0?0:calcPrice).toFixed(2)
})
function editDiscountConfirm(form) {
console.log(form);
Object.assign(discount, form)
getPayUrl()
}
async function getPayType() {
const payTypeList = await Api.$getPayType()
pays.payTypes.list = payTypeList
@@ -294,8 +447,8 @@
function changePayType(i, item) {
pays.payTypes.selIndex = i
if (item.payType == 'vipPay' ) {
chooseUser()
if (item.payType == 'vipPay') {
chooseUser()
}
}
//支付成功回调
@@ -303,7 +456,7 @@
infoBox.showToast('支付成功')
setTimeout(() => {
// uni.$emit('orderDetail:update')
payFinish.value=true
payFinish.value = true
uni.$emit('get:table')
uni.$emit('update:orderDetail')
uni.navigateBack({
@@ -323,8 +476,8 @@
async function payOrder() {
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
if (payType == 'vipPay' && user.value.amount * 1 < order.amount * 1) {
infoBox.showToast('余额不足')
return
infoBox.showToast('余额不足')
return
}
await Api.$payOrder({
tableId: order.tableId,
@@ -385,11 +538,12 @@
const orderRes = await orderApi.tbOrderInfoDetail(order.orderId)
Object.assign(order, orderRes)
if (orderRes.memberId) {
calcUsablePoints()
queryAllShopUser({
id: orderRes.memberId
}).then(res => {
if(res.content[0]){
user.value =res.content[0]
if (res.content[0]) {
user.value = res.content[0]
}
})
}
@@ -420,14 +574,16 @@
<style lang="scss" scoped>
$quan-color: #318AFE;
.hui {
// background-color: $quan-color;
background-image: linear-gradient(to right bottom,rgb(254,103,4),rgb(241,50,42));
background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42));
padding: 4rpx 10rpx;
border-radius: 10rpx;
font-size: 24rpx;
color: #fff;
}
.box-shadow {
box-shadow: 0 0 5px #E5E5E5;
}

View File

@@ -108,12 +108,16 @@
onLoad,
onReady
} from '@dcloudio/uni-app'
import * as orderApi from '@/http/yskApi/order.js'
import {
$activateByOrderId
} from '@/http/yskApi/Instead.js'
function back(){
uni.navigateBack()
}
let order=ref({
})
const myQuan = reactive({
fullReductionCouponSel: {
id: ''
@@ -148,6 +152,8 @@
}
async function getQuan() {
order.value=await orderApi.tbOrderInfoDetail(option.orderId)
console.log(order.value);
const res = await $activateByOrderId(option)
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => !v.use)
res.productCoupon = res.productCoupon.filter((v) => !v.use).map(v => {
@@ -162,6 +168,7 @@
const option = reactive({
orderId: '',
memberId: '',
payPrice:''
})
function toEmitChooseQuan(item){