fix: 订单管理页面调整增加退款功能,代客下单调整
This commit is contained in:
236
src/views/tool/Instead/components/carts/extra-fee.vue
Normal file
236
src/views/tool/Instead/components/carts/extra-fee.vue
Normal file
@@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<div class="flex order-item u-m-b-14 relative">
|
||||
<div class="flex u-col-center">
|
||||
<div class="img">
|
||||
<div class="isSeatFee img u-line-1 u-flex u-col-center u-row-center">
|
||||
<span>{{ name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 10px"></div>
|
||||
<div class="flex">
|
||||
<div class="order-number-box u-font-12">
|
||||
<div class="">X{{ number }}</div>
|
||||
</div>
|
||||
|
||||
<div class="color-333 total-price">
|
||||
<div>¥{{ to2(price) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
name: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
number: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
price: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
function to2(n) {
|
||||
return n.toFixed(2);
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.isSeatFee {
|
||||
background: #3f9eff;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.flex.order-item {
|
||||
padding: 4px;
|
||||
border-radius: 2px;
|
||||
display: flex;
|
||||
overflow: visible;
|
||||
cursor: pointer;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
transition: all 0.3s;
|
||||
|
||||
.status-box {
|
||||
width: 18px;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
|
||||
> span {
|
||||
display: block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 4px 0 4px 0;
|
||||
font-size: 12px;
|
||||
line-height: 17px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.isWaitCall {
|
||||
background: #d3adf7;
|
||||
}
|
||||
|
||||
.pack {
|
||||
background: #35ac6a;
|
||||
.number {
|
||||
background: #f56c6c;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
left: -7px;
|
||||
top: -7px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.da {
|
||||
background: #35ac6a;
|
||||
}
|
||||
|
||||
.tui {
|
||||
background: #ac4735;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.total-price {
|
||||
width: 94px;
|
||||
font-size: 16px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.good-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
min-width: 70px;
|
||||
|
||||
.specSnap {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.specSnapss {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 3px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
|
||||
.specSnap {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
color: #212121;
|
||||
overflow: hidden;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.img {
|
||||
width: 59px;
|
||||
height: 59px;
|
||||
position: relative;
|
||||
margin-right: 10px;
|
||||
|
||||
img {
|
||||
width: 59px;
|
||||
height: 59px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.note {
|
||||
max-width: 70%;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
text-align: left;
|
||||
color: #999;
|
||||
margin-top: 5px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.order-number-box {
|
||||
position: relative;
|
||||
|
||||
.absolute {
|
||||
width: 60px;
|
||||
height: 40px;
|
||||
right: -38px;
|
||||
top: -14px;
|
||||
position: absolute;
|
||||
|
||||
.order-input-number {
|
||||
position: absolute;
|
||||
right: -6px;
|
||||
top: 0;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
display: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
|
||||
padding: 9px 6px;
|
||||
background-color: #fff;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
&:hover .order-input-number {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.good_info_discount {
|
||||
height: 16px;
|
||||
padding: 0 3px;
|
||||
color: #ff3f3f;
|
||||
background-color: rgba(255, 63, 63, 0.1);
|
||||
border-radius: 2px;
|
||||
margin-left: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
::v-deep .order-input-number .el-input__inner::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
::v-deep .order-input-number .el-input__inner::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -112,6 +112,10 @@
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
useVipPrice: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isShowVipPrice: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -179,7 +183,14 @@ const vipAllPrice = computed(() => {
|
||||
return 0;
|
||||
});
|
||||
const allPrice = computed(() => {
|
||||
if (props.item.discount_sale_amount * 1 != 0) {
|
||||
if (props.useVipPrice) {
|
||||
const memberPrice = props.item.memberPrice || props.item.salePrice;
|
||||
return memberPrice * props.item.number;
|
||||
}
|
||||
if (
|
||||
props.item.hasOwnProperty("discount_sale_amount") &&
|
||||
props.item.discount_sale_amount * 1 != 0
|
||||
) {
|
||||
return props.item.number * props.item.discount_sale_amount;
|
||||
}
|
||||
return props.item.number * props.item.salePrice;
|
||||
|
||||
@@ -1,16 +1,30 @@
|
||||
<template>
|
||||
<div class="list">
|
||||
<div class="carts">
|
||||
<!-- 当前购物车 -->
|
||||
<div v-for="(item, index) in carts.list" :key="index">
|
||||
<carts-item
|
||||
:item="item"
|
||||
@changeNumber="changeNumber"
|
||||
:selCart="carts.selCart"
|
||||
@itemClick="itemClick(item)"
|
||||
@editNote="editNote"
|
||||
></carts-item>
|
||||
</div>
|
||||
<template v-if="carts.list && carts.list.length >= 1">
|
||||
<!-- 当前购物车 -->
|
||||
<div v-for="(item, index) in carts.list" :key="index">
|
||||
<carts-item
|
||||
:item="item"
|
||||
:useVipPrice="carts.useVipPrice"
|
||||
@changeNumber="changeNumber"
|
||||
:selCart="carts.selCart"
|
||||
@itemClick="itemClick(item)"
|
||||
@editNote="editNote"
|
||||
></carts-item>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 打包费 -->
|
||||
<template v-if="carts.packNum > 0">
|
||||
<div class="cart-title"><span>打包费</span></div>
|
||||
<extra-fee name="打包费" :number="carts.packNum" :price="carts.packFee"></extra-fee>
|
||||
</template>
|
||||
<!-- 餐位费 -->
|
||||
<template v-if="perpole >= 1">
|
||||
<div class="cart-title"><span>餐位费</span></div>
|
||||
<extra-fee name="餐位费" :number="perpole" :price="canWeiFee"></extra-fee>
|
||||
</template>
|
||||
|
||||
<!-- 赠菜 -->
|
||||
<div class="cart-title" v-if="carts.giftList.length > 0"><span>以下是优惠菜品</span></div>
|
||||
<div v-for="(item, index) in carts.giftList" :key="index">
|
||||
@@ -22,8 +36,28 @@
|
||||
@editNote="editNote"
|
||||
></carts-item>
|
||||
</div>
|
||||
<el-empty :image-size="60" v-if="carts.isEmpty" description="点餐列表为空" />
|
||||
|
||||
<el-empty image-size="60" v-if="carts.isEmpty" description="点餐列表为空" />
|
||||
<!-- 历史订单 -->
|
||||
<template v-for="(item, index) in carts.oldOrder.detailMap" :key="index">
|
||||
<div class="cart-title">
|
||||
<span>第{{ index }}次下单</span>
|
||||
</div>
|
||||
|
||||
<div v-for="(detaiItem, index) in item" :key="index">
|
||||
<carts-item
|
||||
:canChangeNumber="false"
|
||||
isOld
|
||||
:item="detaiItem"
|
||||
@changeNumber="changeNumber"
|
||||
:selCart="carts.selCart"
|
||||
@itemClick="itemClick(detaiItem)"
|
||||
@editNote="editNote"
|
||||
></carts-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- <div class="color-666 u-font-14">订单备注:{{ "123" }}</div> -->
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="yiyouhui">{{ carts.yiyouhui }}</div>
|
||||
@@ -31,17 +65,25 @@
|
||||
<el-link type="primary">打印制作单</el-link>
|
||||
<div>
|
||||
<span class="totalNumber">共{{ carts.totalNumber }}件</span>
|
||||
<span class="totalPrice">¥{{ carts.payMoney }}</span>
|
||||
<span class="totalPrice">¥{{ totalMoney }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" v-if="isXianFuKuan">
|
||||
<el-button type="primary" size="large" @click="createOrder">微信/支付宝</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder">现金</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder">更多支付</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder()">微信/支付宝</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder()">现金</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder()">更多支付</el-button>
|
||||
</div>
|
||||
<div class="btn-group" v-else>
|
||||
<el-button type="primary" size="large" @click="createOrder">仅下单</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder">去结账</el-button>
|
||||
<template v-if="!showOrder">
|
||||
<el-button type="primary" size="large" @click="createOrder('only-create')">
|
||||
仅下单
|
||||
</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder('to-pay')">去结账</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button type="default" size="large" @click="hideOrder()">加菜/返回</el-button>
|
||||
<el-button type="primary" size="large" @click="createOrder('to-pay')">立即支付</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,11 +91,39 @@
|
||||
|
||||
<script setup>
|
||||
import cartsItem from "./item.vue";
|
||||
import { useCartsStore } from "@/store/modules/carts";
|
||||
import extraFee from "./extra-fee.vue";
|
||||
|
||||
let isXianFuKuan = ref(true);
|
||||
import { useCartsStore } from "@/store/modules/carts";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
|
||||
const shopUser = useUserStore();
|
||||
const carts = useCartsStore();
|
||||
|
||||
const props = defineProps({
|
||||
table: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
tableCode: "",
|
||||
};
|
||||
},
|
||||
},
|
||||
perpole: {
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
showOrder: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
oldOrder: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
detailMap: [],
|
||||
};
|
||||
},
|
||||
},
|
||||
goodsList: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
@@ -63,36 +133,58 @@ const props = defineProps({
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const emits = defineEmits(["editNote", "createOrder"]);
|
||||
let isXianFuKuan = computed(() => {
|
||||
if (!props.table.tableCode) {
|
||||
return true;
|
||||
}
|
||||
return shopUser.userInfo.registerType === "before" ? true : false;
|
||||
});
|
||||
const canWeiFee = computed(() => {
|
||||
if (shopUser.userInfo.isTableFee) {
|
||||
return 0;
|
||||
}
|
||||
if (props.perpole >= 1) {
|
||||
return props.perpole * shopUser.userInfo.tableFee;
|
||||
}
|
||||
});
|
||||
const emits = defineEmits(["editNote", "createOrder", "hideOrder"]);
|
||||
function editNote() {
|
||||
emits("editNote");
|
||||
}
|
||||
|
||||
function createOrder() {
|
||||
emits("createOrder");
|
||||
function hideOrder() {
|
||||
emits("hideOrder");
|
||||
}
|
||||
function createOrder(key) {
|
||||
emits("createOrder", key);
|
||||
}
|
||||
const selCartId = ref(null);
|
||||
|
||||
const carts = useCartsStore();
|
||||
watch(
|
||||
() => props.table.tableCode,
|
||||
(newval) => {
|
||||
init();
|
||||
}
|
||||
);
|
||||
|
||||
const goodsMap = {};
|
||||
watch(
|
||||
() => props.goodsMapisFinish,
|
||||
(newval) => {
|
||||
if (newval) {
|
||||
for (let goods of props.goodsList) {
|
||||
goodsMap[goods.id] = goods;
|
||||
}
|
||||
carts.init(
|
||||
{
|
||||
table_code: "",
|
||||
},
|
||||
goodsMap
|
||||
);
|
||||
init();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function init() {
|
||||
for (let goods of props.goodsList) {
|
||||
goodsMap[goods.id] = goods;
|
||||
}
|
||||
console.log(props.table);
|
||||
|
||||
carts.init({ table_code: props.table.tableCode }, goodsMap, props.oldOrder);
|
||||
}
|
||||
|
||||
function itemClick(item) {
|
||||
carts.changeSelCart(item);
|
||||
}
|
||||
@@ -100,8 +192,15 @@ function itemClick(item) {
|
||||
function changeNumber(step, item) {
|
||||
carts.changeNumber(step * 1, item);
|
||||
}
|
||||
const totalMoney = computed(() => {
|
||||
console.log(carts.payMoney);
|
||||
console.log(carts.oldOrder.originAmount);
|
||||
|
||||
return (carts.payMoney * 1 + (carts.oldOrder.originAmount || 0) * 1).toFixed(2);
|
||||
});
|
||||
defineExpose({
|
||||
carts,
|
||||
init,
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -29,13 +29,13 @@ const carts = useCartsStore();
|
||||
const controls = ref([
|
||||
{ label: "规格", key: "", disabled: false, per: "sku" },
|
||||
{ label: "赠送", key: "is_gift", disabled: false, per: "cart" },
|
||||
{ label: "打包", key: "is_pack", disabled: false, per: "cart" },
|
||||
{ label: "打包", key: "is_pack", disabled: false, per: "pack" },
|
||||
{ label: "删除", key: "del", disabled: false, per: "del" },
|
||||
{ label: "存单", key: "", disabled: false, per: "save" },
|
||||
{ label: "取单", key: "", disabled: false },
|
||||
{ label: "单品备注", key: "one-note", disabled: false, per: "one-note" },
|
||||
{ label: "整单备注", key: "all-note", disabled: false, per: "all-note" },
|
||||
{ label: "退菜", key: "", disabled: false, per: "order" },
|
||||
{ label: "退菜", key: "return", disabled: false, per: "return" },
|
||||
{ label: "免厨打", key: "is_print", disabled: false, per: "cart" },
|
||||
{ label: "单品改价", key: "changePriceClick", disabled: false, per: "cart" },
|
||||
{ label: "等叫", key: "is_wait_call", disabled: false, per: "cart" },
|
||||
@@ -49,6 +49,10 @@ function controlsClick(item) {
|
||||
carts.updateTag("is_gift", carts.selCart.is_gift ? 0 : 1);
|
||||
break;
|
||||
case "is_pack":
|
||||
if (carts.selCart.number * 1 == 1) {
|
||||
carts.updateTag("pack_number", carts.selCart.pack_number * 1 == 1 ? 0 : 1);
|
||||
return;
|
||||
}
|
||||
emits("packClick", carts.selCart.pack_number, carts.selCart.number);
|
||||
break;
|
||||
case "is_print":
|
||||
@@ -71,6 +75,8 @@ function controlsClick(item) {
|
||||
break;
|
||||
case "all-wating":
|
||||
carts.allWating();
|
||||
case "return":
|
||||
emits("return", carts.selCart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -79,10 +85,13 @@ const perList = computed(() => {
|
||||
return ["all-wating", "all-note"];
|
||||
}
|
||||
if (carts.isCanSelectGroup) {
|
||||
return ["all-wating", "all-note", "del"];
|
||||
return ["all-wating", "all-note", "del", "pack"];
|
||||
}
|
||||
if (carts.selCart.id) {
|
||||
return ["cart", "del", "save", "one-note", "all-note", "all-wating"];
|
||||
if (carts.isOldOrder) {
|
||||
return ["return"];
|
||||
}
|
||||
return ["cart", "del", "pack", "save", "one-note", "all-note", "all-wating"];
|
||||
}
|
||||
});
|
||||
const canEdit = computed(() => {
|
||||
@@ -97,7 +106,7 @@ function returnLabel(item) {
|
||||
return carts.selCart.is_gift ? "取消赠送" : "赠送";
|
||||
}
|
||||
if (item.key == "is_pack") {
|
||||
return carts.selCart.is_pack ? "取消打包" : "打包";
|
||||
return carts.selCart.pack_number * 1 > 0 ? "取消打包" : "打包";
|
||||
}
|
||||
if (item.key == "is_print") {
|
||||
return carts.selCart.is_print ? "免厨打" : "打印";
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<div class="u-flex u-row-center u-m-t-50">
|
||||
<el-button size="medium" @click="close">取消</el-button>
|
||||
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="confirm">确定</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -137,10 +137,7 @@ export default {
|
||||
|
||||
confirm() {
|
||||
console.log(this.form.discount / 100);
|
||||
this.$emit("confirm", {
|
||||
discount: this.form.discount / 100,
|
||||
currentPrice: ((this.form.discount * this.form.money) / 100).toFixed(2),
|
||||
});
|
||||
this.$emit("confirm", this.form);
|
||||
this.close();
|
||||
},
|
||||
open(data) {
|
||||
|
||||
@@ -2,16 +2,28 @@
|
||||
<div class="order-box">
|
||||
<div class="left">
|
||||
<div class="user bg-fff u-p-20">
|
||||
<div class="userinfo">
|
||||
<div class="userinfo" v-if="user.id" @click="chooseUser">
|
||||
<el-avatar class="avatar" :size="50" />
|
||||
<div class="u-m-l-12">
|
||||
<p>
|
||||
<span class="name u-font-16">hh</span>
|
||||
<span class="vip">VIP1</span>
|
||||
<span class="name u-font-16">{{ user.nickName }}</span>
|
||||
<span class="vip" v-if="user.isVip">>VIP{{ user.isVip }}</span>
|
||||
</p>
|
||||
<p class="u-font-14 color-666 u-m-t-10">
|
||||
<span class="money">余额:4.00</span>
|
||||
<span class="score u-m-l-10">积分:0</span>
|
||||
<span class="money">余额:{{ user.amount }}</span>
|
||||
<span class="score u-m-l-10">积分:{{ user.accountPoints }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="userinfo" v-else @click="chooseUser">
|
||||
<el-avatar class="avatar" :size="50" />
|
||||
<div class="u-m-l-12">
|
||||
<p>
|
||||
<span class="name u-font-16">服务员下单</span>
|
||||
</p>
|
||||
<p class="u-font-14 color-666 u-m-t-10">
|
||||
<span class="money">余额:</span>
|
||||
<span class="score u-m-l-10">积分:</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,7 +44,7 @@
|
||||
<span>积分不足或小于最低使用门槛1</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="u-flex u-col-center u-m-t-20">
|
||||
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
||||
<span class="u-font-14 font-bold u-m-r-20">团购代金券</span>
|
||||
<div class="u-flex my-select">
|
||||
<span class="u-m-r-10">代金券名称</span>
|
||||
@@ -40,7 +52,7 @@
|
||||
</div>
|
||||
<svg-icon iconClass="scan" size="30" class="u-m-l-10 cur-pointer"></svg-icon>
|
||||
</div>
|
||||
<div class="u-flex u-col-center u-m-t-20">
|
||||
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
||||
<span class="u-font-14 font-bold u-m-r-20">优惠券</span>
|
||||
<div class="u-flex my-select">
|
||||
<span class="u-m-r-10">选择优惠券</span>
|
||||
@@ -56,17 +68,17 @@
|
||||
<p class="u-font-16 font-bold u-m-r-20 font-bold">选择支付方式</p>
|
||||
<div class="u-m-t-20">
|
||||
<el-button
|
||||
v-for="(item, index) in payType.list"
|
||||
v-for="(item, index) in payTypes.list"
|
||||
:key="index"
|
||||
size="large"
|
||||
:type="index == payType.sel ? 'primary' : ''"
|
||||
:type="index == payTypes.sel ? 'primary' : ''"
|
||||
@click="changePayType(index)"
|
||||
>
|
||||
{{ item.label }}
|
||||
{{ item.payName }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
<el-button type="primary" size="large">立即支付</el-button>
|
||||
<el-button type="primary" size="large" @click="nowPayClick">立即支付</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,30 +87,30 @@
|
||||
<div class="order-info">
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">订单号:</span>
|
||||
<span class="u-m-l-10 value">202111111111111111</span>
|
||||
<span class="u-m-l-10 value">{{ orderInfo.orderNo }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">门店优惠</span>
|
||||
<span class="u-m-l-10 value"></span>
|
||||
<span class="title">餐位费</span>
|
||||
<span class="u-m-l-10 value">{{ orderInfo.seatAmount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">优惠券</span>
|
||||
<span class="u-m-l-10 value"></span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">积分抵扣</span>
|
||||
<span class="u-m-l-10 value"></span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">整单改价</span>
|
||||
<span class="u-m-l-10 value"></span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">餐位费/附加费</span>
|
||||
<span class="u-m-l-10 value"></span>
|
||||
<span class="title">打包费</span>
|
||||
<span class="u-m-l-10 value">{{ orderInfo.packFee }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">总价</span>
|
||||
<span class="u-m-l-10 value">{{ orderInfo.orderAmount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">优惠券</span>
|
||||
<span class="u-m-l-10 value">{{ coupDiscount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">积分抵扣</span>
|
||||
<span class="u-m-l-10 value">{{ orderInfo.pointsDiscountAmount || 0 }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">整单改价</span>
|
||||
<span class="u-m-l-10 value"></span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
@@ -107,33 +119,151 @@
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">应付金额</span>
|
||||
<span class="u-m-l-10 value"></span>
|
||||
<span class="u-m-l-10 value">{{ payMoney }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 扫码 -->
|
||||
<scanPay ref="refScanPay" :order="orderInfo"></scanPay>
|
||||
<!-- 打折 -->
|
||||
<discount ref="refDiscount" @confirm="discountConfirm"></discount>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import payTypeApi from "@/api/account/payType";
|
||||
import payApi from "@/api/order/pay";
|
||||
import scanPay from "./scan-pay.vue";
|
||||
import discount from "./discount.vue";
|
||||
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
|
||||
//打折
|
||||
const refDiscount = ref();
|
||||
const checkOrderPay = reactive({
|
||||
discountAmount: 0, //手动优惠金额
|
||||
});
|
||||
function discountConfirm(e) {
|
||||
console.log(e);
|
||||
checkOrderPay.discountAmount = e.reduceMoney;
|
||||
}
|
||||
function discountShow(e) {
|
||||
refDiscount.value.open({
|
||||
amount: props.orderInfo.originAmount,
|
||||
});
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
table: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
const emits = defineEmits(["chooseUser", "paysuccess"]);
|
||||
function chooseUser() {
|
||||
emits("chooseUser");
|
||||
}
|
||||
const coupDiscount = computed(() => {
|
||||
const total =
|
||||
props.orderInfo.fullCouponDiscountAmount * 1 + props.orderInfo.productCouponDiscountAmount * 1;
|
||||
if (total <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return total.toFixed(2);
|
||||
});
|
||||
const score = ref({
|
||||
list: [],
|
||||
sel: 0,
|
||||
});
|
||||
const emits = defineEmits(["discountShow"]);
|
||||
function discountShow() {
|
||||
emits("discountShow");
|
||||
}
|
||||
const payType = reactive({
|
||||
list: [
|
||||
{ label: "现金", value: "" },
|
||||
{ label: "扫码支付", value: "" },
|
||||
{ label: "会员支付", value: "" },
|
||||
],
|
||||
|
||||
const payTypes = reactive({
|
||||
list: [],
|
||||
sel: 0,
|
||||
});
|
||||
|
||||
const refScanPay = ref();
|
||||
function changePayType(i) {
|
||||
payType.sel = i;
|
||||
if (payTypes.list[i].payType === "scanCode") {
|
||||
return refScanPay.value.open({
|
||||
money: props.orderInfo.orderAmount,
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
checkOrderPay: {
|
||||
orderId: props.orderInfo.id,
|
||||
discountRatio: 1,
|
||||
orderAmount: props.orderInfo.orderAmount,
|
||||
seatNum: props.orderInfo.seatNum,
|
||||
originAmount: props.orderInfo.originAmount,
|
||||
discountAmount: props.orderInfo.discountAmount,
|
||||
productCouponDiscountAmount: props.orderInfo.productCouponDiscountAmount,
|
||||
orderAmount: props.orderInfo.orderAmount,
|
||||
roundAmount: props.orderInfo.roundAmount,
|
||||
pointsDiscountAmount: props.orderInfo.pointsDiscountAmount,
|
||||
pointsNum: props.orderInfo.pointsNum,
|
||||
fullCouponDiscountAmount: props.orderInfo.fullCouponDiscountAmount,
|
||||
},
|
||||
});
|
||||
}
|
||||
payTypes.sel = i;
|
||||
}
|
||||
async function getPaytype() {
|
||||
const res = await payTypeApi.getList();
|
||||
payTypes.list = res;
|
||||
}
|
||||
function nowPayClick() {
|
||||
const payType = payTypes.list[payTypes.sel].payType;
|
||||
console.log(payType);
|
||||
if (payType === "cash") {
|
||||
ElMessageBox.confirm("是否确认已现金收款:" + payMoney.value + "元", "快捷支付", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
payApi
|
||||
.cashPay({
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
checkOrderPay: {
|
||||
orderId: props.orderInfo.id,
|
||||
discountRatio: 1,
|
||||
orderAmount: props.orderInfo.orderAmount,
|
||||
seatNum: props.orderInfo.seatNum,
|
||||
originAmount: props.orderInfo.originAmount,
|
||||
discountAmount: props.orderInfo.discountAmount,
|
||||
productCouponDiscountAmount: props.orderInfo.productCouponDiscountAmount,
|
||||
orderAmount: props.orderInfo.orderAmount,
|
||||
roundAmount: props.orderInfo.roundAmount,
|
||||
pointsDiscountAmount: props.orderInfo.pointsDiscountAmount,
|
||||
pointsNum: props.orderInfo.pointsNum,
|
||||
fullCouponDiscountAmount: props.orderInfo.fullCouponDiscountAmount,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
ElMessage.success("支付成功");
|
||||
emits("paysuccess");
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const payMoney = computed(() => {
|
||||
if (!props.orderInfo.orderAmount) {
|
||||
return "";
|
||||
}
|
||||
return (props.orderInfo.orderAmount - checkOrderPay.discountAmount).toFixed(2);
|
||||
});
|
||||
onMounted(() => {
|
||||
getPaytype();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -141,6 +271,7 @@ function changePayType(i) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.vip {
|
||||
padding: 2px 5px;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
placeholder="请输入打包数量"
|
||||
></el-input-number>
|
||||
<template #footer>
|
||||
<el-button size="medium" @click="close">取消</el-button>
|
||||
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
|
||||
<el-button size="default" @click="close">取消</el-button>
|
||||
<el-button size="default" type="primary" @click="confirm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="">
|
||||
<div>单价</div>
|
||||
<div class="u-m-t-10">
|
||||
<el-tag type="primary" size="medium">¥{{ price }}/{{ item.unitName }}</el-tag>
|
||||
<el-tag type="primary">¥{{ price }}/{{ item.unitName }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
@@ -38,9 +38,7 @@
|
||||
<div class="price u-text-left w-full">¥ {{ allPrice }}</div>
|
||||
|
||||
<div class="confirm_btns u-flex u-m-t-20">
|
||||
<el-button style="width: 100%" type="primary" size="medium" @click="confirm">
|
||||
确定
|
||||
</el-button>
|
||||
<el-button style="width: 100%" type="primary" @click="confirm">确定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
229
src/views/tool/Instead/components/scan-pay.vue
Normal file
229
src/views/tool/Instead/components/scan-pay.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<el-dialog width="400px" :title="title" v-model="show" @close="reset">
|
||||
<div class="u-p-15">
|
||||
<div v-if="openSwitch">
|
||||
<el-button
|
||||
@click="changeKey('paysSel', index)"
|
||||
v-for="(item, index) in pays"
|
||||
:key="index"
|
||||
:type="paysSel == index ? 'primary' : ''"
|
||||
>
|
||||
{{ item.text }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
<el-alert :closable="false" v-if="tips" :title="tips" type="warning" show-icon></el-alert>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
<template v-if="paysSel == 0">
|
||||
<el-form label-width="90px" label-position="left">
|
||||
<el-form-item label="应付金额">
|
||||
<el-input :value="form.money" disabled></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="付款码">
|
||||
<el-input
|
||||
v-model="form.code"
|
||||
@change="codeInputChange"
|
||||
placeholder="请扫码或者输入付款码"
|
||||
ref="refInputCode"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<div class="u-flex u-row-center u-m-t-50">
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="confirm">确定</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="u-text-center">
|
||||
<div class="u-flex u-row-center">
|
||||
<div class="codeImg">
|
||||
<canvas ref="canvas" id="QRCode_header"></canvas>
|
||||
</div>
|
||||
|
||||
<!-- <img :src="codeImg" class="codeImg" alt="" /> -->
|
||||
</div>
|
||||
<div class="color-333 u-font-20 u-m-t-20">{{ to2(price) }}元</div>
|
||||
<div class="color-aaa u-font-12 u-m-t-10">
|
||||
<i class="el-icon-loading"></i>
|
||||
<span>等待用户支付</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import QRCode from "qrcode";
|
||||
import orderApi from "@/api/order/order";
|
||||
import payApi from "@/api/order/pay";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
openSwitch: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
order: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: "支付",
|
||||
},
|
||||
price: {
|
||||
type: [String, Number],
|
||||
default: 0,
|
||||
},
|
||||
defaultTips: {
|
||||
type: String,
|
||||
default: "请使用扫码枪扫描付款码",
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tips: "",
|
||||
paymentQrcode: "",
|
||||
paysSel: 0,
|
||||
form: {
|
||||
money: "",
|
||||
code: "",
|
||||
},
|
||||
codeImg:
|
||||
"https://zhyx.eingdong.com/qrcode/api.php?url=https%3A%2F%2Fzhyx.eingdong.com%2Fcopyright%2F%23%2Fpay%3Fid%3D139451580",
|
||||
pays: [
|
||||
{
|
||||
text: "主扫",
|
||||
},
|
||||
{
|
||||
text: "被扫",
|
||||
},
|
||||
],
|
||||
number: "0",
|
||||
show: false,
|
||||
timer: null,
|
||||
payPar: {},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
defaultTips(val) {
|
||||
this.tips = val;
|
||||
},
|
||||
price(val) {
|
||||
console.log(val);
|
||||
this.form.money = Number(val).toFixed(2);
|
||||
},
|
||||
paysSel(newval) {
|
||||
if (newval == 0) {
|
||||
this.clear();
|
||||
this.tips = "请使用扫码枪扫微信/支付宝收款码";
|
||||
this.$refs.refInputCode.focus();
|
||||
} else {
|
||||
this.getPayUrl();
|
||||
this.tips = "请用户使用微信/支付宝扫描付款码";
|
||||
// this.startGetOrderInfo();
|
||||
}
|
||||
},
|
||||
number(newval) {
|
||||
this.$emit("input", newval);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
to2(n) {
|
||||
return n.toFixed(2);
|
||||
},
|
||||
clear() {
|
||||
clearInterval(this.timer);
|
||||
},
|
||||
async getOrderDetail() {
|
||||
const res = await orderApi.getHistoryList({
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
orderId: this.order.id,
|
||||
});
|
||||
if (res.status == "closed") {
|
||||
this.clear();
|
||||
this.$emit("paySuccess");
|
||||
}
|
||||
},
|
||||
startGetOrderInfo() {
|
||||
clearInterval(this.timer);
|
||||
this.getOrderDetail();
|
||||
this.timer = setInterval(() => {
|
||||
this.getOrderDetail();
|
||||
}, 1000);
|
||||
},
|
||||
codeInputChange(e) {
|
||||
console.log(e);
|
||||
// this.$emit("confirm", this.form.code);
|
||||
},
|
||||
reset() {
|
||||
// this.form.money=''
|
||||
this.form.code = "";
|
||||
this.paysSel = 0;
|
||||
this.clear();
|
||||
},
|
||||
changeKey(key, val) {
|
||||
this[key] = val;
|
||||
},
|
||||
|
||||
confirm() {
|
||||
if (!this.form.code) {
|
||||
return this.$message.error("请输入或扫付款码");
|
||||
}
|
||||
this.close();
|
||||
this.$emit("confirm", this.form.code);
|
||||
},
|
||||
async getPayUrl() {
|
||||
const res = await payApi.microPay(this.payPar);
|
||||
console.log(res);
|
||||
this.paymentQrcode = res;
|
||||
this.$nextTick(() => {
|
||||
QRCode.toCanvas(
|
||||
this.$refs.canvas,
|
||||
this.paymentQrcode,
|
||||
{ width: 160, height: 160 },
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
open(data) {
|
||||
this.show = true;
|
||||
this.form.money = Number(data.money).toFixed(2);
|
||||
this.payPar = data;
|
||||
if (this.openSwitch) {
|
||||
// this.getPayUrl();
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs.refInputCode.focus();
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.show = false;
|
||||
},
|
||||
numberInput(val) {
|
||||
console.log(val);
|
||||
this.number = `${Number(val)}`;
|
||||
},
|
||||
keyboradConfirm() {
|
||||
this.$emit("confirm", this.number);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.number = `${this.value}`;
|
||||
this.tips = this.defaultTips;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.codeImg {
|
||||
width: 164px;
|
||||
border: 1px solid rgb(220, 223, 230);
|
||||
height: 164px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user