diff --git a/common/js/api.js b/common/js/api.js index ea8d6eb..88ca514 100644 --- a/common/js/api.js +++ b/common/js/api.js @@ -35,25 +35,23 @@ export default { cleanCart(data) { //清空购物车 return uni.api.post("/product/cleanCart", data); }, - - // 下单 - creatGroupOrder(data) { - return uni.api.post("/groupOrderInfo/creatGroupOrder", data); - }, - // 支付 - payOrderPay(data) { - return uni.api.post("/pay/groupOrderPay", data); + // 下单详情 + getproductorderConfirm(data) { + return uni.api.get("/product/orderConfirm", data); }, // 下单详情 getproductorderConfirm(data) { return uni.api.get("/product/orderConfirm", data); }, - logincreateCardNo(data) { //获取会员码 - return uni.api.get("/login/createCardNo", data); + choseEatModel(data) { //就餐模式选择 + return uni.api.post("/product/choseEatModel", data, false); }, - + // 支付 + payOrderPay(data) { + return uni.api.post("/pay/groupOrderPay", data); + }, // 会员支付 accountPay(data) { return uni.api.get("/pay/accountPay", data); @@ -64,6 +62,10 @@ export default { paymodfiyOrderInfo(data) { //查询订单支付状态 return uni.api.post("/pay/modfiyOrderInfo", data); }, + paymemeberIn(data) { //充值 + return uni.api.post("/pay/memeberIn", data); + }, + orderorderList(data) { //订单列表 return uni.api.get("/order/orderList", data); @@ -74,6 +76,10 @@ export default { removeOrder(data) { //删除订单 return uni.api.post("/order/rmOrder", data); }, + creatOrder(data) { //创建订单 + return uni.api.post("/order/creatOrder", data); + }, + // 团购订单列表 groupOrderInfo(data) { //订单列表 @@ -83,10 +89,11 @@ export default { groupOrderInfoDetail(data) { //订单回显 return uni.api.get("/groupOrderInfo/get", data); }, - - paymemeberIn(data) { //充值 - return uni.api.post("/pay/memeberIn", data); + // 下单 + creatGroupOrder(data) { + return uni.api.post("/groupOrderInfo/creatGroupOrder", data); }, + // 获取店铺会员信息 diff --git a/pagesOrder/confirm_order/index.vue b/pagesOrder/confirm_order/index.vue index 67c7833..1f49a26 100644 --- a/pagesOrder/confirm_order/index.vue +++ b/pagesOrder/confirm_order/index.vue @@ -16,14 +16,14 @@ - + - - {{item.title}} + + {{item.title}} - + 桌台 @@ -144,10 +144,10 @@ - + - + 请输入支付密码 @@ -185,7 +185,7 @@ toplist: { name: '确认订单' }, - is_type: 1, + is_type: 0, is_typeList: [ { title: "送餐到桌", show: false, type: "table", val: "dine-in", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/tab1.png" , url_active: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/tab1_active.png"}, { title: "打包外带", show: false, type: "takeself", val: "take-out", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/tab2.png" , url_active: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/tab2_active.png"}, @@ -253,13 +253,14 @@ if ( e.dinersNum ) { this.dinersNum = e.dinersNum;} if ( this.storeInfo.eatModel.indexOf("dine-in") != -1 ) { - this.eatModel = ["dine-in"] + this.eatModel = "dine-in"; + this.is_type = 0; } else { - this.eatModel = ["take-out"] - } - if ( e.tableCode ) { - this.getProductqueryShop() + this.eatModel = "take-out"; + this.is_type = 1; } + this.getProductqueryShop(); + this.getchoseEatModel(); }, onShow() { if (this.listinfoid) { @@ -355,28 +356,33 @@ } else { switch (msg.type) { case 'createOrder': - if ( this.storeInfo.registerType == 'restaurant') { - uni.switchTab({ - url: '/pages/order/order' - }); - return; + if ( this.eatModel == "dine-in" && this.tableCode ) { + if ( this.storeInfo.registerType == 'restaurant') { + uni.switchTab({ + url: '/pages/order/order' + }); + return; + } + this.isSocket = true; + this.listinfoid = msg.data.id + this.listinfo.details = msg.data.detailList; + this.listinfo.payAmount = msg.data.amount; + + uni.$off('getMessage') + this.orderorderInfo(1) } - this.isSocket = true; - this.listinfoid = msg.data.id - this.listinfo.details = msg.data.detailList; - this.listinfo.payAmount = msg.data.amount; - - uni.$off('getMessage') - this.orderorderInfo(1) break; case 'addCart': this.isSocket = true; - if (this.listinfoid) { - this.orderorderInfo() - } else { - this.listinfo.details = msg.data; - this.listinfo.payAmount = msg.amount; + if ( this.eatModel == "dine-in" && this.tableCode ) { + if (this.listinfoid) { + this.orderorderInfo() + } else { + this.listinfo.details = msg.data; + this.listinfo.payAmount = msg.amount; + } } + break; case 'order': uni.navigateBack() @@ -410,6 +416,22 @@ this.sendType = item.type this.eatModel = []; this.eatModel.push(item.val); + this.getchoseEatModel(); + }, + + /** + * 获取堂食/外带菜品数据 + */ + async getchoseEatModel () { + let params = { + shopId: uni.cache.get('shopId'), + type: this.is_type, + } + if ( this.eatModel == "dine-in" && this.tableCode ) { params.tableId = this.tableCode; } + if ( this.dinersNum ) { params.num = this.dinersNum; } + let res = await this.api.choseEatModel(params) + this.listinfo.details = res.data.info; + this.listinfo.payAmount = res.data.amount; }, /** @@ -421,6 +443,16 @@ this.paymentBtnText = e.name; }, + /** + * 输入密码关闭 + */ + close () { + this.ispws = false; + uni.pro.navigateTo('/pagesOrder/order_detail/index', { + orderId: this.listinfoid + }) + }, + /** * 初始化socket */ @@ -489,15 +521,9 @@ /** * 生成订单 */ - orderdetail() { - if (!this.isSocket) { - uni.showToast({ - title: "当前网络异常,请稍后再试", - icon: "none", - }) - return; - } - if ( this.sendType == 'table' && !this.tableCode) { + async orderdetail() { + + if ( this.eatModel == "dine-in" && !this.tableCode) { uni.showToast({ title: "请选择桌台", icon: "none", @@ -512,30 +538,23 @@ return; } - let data = { - "skuId": '', - "num": '', //数量 - "type": "createOrder", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”, - "remark": this.remark, - "couponsId": '', //优惠券ID, - "isYhq": 0, // 是否使用优惠券( 1: 使用, 0: 不使用), - "isBuyYhq": 0, // 是否购买优惠券( 1: 购买, 0: 不够买) - "productId": '', //商品id - "sendType": this.sendType, - "tableId": this.tableCode , //商品id - "dinersNum": this.dinersNum, //就餐人数 - "eatModel": this.eatModel, //就餐模式 + let res = await this.api.creatOrder({ + "tableId": this.tableCode , //桌台码 "shopId": uni.cache.get('shopId'), "userId": uni.cache.get('userInfo').id, - } - uni.$u.debounce(this.socketSendMsg(data), 500) + "sendType": this.sendType, + "remark": this.remark, + }) + console.log(res) + this.listinfoid = res.data.id + this.showpopupclickdd(); }, /** * 去支付 */ showpopupclickdd() { - if ( this.radiovalue == 2 || this.radiovalue == 3 && this.listinfo.payAmount <= 0 ) { + if ( (this.radiovalue == 2 || this.radiovalue == 3) && this.listinfo.payAmount <= 0 ) { uni.showToast({ title: "支付金额必须大于0", icon: 'none' @@ -547,7 +566,7 @@ mask: true }) // radiovalue为2是微信支付 - if (this.radiovalue == 2||this.radiovalue == 3) { + if (this.radiovalue == 2 || this.radiovalue == 3) { this.showpopupclickdds() //微信支付 } else { // 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码 @@ -619,6 +638,9 @@ }) }, fail: () => { + uni.pro.navigateTo('/pagesOrder/order_detail/index', { + orderId: this.listinfoid + }) uni.hideLoading() } }); @@ -645,6 +667,9 @@ }); }, fail: () => { + uni.pro.navigateTo('/pagesOrder/order_detail/index', { + orderId: this.listinfoid + }) uni.hideLoading() } }); diff --git a/pagesOrder/order_detail/index.vue b/pagesOrder/order_detail/index.vue index 2fe8365..777e127 100644 --- a/pagesOrder/order_detail/index.vue +++ b/pagesOrder/order_detail/index.vue @@ -132,7 +132,7 @@ * 去支付 */ goToPay(){ - if ( this.radiovalue == 2 || this.radiovalue == 3 && this.listinfo.payAmount <= 0 ) { + if ( (this.radiovalue == 2 || this.radiovalue == 3) && this.listinfo.payAmount <= 0 ) { uni.showToast({ title: "支付金额必须大于0", icon: 'none'