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

View File

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