扫码下单

This commit is contained in:
魏啾
2024-05-15 16:55:38 +08:00
parent da87e38df0
commit 618daced35
6 changed files with 211 additions and 54 deletions

View File

@@ -1,6 +1,6 @@
<template>
<view class="container">
<view class="card">
<view class="card" v-if="listinfo.tableName">
<view class="head">
<text class="title">
<text>{{listinfo.tableName || '空'}}</text>
@@ -50,15 +50,15 @@
<view class="shop-info">
<view class="item" v-for="(item,index) in listinfo.detailList" :key="index">
<view class="cover">
<c-image width="120" height="120" radius="16" :src='item.productImg'></c-image>
<c-image width="120" height="120" radius="16" :src='item.coverImg'></c-image>
</view>
<view class="info">
<text>{{item.productName}}</text>
<text class="n">x{{item.num}}</text>
<text>{{item.name}}</text>
<text class="n">x{{item.number}}</text>
</view>
<view class="price">
<text class="i"></text>
<text class="num">{{item.price}}</text>
<text class="num">{{item.salePrice}}</text>
</view>
</view>
</view>
@@ -66,10 +66,18 @@
<view class="price">
<text>合计</text>
<text class="i"></text>
<text class="num">{{listinfo.amount}}</text>
<text class="num">{{listinfo.amounts}}</text>
</view>
</view>
</view>
<view class="sixcontent">
<view class="sixcontentone flex-between" style="padding: 0 0;" @click="orderfoodindex">
<view class="sixcontent_one" style="padding: 0 0;">
优惠卷
</view>
<text style="color: red;">{{emitorderfoodform.couponsPrice}}</text>
</view>
</view>
<view class="sixcontent" v-if="listinfo.status == 'unpaid'">
<view class="sixcontentone flex-between">
<view class="sixcontent_one">
@@ -112,8 +120,11 @@
<view class="fixedview_onetow">
<text>¥</text>{{listinfo.amount}}
</view>
<view class="fixedview_onethere" v-if="emitorderfoodform.couponsPrice">
以优惠¥{{emitorderfoodform.couponsPrice}}
</view>
</view>
<view class="fixedview_tow" @tap="$u.debounce(showpopupclick,1000)">
<view class="fixedview_tow" @click="showpopupclick">
立即付款
</view>
</view>
@@ -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 {