增加无台桌下单切换台桌

This commit is contained in:
YeMingfei666 2024-10-25 14:50:52 +08:00
parent c473f30a37
commit 709036c050
3 changed files with 97 additions and 33 deletions

View File

@ -450,3 +450,14 @@ export function $returnOrder(data) {
}
});
}
//获取台桌详情状态
export function $returnTableDetail(data) {
return request({
url: '/api/tbShopTable/state',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}

View File

@ -118,6 +118,7 @@ export default {
number: "0",
show: false,
timer: null,
payPar:{}
};
},
watch: {
@ -136,18 +137,10 @@ export default {
this.$refs.refInputCode.focus();
});
} else {
this.getPayUrl()
this.tips = "请用户使用微信/支付宝扫描付款码";
this.startGetOrderInfo();
this.$nextTick(() => {
QRCode.toCanvas(
this.$refs.canvas,
this.paymentQrcode,{width: 160,
height: 160,},
function (error) {
console.log(error);
}
);
});
}
},
number(newval) {
@ -193,14 +186,28 @@ export default {
this.close();
this.$emit("confirm", this.form.code);
},
getPayUrl(){
$getOrderPayUrl(this.payPar).then((res) => {
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(this.price).toFixed(2);
this.payPar=data
if (this.openSwitch) {
$getOrderPayUrl({ orderId: this.order.id||data.id,payAmount:this.form.money||data.settlementAmount }).then((res) => {
console.log(res);
this.paymentQrcode = res;
});
// this.getPayUrl();
}
this.$nextTick(() => {
this.$refs.refInputCode.focus();

View File

@ -54,7 +54,7 @@
@click="changeTable(item, index)"
>
<span> {{ item.name }}</span>
<span :style="{ color: status[item.status].type }">
<span :style="{ color: returnTableColor(item.status) }">
{{
status[item.status] ? status[item.status].label : ""
}}</span
@ -759,9 +759,9 @@
</div>
</div>
</div>
<div class="u-m-t-20 color-999 text-center">{{
goods.status=='end'?'没有更多了':'加载中'
}}</div>
<div class="u-m-t-20 color-999 text-center">
{{ goods.status == "end" ? "没有更多了" : "加载中" }}
</div>
</template>
<div
class="no-search-result"
@ -1255,6 +1255,7 @@ import {
$printOrder,
tbShopTableGet,
$changeUseType,
$returnTableDetail,
} from "@/api/table";
import { tbShopCategoryGet } from "@/api/shop";
import {
@ -1307,6 +1308,11 @@ export default {
},
//
tableList: [],
//
tableQuery: {
page: 1,
size: 20,
},
tableShow: false,
status: $status,
//
@ -1355,7 +1361,7 @@ export default {
informationdialogshow: false,
informationdialogshowedit: false,
goods: {
status:'loadmore',//loadmore end
status: "loadmore", //loadmore end
list: [],
query: {
productId: "",
@ -1637,7 +1643,7 @@ export default {
"goods.query.categoryId": function (newval) {
this.goods.query.page = 1;
this.goods.list = [];
this.goods.status='loadmore'
this.goods.status = "loadmore";
this.getGoods();
},
"useTypes.sel": function (newval, oldval) {
@ -1799,6 +1805,10 @@ export default {
this.open(this.$route.query.tableId ? this.$route.query : "");
},
methods: {
returnTableColor(key) {
const item = $status[key];
return item ? item.type : "";
},
loadMoreGoods() {
if (this.goods.query.page * this.goods.query.size < this.goods.total) {
this.goods.query.page = this.goods.query.page + 1;
@ -1919,10 +1929,10 @@ export default {
if (!canJiesuan) {
return;
}
await this.returnCreateOrderData();
const order= await this.returnCreateOrderData();
console.log(this.createOrder.data);
this.order.payType = "scanCode";
this.payTypeItemClick({ payType: "scanCode" });
this.payTypeItemClick({ payType: "scanCode",order });
this.payBeforeClear();
},
async changeOrderUseType(useType) {
@ -2075,6 +2085,7 @@ export default {
async getTable() {
try {
const { content, total } = await tbShopTableGet({
...this.tableQuery,
shopId: localStorage.getItem("shopId"),
});
this.tableList = content.filter(
@ -2084,7 +2095,40 @@ export default {
console.log(error);
}
},
changeTable(item) {
async changeTable(item) {
if(this.table||this.order.list.length<=0){
this.table = item;
this.tableShow = false;
return
}
if(item.status!='idle'){
return this.$message.error("该台桌已在使用中");
}
const res = await $returnTableDetail({
tableId: item.tableId,
});
let res1 = null;
if (res.cartCount > 0) {
try {
res1 = await this.$confirm(
"该台桌购物车里有商品,是否清除该台桌里的商品?",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
);
} catch (e) {
console.log(e);
}
await $choseTable({
masterId: this.masterId,
tableId: item.tableId,
isClear: res1 == "confirm" ? true : false,
});
}
this.table = item;
this.tableShow = false;
},
@ -2100,9 +2144,10 @@ export default {
}
this.pays();
},
payTypeItemClick(item) {
console.log(item);
console.log(this.vipUser.id);
payTypeItemClick(item,order) {
order=order?order:this.createOrder.data;
console.log('--------order------')
console.log(order)
if (item.payType == "vipPay") {
return this.refChooseUserOpen();
}
@ -2112,7 +2157,7 @@ export default {
}
if (item.payType == "scanCode") {
//
return this.refToggle("refWxScanCode", true, this.createOrder.data);
return this.refToggle("refWxScanCode", true, {orderId:order.id,payAmount: (this.createOrder.data.amount * order.discount).toFixed(2)});
}
},
ChangeDiscount(discount) {
@ -2246,7 +2291,7 @@ export default {
return this.refChooseUserOpen();
}
if (this.order.payType == "scanCode") {
return this.refToggle("refWxScanCode", true, this.createOrder.data);
return this.refToggle("refWxScanCode", true, {orderId:this.createOrder.data.id,payAmount: (this.createOrder.data.amount * this.createOrder.discount).toFixed(2)});
}
if (this.order.payType == "deposit") {
return this.refToggle("refScanCode", true);
@ -3168,10 +3213,10 @@ export default {
}
},
async getGoods() {
if(this.goods.status=='end'){
return
if (this.goods.status == "end") {
return;
}
this.goods.status='loadmore'
this.goods.status = "loadmore";
const res = await getGoodsLists(this.goods.query);
let $goodsMap = {};
const goods = res.records.filter((v) => {
@ -3190,7 +3235,8 @@ export default {
for (let i in goods) {
this.goods.list.push(goods[i]);
}
this.goods.status= this.goods.list.length>=res.total ? 'end' : 'loadmore'
this.goods.status =
this.goods.list.length >= res.total ? "end" : "loadmore";
this.goods.total = res.total;
this.$goodsData = goods;
},
@ -3246,7 +3292,7 @@ export default {
},
close() {
if (this.table.tableId) {
this.$router.replace({ path: "/table/table_list" });
this.$router.replace({ path: "/tool/table_list" });
} else {
this.$router.go(0);
// this.reset();