更新折扣优惠和代客下单

This commit is contained in:
gyq
2024-08-26 18:28:24 +08:00
parent 48a3443c5f
commit fbfee69b25
15 changed files with 611 additions and 169 deletions

View File

@@ -3,17 +3,22 @@
<div class="header">
<div class="t1">
<span class="title">应收:</span>
<span class="num">{{ props.amount }}</span>
<span class="num">{{ money }}</span>
</div>
<div class="t2">
<span>已付:0.00</span>
<span>优惠:0.00</span>
<span>共计{{ props.amount }}</span>
<span style="margin-left: 20px;">优惠{{ formatDecimal(props.amount - money) }}</span>
<span v-if="props.discount" @click="cancelDiscount">{{ formatDecimal(props.discount * 10, 1, true) }}
<el-icon>
<CircleClose />
</el-icon>
</span>
</div>
</div>
<div class="number_wrap">
<div class="menus">
<div class="item" :class="{ active: payActive == index }" v-for="(item, index) in payList"
:key="item.id" @click="payTypeChange(index, item)">
<div class="item" :class="{ active: payActive == index, disabled: item.disabled }"
v-for="(item, index) in payList" :key="item.id" @click="payTypeChange(index, item)">
<div class="icon">
<el-image :src="item.icon" class="img"></el-image>
</div>
@@ -22,7 +27,7 @@
</div>
<div class="input_wrap">
<div class="input" style="flex: 1;">储值:{{ money }}</div>
<div class="input" v-if="waitPayMoney > 0">待支付:{{ waitPayMoney }}</div>
<!-- <div class="input" v-if="waitPayMoney > 0">待支付:{{ waitPayMoney }}</div> -->
</div>
<div class="blance">
<!-- 可用余额0.00 -->
@@ -45,16 +50,46 @@
</div>
</div>
</div>
<scanModal ref="scanModalRef" :amount="props.amount" :orderId="props.orderId" :selecttype="props.selecttype"
:payType="payType" @success="scanCodeSuccess" />
<scanModal ref="scanModalRef" :amount="props.amount" :money="money" :orderId="props.orderId"
:selecttype="props.selecttype" :payType="payType" @success="scanCodeSuccess" />
<el-dialog :title="`选择会员`" top="3vh" v-model="showDialog" width="80%">
<el-form inline>
<el-form-item>
<el-input placeholder="请输入手机号搜索会员" v-model="tableData.phone" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getMemberList">搜索</el-button>
<el-button @click="resetTable">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="tableData.list" height="440px" border stripe v-loading="tableData.loading">
<el-table-column prop="name" label="昵称" width="120px" />
<el-table-column prop="telephone" label="手机" width="150px" />
<el-table-column prop="code" label="编号" width="120px" />
<el-table-column prop="level" label="等级" />
<el-table-column prop="levelConsume" label="积分" />
<el-table-column prop="amount" label="余额" width="100px">
<template v-slot="scope">
{{ formatDecimal(scope.row.amount) }}
</template>
</el-table-column>
<el-table-column label="操作" width="120px">
<template v-slot="scope">
<el-button type="primary" @click="toHomeMember(scope.row)">选择</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px;"
:total="Number(tableData.total)" v-model:current-page="tableData.page" @current-change="getMemberList" />
</el-dialog>
</template>
<script setup>
import { onMounted, ref, computed, watch } from 'vue'
import { queryPayType, accountPay, cashPay } from '@/api/pay'
import { onMounted, ref, computed, watch, reactive } from 'vue'
import { queryPayType, accountPay, cashPay, vipPay } from '@/api/pay'
import { queryMembermember, createMembermember, membermemberScanPay, accountPaymember } from '@/api/member/index.js'
import { useUser } from "@/store/user.js"
import { clearNoNum } from '@/utils'
import { clearNoNum, formatDecimal } from '@/utils'
import scanModal from '@/components/payCard/scanModal.vue'
import { ElMessage } from "element-plus";
@@ -76,23 +111,30 @@ const props = defineProps({
orderId: {
type: [String, Number],
default: ''
},
discount: {
type: [String, Number],
default: 0
}
})
const emit = defineEmits(['paySuccess'])
const emit = defineEmits(['paySuccess', 'cancelDiscount'])
const money = ref('0')
const scanModalRef = ref(null)
watch(props, (value) => {
money.value = `${props.amount}`
if (props.discount > 0) {
money.value = `${formatDecimal(props.amount * props.discount)}`
}
})
const waitPayMoney = computed(() => {
let num = JSON.stringify(props.amount - money.value)
num = Math.floor(num * 100) / 100
return num
})
// const waitPayMoney = computed(() => {
// let num = JSON.stringify(props.amount - money.value)
// num = Math.floor(num * 100) / 100
// return num
// })
const payActive = ref(0)
const payType = ref('')
@@ -106,11 +148,16 @@ function scanCodeSuccess() {
// 切换支付类型
function payTypeChange(index, item) {
if (item.disabled) return
payActive.value = index
payType.value = item.payType
if (item.payType == 'scanCode') {
scanModalRef.value.show()
}
if (item.payType == 'vipPay') {
showDialog.value = true
getMemberList()
}
if (payList.value[payActive.value].payType == 'deposit' && !global.orderMemberInfo.id) {
scanModalRef.value.show()
}
@@ -123,7 +170,7 @@ async function confirmOrder() {
if (payList.value[payActive.value].payType == 'scanCode') {
scanModalRef.value.show()
} else {
if (money.value < props.amount) return
// if (money.value < props.amount) return
payLoading.value = true
switch (payList.value[payActive.value].payType) {
case 'deposit'://储值卡
@@ -153,16 +200,18 @@ async function confirmOrder() {
})
} else {
await cashPay({
orderId: props.orderId
orderId: props.orderId,
payAmount: props.discount > 0 ? money.value : '',
discountAmount: props.discount > 0 ? formatDecimal(props.amount - money.value) : ''
})
}
break;
case 'bank'://银行卡
if (props.selecttype == 1) {//1 代表会员
} else {
}
case 'vipPay':
// 会员支付
console.log('使用会员id支付');
payLoading.value = false
showDialog.value = true
return
break;
default:
break;
@@ -202,8 +251,17 @@ async function queryPayTypeAjax() {
const res = await queryPayType({
shopId: store.userInfo.shopId
})
res.map(item => {
if (props.amount <= 0 && item.payType == 'scanCode') {
item.disabled = true
} else {
item.disabled = false
}
})
payList.value = res
if (res[0].payType == 'scanCode' || res[0].payType == 'deposit') {
if ((res[0].payType == 'scanCode' && !res[0].disabled) || res[0].payType == 'deposit') {
scanModalRef.value.show()
payType.value = res[0].payType
}
@@ -212,6 +270,69 @@ async function queryPayTypeAjax() {
}
}
const showDialog = ref(false)
const tableData = reactive({
phone: '',
loading: false,
list: [],
page: 1,
size: 10,
total: 0
})
// 重置表格
function resetTable() {
tableData.phone = ''
tableData.page = 1
getMemberList()
}
// 获取会员列表
async function getMemberList() {
try {
tableData.loading = true
const res = await queryMembermember({
shopId: store.userInfo.shopId,
phone: tableData.phone,
page: tableData.page,
pageSize: tableData.size
})
tableData.loading = false
tableData.list = res.list
tableData.total = res.total
} catch (error) {
console.log(error);
}
}
// 选择会员去下单
async function toHomeMember(row) {
try {
showDialog.value = false
payLoading.value = true
const res = await vipPay({
orderId: props.orderId,
vipUserId: row.id,
payAmount: props.discount > 0 ? money.value : '',
discountAmount: props.discount > 0 ? formatDecimal(props.amount - money.value) : ''
})
global.setOrderTable()
global.setOrderMember()
payLoading.value = false
ElMessage.success('支付成功')
emit('paySuccess')
} catch (error) {
payLoading.value = false
console.log(error);
}
}
// 取消折扣
function cancelDiscount() {
emit('cancelDiscount')
}
onMounted(() => {
money.value = `${props.amount}`
queryPayTypeAjax()
@@ -247,9 +368,13 @@ onMounted(() => {
.t2 {
display: flex;
gap: var(--el-font-size-base);
color: #999;
padding-top: 10px;
span {
display: flex;
align-items: center;
}
}
}
@@ -273,6 +398,10 @@ onMounted(() => {
position: relative;
$lineHeight: 4px;
&.disabled {
filter: grayscale(1);
}
&.active {
&::after {
content: "";