diff --git a/.env.development b/.env.development index 6ab192b..98c3e63 100644 --- a/.env.development +++ b/.env.development @@ -5,7 +5,10 @@ ENV = 'development' # VUE_APP_BASE_API = 'http://192.168.2.42:8000' # VUE_APP_BASE_API = 'http://192.168.2.133:8000' # 测试 -VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' +# VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' +#预发布 +VUE_APP_BASE_API = 'https://pre-cashieradmin.sxczgkj.cn' + # 生产 # VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn' # VUE_APP_BASE_API = 'http://192.168.2.96:8000' diff --git a/.env.production b/.env.production index 2a4f841..1db13cc 100644 --- a/.env.production +++ b/.env.production @@ -3,13 +3,13 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http # 测试 -VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' +# VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' # 生产 # VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn' # 预发布接口 -# VUE_APP_BASE_API = 'https://pre-cashieradmin.sxczgkj.cn' +VUE_APP_BASE_API = 'https://pre-cashieradmin.sxczgkj.cn' # VUE_APP_BASE_API = 'http://192.168.2.98:8000' # 如果接口是 http 形式, wss 需要改为 ws diff --git a/src/api/table.js b/src/api/table.js index 57bf688..1a691c3 100644 --- a/src/api/table.js +++ b/src/api/table.js @@ -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 + } + }); +} diff --git a/src/views/tool/Instead/components/scan-pay.vue b/src/views/tool/Instead/components/scan-pay.vue index fd68e0e..a4c7099 100644 --- a/src/views/tool/Instead/components/scan-pay.vue +++ b/src/views/tool/Instead/components/scan-pay.vue @@ -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(); diff --git a/src/views/tool/Instead/index.vue b/src/views/tool/Instead/index.vue index 0a756d6..b60aa75 100644 --- a/src/views/tool/Instead/index.vue +++ b/src/views/tool/Instead/index.vue @@ -54,7 +54,7 @@ @click="changeTable(item, index)" > {{ item.name }} - + {{ status[item.status] ? status[item.status].label : "" }} --> -
+
@@ -945,54 +965,80 @@
-
-
-
¥{{ skuGoods.data.salePrice | to2 }}
-
- {{ skuText }} - 库存:{{ skuGoods.data.stockNumber || 0 }} + +
@@ -1166,7 +1212,7 @@
@@ -1209,6 +1255,7 @@ import { $printOrder, tbShopTableGet, $changeUseType, + $returnTableDetail, } from "@/api/table"; import { tbShopCategoryGet } from "@/api/shop"; import { @@ -1261,6 +1308,11 @@ export default { }, //台桌列表 tableList: [], + //台桌参数 + tableQuery: { + page: 1, + size: 20, + }, tableShow: false, status: $status, //就餐人数 @@ -1293,10 +1345,7 @@ export default { }, skuGoods: { number: 1, - data: { - stockNumber: 0, - salePrice: 0, - }, + data: undefined, }, selGoods: { isEdit: false, @@ -1312,12 +1361,13 @@ export default { informationdialogshow: false, informationdialogshowedit: false, goods: { + status: "loadmore", //loadmore end list: [], query: { productId: "", categoryId: "", page: 1, - size: 300, + size: 66, }, loading: false, total: 0, @@ -1554,13 +1604,22 @@ export default { this.selGoods.show = false; }, CanConfirm() { - if (!this.selGoods.skuList.length) { - return true; - } - return ( - this.selGoods.skuList.filter((v) => v.sel !== "").length !== - this.selGoods.skuList.length - ); + // if (!this.skuGoods.data) { + // return; + // } + // if (!this.selGoods.skuList.length) { + // return true; + // } + // const canBuyArr = this.selGoods.skuList.filter((v) => + // isCanBuy(v, this.selGoods.isStock) + // ); + // if (canBuyArr.length <= 0) { + // return true; + // } + // return ( + // this.selGoods.skuList.filter((v) => v.sel !== "").length !== + // this.selGoods.skuList.length + // ); }, }, filters: { @@ -1581,6 +1640,12 @@ export default { }, }, watch: { + "goods.query.categoryId": function (newval) { + this.goods.query.page = 1; + this.goods.list = []; + this.goods.status = "loadmore"; + this.getGoods(); + }, "useTypes.sel": function (newval, oldval) { console.log(newval); this.setPostPay(); @@ -1740,15 +1805,24 @@ 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; + this.getGoods(); + } + }, async shoukuanClick() { this.canShoukuan = await hasPermission("允许收款"); - return this.canShoukuan; + return this.canShoukuan; }, // 打开页面 async xiadanClick() { this.canXiadan = await hasPermission("允许下单"); - return this.canXiadan; - + return this.canXiadan; }, changeOrderExtraSel(index, canChangeNumber, placeNum) { // console.log(index,canChangeNumber,placeNum) @@ -1855,10 +1929,10 @@ export default { if (!canJiesuan) { return; } - await this.returnCreateOrderData(); - console.log( this.createOrder.data ) + 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) { @@ -2011,6 +2085,7 @@ export default { async getTable() { try { const { content, total } = await tbShopTableGet({ + ...this.tableQuery, shopId: localStorage.getItem("shopId"), }); this.tableList = content.filter( @@ -2020,7 +2095,40 @@ export default { console.log(error); } }, - changeTable(item) { + async changeTable(item) { + console.log(this.table); + 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; }, @@ -2036,9 +2144,8 @@ export default { } this.pays(); }, - payTypeItemClick(item) { - console.log(item); - console.log(this.vipUser.id); + payTypeItemClick(item, order) { + order = order ? order : this.createOrder.data; if (item.payType == "vipPay") { return this.refChooseUserOpen(); } @@ -2048,7 +2155,10 @@ 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) { @@ -2182,7 +2292,12 @@ 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); @@ -2250,7 +2365,7 @@ export default { if (!canXiadan) { return; } - }else{ + } else { //去结算 const canJiesuan = await this.shoukuanClick(); if (!canJiesuan) { @@ -2273,14 +2388,15 @@ export default { console.log(this.order.orderId); let res = ""; try { - const seatFee = await $choseCount({ - masterId: this.masterId, - tableId: this.table.tableId, - num: this.perpole, - }); - this.order.seatFee = seatFee; - - this.order.seatFee = res; + if (!this.shopInfo.isTableFee) { + const seatFee = await $choseCount({ + masterId: this.masterId, + tableId: this.table.tableId, + num: this.perpole, + }); + this.order.seatFee = seatFee; + this.order.seatFee = res; + } res = await $createOrder({ masterId: this.order.masterId || this.masterId, vipUserId: this.vipUser.id, @@ -2316,23 +2432,15 @@ export default { }, // 获取取餐号 - getMasterId() { - // if(!this.table.tableId){ - // return this.$message.error("请选择桌台"); - // } - if (this.table.tableId) { - return $getMasterId({ - tableId: this.table.tableId, - orderId: this.table.orderId, - vipUserId: this.vipUser.id, - useType: this.useTypes.sel == "takeout" ? "takeout" : "", - }); - } else { - // return $getMasterId({ - // useType:'takeout', - // vipUserId: this.vipUser.id, - // }); - } + async getMasterId() { + const res = await $getMasterId({ + tableId: this.table.tableId, + orderId: this.table.orderId, + vipUserId: this.vipUser.id, + useType: this.useTypes.sel == "takeout" ? "takeout" : "", + }); + this.masterId = res.masterId; + return res; }, onSelGoodsSkuClose() { this.selGoods.isEdit = false; @@ -2885,7 +2993,7 @@ export default { .filter((v) => v.specSnap.match(i)) .every((v) => { // return isCanBuy(v,this.selGoods.data.isStock) - return !isCanBuy(v, true); + return !isCanBuy(v, this.selGoods.data); }); } } @@ -3008,7 +3116,7 @@ export default { return prve; }, {}); const canBudyGoods = this.selGoods.data.specList - .filter((v) => isCanBuy(v, true)) + .filter((v) => isCanBuy(v, this.selGoods.data)) .sort((a, b) => { const aNumber = a.specSnap.split(",").reduce((prve, cur) => { return prve + skuMapNumber[cur]; @@ -3022,6 +3130,7 @@ export default { }, //设置商品默认选中,规格禁止以及选中 setSkugoodsDefaultInit() { + this.skuGoods.data = undefined; const skuList = this.selGoods.skuList; const goodsListMap = this.selGoods.skuMap; const skuGoods = this.findGoods(skuList, goodsListMap); @@ -3057,9 +3166,9 @@ export default { }, //根据右侧商品单规格多规格做不同处理 async goodsClick(item) { - if (!this.table) { - return this.$message.error("暂不支持无桌台下单,请先选择桌台"); - } + // if (!this.table) { + // return this.$message.error("暂不支持无桌台下单,请先选择桌台"); + // } if (item.typeEnum === "sku") { this.selGoods.data = item; this.selGoods.skuMap = {}; @@ -3110,6 +3219,10 @@ export default { } }, async getGoods() { + if (this.goods.status == "end") { + return; + } + this.goods.status = "loadmore"; const res = await getGoodsLists(this.goods.query); let $goodsMap = {}; const goods = res.records.filter((v) => { @@ -3125,8 +3238,11 @@ export default { }); return isShow; }); - console.log($goodsMap); - this.goods.list = goods; + for (let i in goods) { + this.goods.list.push(goods[i]); + } + this.goods.status = + this.goods.list.length >= res.total ? "end" : "loadmore"; this.goods.total = res.total; this.$goodsData = goods; }, @@ -3182,7 +3298,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(); @@ -3976,11 +4092,12 @@ input[type="number"]::-webkit-outer-spin-button { .goods-list { display: flex; flex-wrap: wrap; - + min-height: 10px; .goods-item { position: relative; cursor: pointer; - min-width: 98px; + // min-width: 98px; + min-width: 100px; max-width: 100px; height: 100px; // flex: 1; @@ -4448,6 +4565,11 @@ input[type="number"]::-webkit-outer-spin-button { ::v-deep .cashier_left .el-form-item__label { text-align: left; } +::v-deep .goods .el-image { + display: flex; + width: 100%; + justify-content: center; +} .cashier_left .detail_box .usercard .info .nickname .vip_level { font-size: 12px; padding: 0 5px; diff --git a/src/views/tool/Instead/util.js b/src/views/tool/Instead/util.js index 3b7bd4d..6967221 100644 --- a/src/views/tool/Instead/util.js +++ b/src/views/tool/Instead/util.js @@ -1,6 +1,13 @@ //判断商品是否可以下单 -export function isCanBuy(goods,isStock) { - return goods.isGrounding && goods.isPauseSale == 0 && (isStock?goods.stockNumber > 0:true) ; +export function isCanBuy(skuGoods,goods) { + if(goods.typeEnum=='normal'){ + //单规格 + return goods.isGrounding&&goods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true); + }else{ + //多规格 + return goods.isGrounding&&goods.isPauseSale==0&&skuGoods.isGrounding&&skuGoods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true); + + } } // 一个数组是否包含另外一个数组全部元素 @@ -15,6 +22,8 @@ export function arrayContainsAll(arr1, arr2) { //n项 n-1项组合,生成全部结果 export function generateCombinations(arr, k) { + console.log(arr) + console.log(k) let result = []; function helper(index, current) {