From def9db0884fab1504a3006a3a37b58f36767e933 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=AD=8F=E5=95=BE?= <1144797966@qq.com>
Date: Fri, 31 May 2024 17:26:02 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=B8=8B=E5=8D=95=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/js/websocket.js | 12 +-
pages/member/index.vue | 11 +-
pages/order_detail/index.vue | 811 ++++++++++++++++++++++++++++
pages/order_detail/order_detail.vue | 122 +----
pages/order_food/order_food.vue | 61 ++-
5 files changed, 870 insertions(+), 147 deletions(-)
create mode 100644 pages/order_detail/index.vue
diff --git a/common/js/websocket.js b/common/js/websocket.js
index e96b30b..894adbb 100644
--- a/common/js/websocket.js
+++ b/common/js/websocket.js
@@ -124,12 +124,12 @@ class webSocketUtils {
//开启心跳检测
start(data) {
console.log('开启心跳检测',data)
- // this.heartbeatInterval = setInterval(() => {
- // this.send({
- // data: '心跳检测',
- // type: 'jc',
- // });
- // }, this.timeout);
+ this.heartbeatInterval = setInterval(() => {
+ // this.send({
+ // data: '心跳检测',
+ // type: 'jc',
+ // });
+ }, this.timeout);
}
//重新连接
reconnect() {
diff --git a/pages/member/index.vue b/pages/member/index.vue
index c8c3e09..6089f52 100644
--- a/pages/member/index.vue
+++ b/pages/member/index.vue
@@ -95,17 +95,8 @@
})
setTimeout(res => {
uni.navigateBack()
- }, 1000)
+ }, 500)
},
- fail: (err) => {
- uni.showToast({
- icon: 'none',
- title: '支付失败'
- })
- setTimeout(res => {
- uni.hideLoading()
- }, 1000)
- }
});
// #endif
}
diff --git a/pages/order_detail/index.vue b/pages/order_detail/index.vue
new file mode 100644
index 0000000..9e8e885
--- /dev/null
+++ b/pages/order_detail/index.vue
@@ -0,0 +1,811 @@
+
+
+
+
+
+ {{listinfo.tableName || '空'}}
+
+
+ 待支付
+
+
+ 待发货
+
+
+ 订单完成
+
+
+ 已发
+
+
+ 申请退单
+
+
+ 退单
+
+
+ 取消订单
+
+
+ 合台
+
+
+
+ 快递
+ 外卖
+ 自提
+ 堂食
+
+
+ 取餐号
+ {{listinfo.tableName || '空'}}
+
+
+
+
+
+ 点单详情
+
+
+
+
+
+
+
+
+ {{item.name}}
+ x{{item.number}}
+
+
+ ¥
+ {{item.salePrice}}
+
+
+
+
+
+ 合计:
+ ¥
+ {{listinfo.amounts}}
+
+
+
+
+
+
+
+
+ 支付方式
+
+
+
+
+
+
+
+
+ 微信支付
+
+
+
+
+
+
+
+
+
+
+ 会员卡支付
+
+
+
+
+ 会员卡余额{{ amountVIP.amount}} 去充值
+
+
+
+
+
+
+
+
+
+
+
+ 实付金额:
+
+
+ ¥{{listinfo.amount}}
+
+
+ 以优惠¥{{emitorderfoodform.couponsPrice}}
+
+
+
+ 立即付款
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/order_detail/order_detail.vue b/pages/order_detail/order_detail.vue
index 9e8e885..74d7ec4 100644
--- a/pages/order_detail/order_detail.vue
+++ b/pages/order_detail/order_detail.vue
@@ -50,15 +50,15 @@
-
+
- {{item.name}}
- x{{item.number}}
+ {{item.productName}}
+ x{{item.num}}
¥
- {{item.salePrice}}
+ {{item.price}}
@@ -66,7 +66,7 @@
合计:
¥
- {{listinfo.amounts}}
+ {{listinfo.amount}}
@@ -203,12 +203,10 @@
},
amountVIP: null,
radiovalue1: '1',
- vipId: null,
orderInfo: '',
// 可用优惠券数据
couponAmount: 0,
// 输入支付密码 123
- passwordArr: [],
ispws: false,
};
},
@@ -216,43 +214,17 @@
onUnload() {
uni.$off('getMessage')
this.ispws = false
-
},
onLoad(e) {
- // console.log(e, 140)
- let res = JSON.parse(e.tableId)
- this.listinfo.detailList = res
- this.listinfo.amount = e.amount // 算完了的价格
- this.listinfo.amounts = e.amount //本来的价格
- this.handlemessage()
- uni.$on('message', this.getMessage)
-
+ this.listinfo = JSON.parse(e.tablelist)
// 获取余额
this.getAount()
- // 获取可用优惠券数量
- this.getcoupon()
- this.vipId = uni.cache.get('userInfo').id
-
},
onShow() {
this.getAount()
},
- created() {
- uni.$on('emitclickorderfood', (num) => {
- // 总金额 couponsAmount 优惠卷购买金额 couponsPrice优惠金额 等于1是团购/不等于1
- if (num.clickiconone == 1) {
- this.listinfo.amount = (Number(this.listinfo.amounts) + Number(num.couponsPrice) - Number(num
- .couponsAmount)).toFixed(2)
- } else {
- this.listinfo.amount = (Number(this.listinfo.amounts) - Number(num.couponsAmount)).toFixed(2)
- }
- this.emitorderfoodform = num
- // this.num += num
- })
- },
methods: {
groupChange(n) {
- // console.log('groupChange', n);
this.radiovalue1 = n
uni.cache.set('radiovalue1', n)
},
@@ -313,7 +285,7 @@
orderfoodindex() {
uni.pro.navigateTo('index/coupons/index', {
orderfood: 0,
- orderId: this.listinfoid,
+ orderId: this.listinfo.id,
amount: this.listinfo.amounts
})
},
@@ -330,10 +302,10 @@
},
async paymodfiyOrderInfo() {
let res = await this.api.paymodfiyOrderInfo({
- orderId: this.listinfoid
+ orderId: this.listinfo.id,
})
},
- creactorder(){
+ creactorder() {
let data = { //定义socket数据传参
"skuId": '',
"num": '', //数量
@@ -347,7 +319,7 @@
// tableId:uni.cache.get('tableCode')
}
let res = 0
- if(res.code==0){
+ if (res.code == 0) {
this.listinfoid = msg.data.id //下单需要的id
this.orderInfo = msg.data
if (this.radiovalue1 == 1) {
@@ -379,10 +351,8 @@
},
showpopupclickdd() {
- console.log(this.radiovalue1, 'radiovalue1的值')
if (this.radiovalue1 == 1) {
- // this.showpopupclick() //生成订单
- this.creactorder()
+ this.showpopupclickdds() //微信支付
} else {
// 判断是否有绑定支付密码
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
@@ -391,26 +361,17 @@
shopId_id: uni.cache.get('shopUser')
})
} else {
- if (this.amountVIP.amount > this.listinfo.amount) {
- this.ispws = true
- // this.showpopupclick() //生成订单
- this.creactorder()
- this.$nextTick(() => {
- this.$refs.payPwd.onPayUp();
- })
- } else {
- uni.showToast({
- title: "余额不足"
- })
- }
-
+ this.ispws = true
+ this.$nextTick(() => {
+ this.$refs.payPwd.onPayUp();
+ })
}
}
},
// 微信支付
async showpopupclickdds() {
let res = await this.api.payorderPay({
- orderId: this.listinfoid
+ orderId: this.listinfo.id
}) //判断是否支付成功
if (res.code == 0) {
// uni.showLoading({
@@ -434,43 +395,12 @@
uni.cache.set('shopUser', '') //删除shopUser
this.paymodfiyOrderInfo()
setTimeout(res => {
- // uni.redirectTo({
- // url: '/pages/order/successful?orderId=' + this
- // .listinfoid + '&orderInfo=' + JSON.stringify(
- // this.orderInfo) + '&radiovalue1=' + this
- // .radiovalue1
- // });
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this
- .listinfoid
- });
- }, 500)
- // uni.redirectTo({
- // url: "/pages/mall/order/ordersuccess?id=" + datareslane.data
- // .order_id,
- // });
- },
- fail: (err) => {
- uni.showToast({
- icon: 'none',
- title: '支付失败'
- })
- setTimeout(res => {
- // uni.redirectTo({
- // url: '/pages/order/successful?orderId=' + this
- // .listinfoid + '&orderInfo=' + JSON.stringify(
- // this.orderInfo) + '&radiovalue1=' + this
- // .radiovalue1
- // });
- uni.redirectTo({
- url: '/pages/order/order_detail?orderId=' + this
- .listinfoid
+ .listinfo.id,
});
}, 500)
},
- complete: (data) => {
- console.log(data, '成功与否')
- }
});
// #endif
}
@@ -479,7 +409,7 @@
async accountPayevent(pwd) {
this.ispws = false
let res = await this.api.accountPay({
- orderId: this.listinfoid,
+ orderId: this.listinfo.id,
memberId: this.amountVIP.id,
pwd: pwd
})
@@ -489,19 +419,12 @@
title: '支付成功',
success: () => {
setTimeout(res => {
- // uni.redirectTo({
- // url: '/pages/order/successful?orderId=' + this
- // .listinfoid + '&orderInfo=' + JSON.stringify(
- // this.orderInfo) + '&radiovalue1=' + this
- // .radiovalue1
- // });
+ uni.cache.set('shopUser', '') //删除shopUser
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this
- .listinfoid
+ .listinfo.id,
});
}, 500)
-
-
}
})
} else if (res.data == 1) {
@@ -526,11 +449,6 @@
var that = this;
that.height = (ele.height) + "px";
that = null;
- // uni.getSystemInfo({
- // success(res) {
-
- // }
- // })
}).exec();
//#endif
//#ifdef MP-ALIPAY
diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue
index 06efaa7..8eb7c7f 100644
--- a/pages/order_food/order_food.vue
+++ b/pages/order_food/order_food.vue
@@ -296,6 +296,14 @@
uni.$off('message')
},
onShow() {
+ // uni.onNetworkStatusChange((res) => { //监听网络状态变化
+ // if (!res.isConnected) {
+ // // 检查网络是否连接
+ // } else {
+ // console.log(res, 111);
+ // // ...这里写你的业务逻辑
+ // }
+ // });
setTimeout(() => {
if (uni.cache.get('token') && uni.cache.get('tableCode')) {
this.productqueryShopIdByTableCode() //获取shop User id
@@ -311,7 +319,7 @@
try {
if (res.data) {
let time = new Date
- console.log(time,'时间戳')
+ console.log(time, '时间戳')
uni.cache.set('shopUser', res.data)
this.handlemessage()
}
@@ -341,16 +349,15 @@
this.productqueryProduct() //list 数据
break;
case 'clearCart':
- console.log('clearCart')
this.specifications.duoguge = ''
this.skuidname = []
this.showCart = false
setTimeout(() => {
uni.showToast({
- title: '清空购物车成功',
+ title: msg.msg,
icon: "none",
})
- }, 1000)
+ }, 500)
this.cartLists = msg
this.productqueryProduct() //list 数据
break;
@@ -362,12 +369,12 @@
this.cartLists = msg
this.productqueryProduct() //list 数据
break;
- // case 'createOrder': //去结算
- // let item = JSON.stringify(msg.data)
- // uni.redirectTo({
- // url: '/pages/order_detail/order_detail?tableId=' + item
- // });
- // break;
+ case 'createOrder': //去结算
+ let item = JSON.stringify(msg.data)
+ uni.redirectTo({
+ url: '/pages/order_detail/order_detail?tablelist=' + item
+ });
+ break;
case 'queryCart': //待提交
// let queryCart = JSON.stringify(msg.data)
// uni.pro.navigateTo('order_detail/order_detail', {
@@ -400,12 +407,10 @@
}
},
handlemessage() {
- console.log(this.socketTicket,'是否存在socketTicket1')
// this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接
this.socketTicket = new webSocketUtils(
`${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
5000)
- console.log(this.socketTicket,'是否存在socketTicket3')
},
// 数据处理
socketSendMsg(data) {
@@ -574,31 +579,29 @@
}
uni.$u.debounce(this.socketSendMsg(data), 500)
}
- } catch (e) {
- uni.showToast({
- title: '获取失败',
- icon: "none",
- })
- }
+ } catch (e) {}
},
orderdetail() {
- // uni.pro.navigateTo('order_detail/order_detail', {
- // tableId: item
- // })
- // if (this.showCart) {
- let data = { //定义socket数据传参
+ // let data = { //缓存的生成订单 //去结算
+ // "skuId": '',
+ // "num": '', //数量
+ // "type": "queryCart", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
+ // "productId": '', //商品id
+ // "shopId": uni.cache.get('shopUser'),
+ // "userId": uni.cache.get('userInfo').id
+ // }
+ let data = { // 直接生成订单
"skuId": '',
"num": '', //数量
- "type": "queryCart", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
+ "type": "createOrder", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
+ "couponsId": '', //优惠券ID,
+ "isYhq": 0, // 是否使用优惠券( 1: 使用, 0: 不使用),
+ "isBuyYhq": 0, // 是否购买优惠券( 1: 购买, 0: 不够买)
"productId": '', //商品id
"shopId": uni.cache.get('shopUser'),
- "userId": uni.cache.get('userInfo').id
+ "userId": uni.cache.get('userInfo').id,
}
uni.$u.debounce(this.socketSendMsg(data), 500)
- // } else {
- // this.showCart = true
- // }
-
},
orderfoodindex() {
uni.pro.navigateTo('index/coupons/index', {