扫码下单

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

@@ -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"

View File

@@ -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) {

View File

@@ -6,7 +6,8 @@
<view>可使用红包</view>
<text>{{totalnumber}}</text>
</view>
<view class="containertopboxitem flex-start" v-for="(item,index) in list" :key="index">
<view class="containertopboxitem flex-start" v-for="(item,index) in list" :key="index"
@click="clickiconone(item)">
<view class="containertopboxitemleft flex-colum"
:class="item.status == 0?'':'containertopboxitemlefts'">
<view class="containertopboxitemleft_one"
@@ -57,7 +58,7 @@
{{item.name}}
</view>
<view class="containerbottombox_bottombox flex-start" v-for="(item1,index1) in item.listdata"
:key="index1">
:key="index1" @click="clickicon(item1)">
<view class="containerbottombox_bottomthere">
<view class="containerbottombox_bottomthere_topitem">
<view class="onecontainerbottombox_bottomthere_topitem">
@@ -81,7 +82,7 @@
</view>
</view>
<view class="therecontainerbottombox_bottomthere_topitem flex-around" @click="clickicon(item1)">
<view class="therecontainerbottombox_bottomthere_topitem flex-around">
<u-icon v-if="item1.id == item1id" name="checkmark-circle" color="#F1CB66"
size="45"></u-icon>
<text v-else class="theretext"></text>
@@ -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()

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 {

View File

@@ -98,24 +98,29 @@
<view class="cart-wrap">
<view class="cart-content">
<view class="left">
<image class="icon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/icon_cart.png" mode="aspectFit" @click="showCart = !showCart">
<image class="icon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/icon_cart.png"
mode="aspectFit" @click="showCart = !showCart">
</image>
<text class="i"></text>
<text class="num">{{cartLists.amount}}</text>
</view>
<view class="btn" @tap="$u.debounce(orderdetail, 500)">
<text class="t">去结算</text>
<text class="t">提交订单</text>
</view>
</view>
</view>
<u-popup :show="showCart" :round="20" :zIndex="98" :overlayStyle="{ zIndex: 98 }" @close="showCart = false">
<view class="cart-list-wrap">
<view class="cart-header" @click="cartclear">
<view class="clear">
<view class="cart-header">
<!-- <view class="clear" @click="orderfoodindex">
<text class="t" style="color: #ffd100;">可用优惠劵</text>
</view> -->
<view class="clear" @click="cartclear">
<u-icon name="trash" color="#999"></u-icon>
<text class="t">清空购物车</text>
</view>
</view>
<scroll-view scroll-y class="scroll-view">
<view class="list-wrap">
<view class="shop-item" v-for="(item,index) in cartLists.data" :key="item.id">
@@ -349,6 +354,16 @@
url: '/pages/order_detail/order_detail?tableId=' + item
});
break;
case 'queryCart': //待提交
// let queryCart = JSON.stringify(msg.data)
// uni.pro.navigateTo('order_detail/order_detail', {
// tableId: JSON.stringify(msg.data)
// })
uni.redirectTo({
url: '/pages/order_detail/order_detail?tableId=' + JSON.stringify(msg.data) +
'&amount=' + msg.amount
});
break;
case 'addcart':
this.cartLists = msg
if (msg.data.length != 0) {
@@ -554,17 +569,29 @@
}
},
orderdetail() {
// uni.pro.navigateTo('order_detail/order_detail', {
// tableId: item
// })
// if (this.showCart) {
let data = { //定义socket数据传参
"skuId": '',
"num": '', //数量
"type": "createOrder", //“addcart:添加购物车create0rder:生成订单clearCart:庆康购物车”,
"type": "queryCart", //“addcart:添加购物车create0rder:生成订单clearCart:庆康购物车”,
"productId": '', //商品id
"shopId": uni.cache.get('shopUser'),
"userId": uni.cache.get('userInfo').id
}
uni.$u.debounce(this.socketSendMsg(data), 500)
// } else {
// this.showCart = true
// }
},
orderfoodindex() {
uni.pro.navigateTo('index/coupons/index', {
orderfood: 0
})
},
async cartclear() {
try {
const data = { //定义socket数据传参
@@ -984,7 +1011,7 @@
.cart-list-wrap {
.cart-header {
display: flex;
justify-content: flex-end;
justify-content: space-between;
background-color: #f4eddf;
padding: 20upx $paddingSize;
border-radius: 20upx 20upx 0 0;

View File

@@ -113,7 +113,7 @@
})
if (res.data.pages < this.form.page) {
this.form.status = 'nomore'
if (res.data.pageNum == 1) {
if (this.form.page == 1 && res.data.list == 0) {
this.is_end = true
}
return false;