更新折扣优惠和代客下单
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import getLodop from "./LodopFuncs.js";
|
||||
import { formatDecimal } from "@/utils/index.js";
|
||||
|
||||
/**
|
||||
* 打印订单小票
|
||||
*/
|
||||
@@ -75,16 +77,22 @@ export default (data) => {
|
||||
</div>
|
||||
<div style="margin-top: 6px; font-size: 22px;display:flex;justify-content: space-between;">
|
||||
<span>应收</span>
|
||||
<span>¥${data.amount}</span>
|
||||
<span>¥${data.discountAmount}</span>
|
||||
</div>
|
||||
<div style="margin-top: 4px; font-size: 12px;">
|
||||
<span>余额:</span>
|
||||
<span>0.00</span>
|
||||
<span>共计:</span>
|
||||
<span>¥${data.amount}</span>
|
||||
<span style="margin-left: 10px;">优惠:</span>
|
||||
<span>¥${formatDecimal(data.amount - data.discountAmount)}(${
|
||||
data.discount
|
||||
}折)</span>
|
||||
</div>
|
||||
<div style="margin-top: 6px;margin-bottom: 6px;width: 100%">
|
||||
<hr/>
|
||||
</div>
|
||||
<div style="margin-top: 4px; font-size: 16px;font-weight: bold;">备注:${data.remark}</div>
|
||||
<div style="margin-top: 4px; font-size: 16px;font-weight: bold;">备注:${
|
||||
data.remark
|
||||
}</div>
|
||||
<div style="margin-top: 4px; font-size: 12px;">
|
||||
打印时间:${data.printTime}
|
||||
</div>
|
||||
|
||||
@@ -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: "";
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="right" v-if="!userPayWait">
|
||||
<div class="amount">
|
||||
<span class="t">扫码支付</span>
|
||||
<span class="n">{{ props.amount }}</span>
|
||||
<span class="n">{{ props.money }}</span>
|
||||
</div>
|
||||
<div class="input">
|
||||
<el-input ref="inputRef" v-model="scanCode" style="height: calc(var(--el-component-size-large) + 30px)"
|
||||
@@ -57,6 +57,7 @@ import icon from "@/assets/icon_scan.png";
|
||||
import { scanpay, queryOrder, quickPay, queryQuickPayStatus, accountPay, queryScanPay } from "@/api/pay";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { formatDecimal } from '@/utils'
|
||||
const store = useUser();
|
||||
const global = useGlobal()
|
||||
import {
|
||||
@@ -88,6 +89,10 @@ const props = defineProps({
|
||||
payType: {
|
||||
type: [Number, String],
|
||||
default: "",
|
||||
},
|
||||
money: {
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
}
|
||||
});
|
||||
|
||||
@@ -112,6 +117,8 @@ async function submitHandle() {
|
||||
memberId: props.orderId,
|
||||
amount: props.amount,
|
||||
authCode: scanCode.value,
|
||||
payAmount: props.money < props.amount ? props.money : '',
|
||||
discountAmount: props.money < props.amount ? formatDecimal(props.amount - props.money) : ''
|
||||
});
|
||||
} else {
|
||||
if (props.fast) {
|
||||
@@ -125,13 +132,17 @@ async function submitHandle() {
|
||||
await scanpay({
|
||||
orderId: props.orderId,
|
||||
authCode: scanCode.value,
|
||||
payAmount: props.money < props.amount ? props.money : '',
|
||||
discountAmount: props.money < props.amount ? formatDecimal(props.amount - props.money) : ''
|
||||
});
|
||||
}
|
||||
if (props.payType == 'deposit') {
|
||||
await accountPay({
|
||||
orderId: props.orderId,
|
||||
memberId: '',
|
||||
memberAccount: scanCode.value
|
||||
memberAccount: scanCode.value,
|
||||
payAmount: props.money < props.amount ? props.money : '',
|
||||
discountAmount: props.money < props.amount ? formatDecimal(props.amount - props.money) : ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<div class="sku_wrap">
|
||||
<!-- <div class="item" :class="{ active: val.active }" v-for="(val, i) in item.value" :key="i"
|
||||
@click="selectedSku(index, i)">{{ val.name }}</div> -->
|
||||
<el-button :plain="!val.active" type="primary" v-for="(val, i) in item.selectSpecResult
|
||||
" :key="i" @click="selectedSku(index, i)" class="btn">{{ val.name }}</el-button>
|
||||
<el-button :plain="!val.active" type="primary" v-for="(val, i) in item.selectSpecResult
|
||||
" :key="i" :disabled="val.disabled" @click="selectedSku(index, i)" class="btn">{{ val.name }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,6 +51,8 @@ const goodsInfo = ref({})
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const selecSkuArray = ref([])
|
||||
|
||||
// 确认选择规格
|
||||
function submitSku() {
|
||||
dialogVisible.value = false
|
||||
@@ -67,10 +69,48 @@ function submitSku() {
|
||||
}
|
||||
|
||||
// 选择规格
|
||||
function selectedSku(index, i) {
|
||||
function selectedSku(index = 0, i = 0) {
|
||||
goods.value.selectSpec[index].selectSpecResult.map(item => {
|
||||
item.active = false
|
||||
})
|
||||
|
||||
|
||||
if (index == 0) {
|
||||
selecSkuArray.value = []
|
||||
}
|
||||
|
||||
|
||||
if (selecSkuArray.value.length - 1 > index) {
|
||||
// console.log(selecSkuArray.value.length - 1);
|
||||
// console.log(index);
|
||||
selecSkuArray.value.splice(index + 1, selecSkuArray.value.length)
|
||||
}
|
||||
|
||||
selecSkuArray.value[index] = goods.value.selectSpec[index].selectSpecResult[i].name
|
||||
|
||||
if (index < goods.value.selectSpec.length - 1) {
|
||||
selectedSkuNum.value = 0
|
||||
goods.value.selectSpec.map((item, idx) => {
|
||||
if (index < idx) {
|
||||
item.selectSpecResult.map(val => {
|
||||
val.disabled = true
|
||||
val.active = false
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
goods.value.selectSpec[index + 1].selectSpecResult.map(item => {
|
||||
goods.value.groundingSpecInfo.map(val => {
|
||||
// console.log(val);
|
||||
// console.log(`${selecSkuArray.value.join(',')},${item.name}`);
|
||||
// console.log(val.specSnap.indexOf(`${selecSkuArray.value.join(',')},${item.name}`));
|
||||
if (val.specSnap.indexOf(`${selecSkuArray.value.join(',')},${item.name}`) != -1 && val.isGrounding) {
|
||||
item.disabled = false
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (goods.value.selectSpec[index].selectSpecResult[i].active) {
|
||||
goods.value.selectSpec[index].selectSpecResult[i].active = false
|
||||
selectedSkuNum.value--
|
||||
@@ -78,6 +118,7 @@ function selectedSku(index, i) {
|
||||
goods.value.selectSpec[index].selectSpecResult[i].active = true
|
||||
selectedSkuNum.value++
|
||||
}
|
||||
|
||||
selectedSuccess()
|
||||
}
|
||||
|
||||
@@ -99,6 +140,8 @@ function selectedSuccess() {
|
||||
if (selectedSkuNum.value >= goods.value.selectSpec.length) {
|
||||
// 规格选完了
|
||||
queryProductSkuAjax()
|
||||
} else {
|
||||
goodsInfo.value = {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,14 +177,23 @@ function show(item, t = 'shop') {
|
||||
goods.value = item
|
||||
type.value = t
|
||||
goods.value.selectSpec = JSON.parse(goods.value.selectSpec)
|
||||
goods.value.selectSpec.map(item => {
|
||||
goods.value.selectSpec.map((item, index) => {
|
||||
let arr = []
|
||||
item.selectSpecResult.map(val => {
|
||||
switch (type.value) {
|
||||
case 'shop':
|
||||
let disabled = true
|
||||
if (index == 0) {
|
||||
goods.value.groundingSpecInfo.map(item => {
|
||||
if (item.specSnap.indexOf(val) != -1 && item.isGrounding) {
|
||||
disabled = false
|
||||
}
|
||||
})
|
||||
}
|
||||
arr.push({
|
||||
active: false,
|
||||
name: val
|
||||
name: val,
|
||||
disabled: index == 0 ? disabled : true
|
||||
})
|
||||
break;
|
||||
case 'cart':
|
||||
@@ -149,7 +201,8 @@ function show(item, t = 'shop') {
|
||||
const skus = goods.value.skuName.split(',')
|
||||
arr.push({
|
||||
active: !!skus.find(item => item === val),
|
||||
name: val
|
||||
name: val,
|
||||
disabled: true
|
||||
})
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user