This commit is contained in:
YeMingfei666 2024-10-08 10:56:44 +08:00
commit 89d5974fd2
3 changed files with 167 additions and 53 deletions

View File

@ -428,3 +428,14 @@ export function $changeUseType(data) {
} }
}); });
} }
//店铺订单支付获取链接
export function $getOrderPayUrl(data) {
return request({
url: '/api/shopPayApi/getOrderPayUrl',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}

View File

@ -37,7 +37,7 @@
</el-form-item> </el-form-item>
<div class="u-flex u-row-center u-m-t-50"> <div class="u-flex u-row-center u-m-t-50">
<el-button size="medium" @click="close">取消</el-button> <el-button size="medium" @click="close">取消</el-button>
<el-button size="medium" type="primary" @click="confirm" <el-button size="medium" type="primary" @click="confirm"
>确定</el-button >确定</el-button
> >
</div> </div>
@ -46,7 +46,11 @@
<template v-else> <template v-else>
<div class="u-text-center"> <div class="u-text-center">
<div class="u-flex u-row-center"> <div class="u-flex u-row-center">
<img :src="codeImg" class="codeImg" alt="" /> <div class="codeImg">
<canvas ref="canvas" id="QRCode_header"></canvas>
</div>
<!-- <img :src="codeImg" class="codeImg" alt="" /> -->
</div> </div>
<div class="color-333 u-font-20 u-m-t-20">32.00</div> <div class="color-333 u-font-20 u-m-t-20">32.00</div>
<div class="color-aaa u-font-12 u-m-t-10"> <div class="color-aaa u-font-12 u-m-t-10">
@ -60,12 +64,20 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import QRCode from "qrcode";
import { $getOrderPayUrl } from "@/api/table";
import { tbOrderInfoDetail } from "@/api/order";
export default { export default {
props: { props: {
openSwitch: { openSwitch: {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
order: {
type: Object,
default: () => ({}),
},
title: { title: {
type: String, type: String,
default: "支付", default: "支付",
@ -82,6 +94,7 @@ export default {
data() { data() {
return { return {
tips: "", tips: "",
paymentQrcode: "",
paysSel: 0, paysSel: 0,
form: { form: {
money: "", money: "",
@ -99,6 +112,7 @@ export default {
], ],
number: "0", number: "0",
show: false, show: false,
timer: null,
}; };
}, },
watch: { watch: {
@ -111,12 +125,23 @@ export default {
}, },
paysSel(newval) { paysSel(newval) {
if (newval == 0) { if (newval == 0) {
this.clear();
this.tips = "请使用扫码枪扫微信/支付宝收款码"; this.tips = "请使用扫码枪扫微信/支付宝收款码";
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.refInputCode.focus(); this.$refs.refInputCode.focus();
}); });
} else { } else {
this.tips = "请用户使用微信/支付宝扫描付款码"; this.tips = "请用户使用微信/支付宝扫描付款码";
this.startGetOrderInfo();
this.$nextTick(() => {
QRCode.toCanvas(
this.$refs.canvas,
this.paymentQrcode,
function (error) {
console.log(error);
}
);
});
} }
}, },
number(newval) { number(newval) {
@ -124,29 +149,50 @@ export default {
}, },
}, },
methods: { methods: {
codeInputChange(e){ clear() {
console.log(e) clearInterval(this.timer);
},
async getOrderDetail() {
const res = await tbOrderInfoDetail(this.order.id);
if (res.status == "closed") {
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); // this.$emit("confirm", this.form.code);
}, },
reset() { reset() {
// this.form.money='' // this.form.money=''
this.form.code = ""; this.form.code = "";
this.paysSel = 0; this.paysSel = 0;
this.clear();
}, },
changeKey(key, val) { changeKey(key, val) {
this[key] = val; this[key] = val;
}, },
confirm() { confirm() {
if(!this.form.code){ if (!this.form.code) {
return this.$message.error("请输入或扫付款码") return this.$message.error("请输入或扫付款码");
} }
this.close() this.close();
this.$emit("confirm", this.form.code); this.$emit("confirm", this.form.code);
}, },
open() { open() {
this.show = true; this.show = true;
this.form.money = Number(this.price).toFixed(2); this.form.money = Number(this.price).toFixed(2);
$getOrderPayUrl({ orderId: this.order.id }).then((res) => {
console.log(res);
this.paymentQrcode = res;
});
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.refInputCode.focus(); this.$refs.refInputCode.focus();
}); });
@ -171,8 +217,9 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.codeImg { .codeImg {
width: 160px; width: 164px;
border: 1px solid rgb(220, 223, 230); border: 1px solid rgb(220, 223, 230);
height: 160px; height: 164px;
overflow: hidden;
} }
</style> </style>

View File

@ -177,7 +177,7 @@
<el-button-group> <el-button-group>
<el-button <el-button
:class="{ active: item.value == useTypes.sel }" :class="{ active: item.value == useTypes.sel }"
:disabled="order.old.list.length > 0" :disabled="order.old.list.length > 0||item.disabled"
v-for="(item, index) in useTypes.list" v-for="(item, index) in useTypes.list"
@click="changeUseType(item.value)" @click="changeUseType(item.value)"
:key="index" :key="index"
@ -237,8 +237,11 @@
</div> </div>
</template> </template>
</div> </div>
<el-button @click="clearCart" type="text" size="mini" <el-button
:disabled="order.list.length<=0" @click="clearCart"
type="text"
size="mini"
:disabled="order.list.length <= 0"
>清空</el-button >清空</el-button
> >
</div> </div>
@ -305,19 +308,18 @@
<template v-if="order.seatFee && order.seatFee.totalAmount > 0"> <template v-if="order.seatFee && order.seatFee.totalAmount > 0">
<div class="list"> <div class="list">
<div class="carts_list_title">餐位费</div> <div class="carts_list_title">餐位费</div>
<cart-item <cart-item
@itemClick="changeOrderExtraSel" @itemClick="changeOrderExtraSel"
:canChangeNumber="false" :canChangeNumber="false"
key="seatFee" key="seatFee"
:index="0" :index="0"
:item="order.seatFee" :item="order.seatFee"
isSeatFee isSeatFee
:selIndex="order.extra.selIndex" :selIndex="order.extra.selIndex"
:placeNum="-10" :placeNum="-10"
:selPlaceNum="order.selPlaceNum" :selPlaceNum="order.selPlaceNum"
></cart-item> ></cart-item>
</div> </div>
</template> </template>
<div class="order_remark" v-if="note.content"> <div class="order_remark" v-if="note.content">
订单备注 {{ note.content }} 订单备注 {{ note.content }}
@ -519,9 +521,13 @@
prveOrder.list.length prveOrder.list.length
}}</span> }}</span>
</div> --> </div> -->
<div class="btn" <div
:class="{ disabled: order.selIndex < 0 }" class="btn"
@click="refNoteShow(true)">单品备注</div> :class="{ disabled: order.selIndex < 0 }"
@click="refNoteShow(true)"
>
单品备注
</div>
<div class="btn" @click="refNoteShow(false)">整单备注</div> <div class="btn" @click="refNoteShow(false)">整单备注</div>
<div <div
@ -1087,9 +1093,11 @@
ref="refWxScanCode" ref="refWxScanCode"
defaultTips="请使用扫码枪扫描微信/支付宝收款码" defaultTips="请使用扫码枪扫描微信/支付宝收款码"
title="扫码支付" title="扫码支付"
:openSwitch="false" :openSwitch="true"
:price="createOrder.data.amount * createOrder.discount" :price="createOrder.data.amount * createOrder.discount"
:order="createOrder.data"
@confirm="scanPayConfirm" @confirm="scanPayConfirm"
@paySuccess="payOrderSuccess"
></scan-pay> ></scan-pay>
<!-- 储值卡支付 --> <!-- 储值卡支付 -->
<scan-pay <scan-pay
@ -1183,14 +1191,17 @@ export default {
shopInfo: {}, shopInfo: {},
// //
useTypes: { useTypes: {
list:[],
list: [ list: [
{ {
name: "堂食", name: "堂食",
value: "dine-in", value: "dine-in",
disabled:true
}, },
{ {
name: "自取", name: "自取",
value: "takeout", value: "takeout",
disabled:true
}, },
], ],
sel: "dine-in", sel: "dine-in",
@ -1358,7 +1369,10 @@ export default {
computed: { computed: {
disableTuicai() { disableTuicai() {
return ( return (
this.order.placeNum==1 ||this.order.selIndex>=0||!this.order.selGoods||this.order.old.list.length<=0|| this.order.placeNum == 1 ||
this.order.selIndex >= 0 ||
!this.order.selGoods ||
this.order.old.list.length <= 0 ||
this.order.selGoods.status == "return" this.order.selGoods.status == "return"
); );
}, },
@ -1418,7 +1432,12 @@ export default {
.reduce((a, b) => { .reduce((a, b) => {
return a + b.number * b.salePrice; return a + b.number * b.salePrice;
}, 0); }, 0);
return (oldPrice + price + this.order.seatFee.totalAmount * (this.order.seatFee.status=='return'?0:1)).toFixed(2); return (
oldPrice +
price +
this.order.seatFee.totalAmount *
(this.order.seatFee.status == "return" ? 0 : 1)
).toFixed(2);
}, },
allNumber() { allNumber() {
const oldNumber = this.order.old.list.reduce((a, b) => { const oldNumber = this.order.old.list.reduce((a, b) => {
@ -1617,7 +1636,6 @@ export default {
// this.getCategory(); // this.getCategory();
// this.refToggle('refScanCode',true) // this.refToggle('refScanCode',true)
// this.refToggle("refDiscount", true); // this.refToggle("refDiscount", true);
this.getShopInfo();
console.log(this.$route.query.tableId); console.log(this.$route.query.tableId);
this.open(this.$route.query.tableId ? this.$route.query : ""); this.open(this.$route.query.tableId ? this.$route.query : "");
}, },
@ -1668,7 +1686,7 @@ export default {
}, },
changeOrderUseType(useType) { changeOrderUseType(useType) {
if (useType && this.order.list.length) { if (useType && this.order.list.length) {
const tableId = useType=='takeout'?undefined: this.table.tableId; const tableId = useType == "takeout" ? undefined : this.table.tableId;
$changeUseType({ $changeUseType({
useType, useType,
tableId, tableId,
@ -1721,6 +1739,9 @@ export default {
}, },
// //
async changePerpole() { async changePerpole() {
if (!this.table.tableId) {
return;
}
const res = await $choseCount({ const res = await $choseCount({
masterId: this.masterId, masterId: this.masterId,
tableId: this.table.tableId, tableId: this.table.tableId,
@ -1734,12 +1755,16 @@ export default {
const res = await this.getMasterId(); const res = await this.getMasterId();
this.masterId = res.masterId; this.masterId = res.masterId;
//1 //1
if (this.table.status == "idle" && !this.shopInfo.isTableFee) { if (
!this.perpole &&
this.table.status == "idle" &&
!this.shopInfo.isTableFee
) {
this.perpole = 1; this.perpole = 1;
await this.changePerpole(); await this.changePerpole();
} }
// //
const item=this.table; const item = this.table;
if (item && item.useType) { if (item && item.useType) {
localStorage.setItem("useType", item.useType); localStorage.setItem("useType", item.useType);
this.useTypes.sel = this.useTypes.sel =
@ -1750,13 +1775,14 @@ export default {
this.getCart(); this.getCart();
this.getCacheOrder(); this.getCacheOrder();
console.log(this.isCreateOrder); console.log(this.isCreateOrder);
if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0 ) { if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0) {
// //
const seatFee = await $choseCount({ const seatFee = await $choseCount({
masterId: this.masterId, masterId: this.masterId,
tableId: this.table.tableId, tableId: this.table.tableId,
num: this.perpole, num: res.seatFee ? res.seatFee.totalNumber : this.perpole,
}); });
console.log(seatFee);
this.order.seatFee = seatFee; this.order.seatFee = seatFee;
this.perpole = seatFee.totalNumber; this.perpole = seatFee.totalNumber;
} }
@ -1934,29 +1960,31 @@ export default {
}, },
async refOrderNoteConfirm(note) { async refOrderNoteConfirm(note) {
// //
if(this.isDanNote){ if (this.isDanNote) {
const cart=this.order.list[this.order.selIndex] const cart = this.order.list[this.order.selIndex];
const res= await $updateCart({ const res = await $updateCart({
cartId: cart.id, cartId: cart.id,
productId: cart.productId, productId: cart.productId,
skuId: cart.skuId, skuId: cart.skuId,
tableId: this.table.tableId, tableId: this.table.tableId,
note:note, note: note,
num: cart.number, // 0 num: cart.number, // 0
}); });
this.$set(this.order.list, this.order.selIndex, res); this.$set(this.order.list, this.order.selIndex, res);
this.$notify({ this.$notify({
title: "更新成功", title: "更新成功",
type: "success", type: "success",
}); });
}else{ } else {
// //
this.note.content = note; this.note.content = note;
} }
}, },
refNoteShow(isDan=false) { refNoteShow(isDan = false) {
this.isDanNote = isDan; this.isDanNote = isDan;
const note=isDan?this.order.list[this.order.selIndex].note:this.note.content; const note = isDan
? this.order.list[this.order.selIndex].note
: this.note.content;
this.$refs.refOrderNote.open(note); this.$refs.refOrderNote.open(note);
}, },
// //
@ -2081,11 +2109,17 @@ export default {
// if(!this.table.tableId){ // if(!this.table.tableId){
// return this.$message.error(""); // return this.$message.error("");
// } // }
if (this.table) { if (this.table.tableId) {
return $getMasterId({ return $getMasterId({
tableId: this.table.tableId, tableId: this.table.tableId,
vipUserId: this.vipUser.id, vipUserId: this.vipUser.id,
useType: this.useTypes.sel == "takeout" ? "takeout" : "",
}); });
} else {
// return $getMasterId({
// useType:'takeout',
// vipUserId: this.vipUser.id,
// });
} }
}, },
onSelGoodsSkuClose() { onSelGoodsSkuClose() {
@ -2860,6 +2894,7 @@ export default {
}, },
async getGoods() { async getGoods() {
const res = await getGoodsLists(this.goods.query); const res = await getGoodsLists(this.goods.query);
let $goodsMap = {};
const goods = res.records.filter((v) => { const goods = res.records.filter((v) => {
if (!v) { if (!v) {
return false; return false;
@ -2868,17 +2903,38 @@ export default {
if (v.typeEnum !== "sku") { if (v.typeEnum !== "sku") {
isShow = v.specList.length >= 1; isShow = v.specList.length >= 1;
} }
v.specList.map((spe) => {
$goodsMap[`${v.id}_${spe.id}`] = spe;
});
return isShow; return isShow;
}); });
console.log($goodsMap);
this.goods.list = goods; this.goods.list = goods;
this.goods.total = res.total; this.goods.total = res.total;
this.$goodsData = goods; this.$goodsData = goods;
}, },
async open(params) { async open(params) {
const shopId = localStorage.getItem("shopId");
const shopInfo = await tbShopInfo(shopId);
for(let i in shopInfo.eatModel){
let model=shopInfo.eatModel[i];
model=model=='take-out'?model.replace(/-/g,""):model;
console.log(model);
const item=this.useTypes.list.find(v=>v.value==model);
console.log(item);
if(item){
item.disabled=false;
}
}
this.shopInfo = shopInfo;
this.setPostPay();
this.setUseType();
this.getGoods(); this.getGoods();
this.getCategory(); this.getCategory();
this.getTable(); this.getTable();
console.log(params); console.log(params);
const res = await this.getMasterId();
console.log(res);
if (!params) { if (!params) {
// //
return; return;
@ -4357,12 +4413,12 @@ input[type="number"]::-webkit-outer-spin-button {
.pay_btns .el-button:disabled { .pay_btns .el-button:disabled {
border: 1px solid #dcdfe6; border: 1px solid #dcdfe6;
} }
.order_remark{ .order_remark {
font-size: 14px; font-size: 14px;
color: #666; color: #666;
margin-top: 5px; margin-top: 5px;
max-width: 340px; max-width: 340px;
word-break: break-all; word-break: break-all;
} }
</style> </style>