From 618daced35a1b97023550ee441f1908d0403dfe4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=AD=8F=E5=95=BE?= <1144797966@qq.com>
Date: Wed, 15 May 2024 16:55:38 +0800
Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E4=B8=8B=E5=8D=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
framework/0-conf.js | 9 +-
framework/11-api.js | 11 +-
pages/index/coupons/index.vue | 48 ++++++++-
pages/order_detail/order_detail.vue | 156 ++++++++++++++++++++++------
pages/order_food/order_food.vue | 39 +++++--
pages/user/coupon.vue | 2 +-
6 files changed, 211 insertions(+), 54 deletions(-)
diff --git a/framework/0-conf.js b/framework/0-conf.js
index 22a4322..485d7f3 100644
--- a/framework/0-conf.js
+++ b/framework/0-conf.js
@@ -5,16 +5,17 @@ const proxyApi = "/api"
// #ifdef MP-WEIXIN || APP
// const proxyApi = 'http://192.168.2.133:9889/cashierService' // 王伟
// const proxyApi = 'http://101.37.12.135:9889/cashierService' // 帆哥
-const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService'
+const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试
+const proxyApiwws = 'ws://wxcashiertest.sxczgkj.cn/cashierService' // 测试
// #endif
// #ifdef H5
const baseUrl = debug ? proxyApi : "https://wxcashiertest.sxczgkj.cn/cashierService"
-const baseUrlwws = 'wss://cashier.sxczgkj.cn/cashierService' // 线上
+const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'
// #endif
// #ifdef APP || MP-WEIXIN
-const baseUrl = debug ? proxyApi : 'https://wxcashiertest.sxczgkj.cn/cashierService'
-const baseUrlwws = 'wss://wxcashiertest.sxczgkj.cn/cashierService' // 线上
+const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService'// 线上
+const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/cashierService' // 线上
// #endif
// import VConsole from "./vConsole.js"
diff --git a/framework/11-api.js b/framework/11-api.js
index e7b6c31..8d9dbb0 100644
--- a/framework/11-api.js
+++ b/framework/11-api.js
@@ -92,10 +92,13 @@ async function request(options) {
title: res.message || res.msg,
icon: "none",
success: () => {
- uni.cache.clear();
- uni.redirectTo({
- url: '/pages/login/login'
- });
+ setTimeout(res => {
+ uni.cache.clear();
+ uni.redirectTo({
+ url: '/pages/login/login'
+ });
+ }, 1000)
+
}
})
} else if (res.code == 482) {
diff --git a/pages/index/coupons/index.vue b/pages/index/coupons/index.vue
index 2e23a03..fa30219 100644
--- a/pages/index/coupons/index.vue
+++ b/pages/index/coupons/index.vue
@@ -6,7 +6,8 @@
可使用红包
{{totalnumber}}张
-
+
+ :key="index1" @click="clickicon(item1)">
@@ -81,7 +82,7 @@
-
+
@@ -113,16 +114,53 @@
size: 10, //页容量
status: 'loadmore'
},
-
+ orderfood: '', //等于0扫码点餐下单
+ amount: '' //下单金额传来的值
};
},
+ onLoad(e) {
+ try {
+ this.orderfood = e.orderfood //等于0扫码点餐下单
+ this.amount = e.amount
+ } catch (e) {
+ //TODO handle the exception
+ }
+ },
onShow() {
this.ordermineCouponsthis()
this.ordergetYhqParass()
},
methods: {
- clickicon(e){
+ clickicon(e) { //团购优惠卷
this.item1id = e.id
+ e.clickiconone = 1
+ let data = e
+ if (this.orderfood == 0) { //等于0扫码点餐下单
+ if (this.amount > e.couponsAmount) {
+ uni.$emit('emitclickorderfood', e)
+ uni.navigateBack()
+ } else {
+ uni.showToast({
+ title: '此优惠卷不能用于目前订单',
+ icon: "none",
+ })
+ }
+ }
+ },
+ clickiconone(e) { //自己优惠劵处理
+ e.clickiconone = 0
+ let data = e
+ if (this.orderfood == 0) { //等于0扫码点餐下单
+ if (this.amount > e.couponsAmount) {
+ uni.$emit('emitclickorderfood', data)
+ uni.navigateBack()
+ } else {
+ uni.showToast({
+ title: '此优惠卷不能用于目前订单',
+ icon: "none",
+ })
+ }
+ }
},
async ordergetYhqParass() { //类型列表
let res = await this.api.ordergetYhqPara()
diff --git a/pages/order_detail/order_detail.vue b/pages/order_detail/order_detail.vue
index 4d62408..50885c1 100644
--- a/pages/order_detail/order_detail.vue
+++ b/pages/order_detail/order_detail.vue
@@ -1,6 +1,6 @@
-
+
{{listinfo.tableName || '空'}}
@@ -50,15 +50,15 @@
-
+
- {{item.productName}}
- x{{item.num}}
+ {{item.name}}
+ x{{item.number}}
¥
- {{item.price}}
+ {{item.salePrice}}
@@ -66,10 +66,18 @@
合计:
¥
- {{listinfo.amount}}
+ {{listinfo.amounts}}
+
+
+
+ 优惠卷
+
+ {{emitorderfoodform.couponsPrice}}
+
+
@@ -112,8 +120,11 @@
¥{{listinfo.amount}}
+
+ 以优惠¥{{emitorderfoodform.couponsPrice}}
+
-
+
立即付款
@@ -129,34 +140,89 @@
height: '',
pay_type: 1,
info: {},
- listinfo: {}
+ listinfo: {
+ detailList: [],
+ amount: '',
+ amounts: ''
+ },
+ emitorderfoodform: {
+ clickiconone: ''
+ }
};
},
- // onUnload() {
- // uni.$off('createOrdermessage')
- // },
+ onUnload() {
+ uni.$off('createOrdermessage')
+ },
onLoad(e) {
- console.log(e,140)
+ console.log(e, 140)
let res = JSON.parse(e.tableId)
- console.log(res)
- this.listinfo = res
- // uni.$on('createOrdermessage', res => {
- // console.log(1111111)
- // console.log(res)
- // this.listinfo = res
- // })
- // uni.$on('createOrdermessage', this.getMessagess)
+ // .toFixed(2)
+ this.listinfo.detailList = res
+ this.listinfo.amount = e.amount
+ this.listinfo.amounts = e.amount
+ this.handlemessage()
+ // uni.$on('createOrdermessage', this.creategetMessage)
},
onShow() {
- // uni.$on('createOrdermessage', res => {
- // console.log(1111111)
- // console.log(res)
- // this.listinfo = res
- // })
+
+ },
+ created() {
+ uni.$on('emitclickorderfood', (num) => {
+ console.log(num)
+ // 总金额 couponsAmount 优惠卷购买金额 couponsPrice优惠金额
+ if (num.clickiconone == 1) {
+ this.listinfo.amount = (Number(this.listinfo.amounts) - Number(num.couponsPrice)).toFixed(2)
+ } else {
+ this.listinfo.amount = (Number(this.listinfo.amounts) + Number(num.couponsAmount) - Number(num
+ .couponsPrice)).toFixed(2)
+ }
+ this.emitorderfoodform = num
+ // this.num += num
+ })
},
methods: {
+ creategetMessage(msg) {
+ if (msg.status != 'success') {
+ uni.showToast({
+ title: msg.msg,
+ icon: "none",
+ })
+ this.socketTicket.Close()
+ uni.$off('createOrdermessage')
+ return false;
+ } else {
+ switch (msg.type) {
+ case 'createOrder': //去结算
+ this.showpopupclickdd()
+ // let item = JSON.stringify(msg.data)
+ // uni.redirectTo({
+ // url: '/pages/order_detail/order_detail?tableId=' + item
+ // });
+ break;
+ }
+ }
+ },
+ handlemessage() {
+ this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接
+ this.socketTicket = new webSocketUtils(
+ `${uni.conf.baseUrlwws}/websocket/table/${this.tableCode}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
+ 5000)
+ },
+ // 数据处理
+ socketSendMsg(data) {
+ if (this.socketTicket) {
+ this.socketTicket.send(data);
+ }
+ },
+ orderfoodindex() {
+ uni.pro.navigateTo('index/coupons/index', {
+ orderfood: 0,
+ amount: this.listinfo.amounts
+
+ })
+ },
async ordercreatOrder() {
let res = await this.api.ordercreatOrder({
tableId: this.info.tableId,
@@ -181,15 +247,25 @@
orderId: this.listinfo.id
})
},
- async showpopupclick() {
- // const data = { //定义socket数据传参
- // "skuId": res.data.id,
- // "num": a == '-' ? Number(b) - 1 : Number(b) + 1, //数量
- // "type": "addcart", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
- // "productId": item.id, //商品id
- // "shopId": uni.cache.get('shopUser').shopId,
- // "userId": uni.cache.get('userInfo').id
- // };
+ // 去结算
+ showpopupclick() {
+
+ let data = { //定义socket数据传参
+ "skuId": '',
+ "num": '', //数量
+ "type": "createOrder", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
+ "couponsId": this.emitorderfoodform.id ? this.emitorderfoodform.id : '', //优惠券ID,
+ "isYhq": this.emitorderfoodform.id ? 1 : 0, // 是否使用优惠券( 1: 使用, 0: 不使用),
+ "isBuyYhq": this.emitorderfoodform.clickiconone == 1 ? 1 : 0, // 是否购买优惠券( 1: 购买, 0: 不够买)
+ "productId": '', //商品id
+ "shopId": uni.cache.get('shopUser'),
+ "userId": uni.cache.get('userInfo').id
+ }
+ console.log(data)
+ uni.$u.debounce(this.socketSendMsg(data), 500)
+ },
+ async showpopupclickdd() {
+
let res = await this.api.payorderPay({
orderId: this.listinfo.id,
}) //判断是否支付成功
@@ -394,6 +470,10 @@
.sixcontentone {
padding-bottom: 28rpx;
border-bottom: 1px solid #F7F7F7;
+ font-size: 28rpx;
+ font-family: Source Han Sans CN-Medium, Source Han Sans CN;
+ font-weight: 500;
+ color: #333333;
.sixcontent_one {
font-size: 28rpx;
@@ -436,6 +516,7 @@
width: 100%;
padding: 24rpx 28rpx;
background: #FFFFFF;
+ flex-wrap: nowrap;
.fixedview_one {
.fixedview_oneone {
@@ -456,6 +537,13 @@
font-size: 28rpx;
}
}
+
+ .fixedview_onethere {
+ font-family: Source Han Sans CN, Source Han Sans CN;
+ font-weight: 400;
+ font-size: 24rpx;
+ color: #999999;
+ }
}
.fixedview_tow {
diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue
index f0e5a14..8d0fb4a 100644
--- a/pages/order_food/order_food.vue
+++ b/pages/order_food/order_food.vue
@@ -98,24 +98,29 @@
-
+
¥
{{cartLists.amount}}
- 去结算
+ 提交订单
-