更改首页
This commit is contained in:
1211
pages/order_food/order_food - 副本.vue
Normal file
1211
pages/order_food/order_food - 副本.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,11 +12,11 @@
|
||||
<view class="left-btn">
|
||||
<view class="btn" :style="{ width: `${menuInfo.height}px`, height: `${menuInfo.height}px` }"
|
||||
@click="navClickHandle(1)">
|
||||
<u-icon name="arrow-left" :color="isFixed ? '#333' : '#fff'" size="38"></u-icon>
|
||||
<u-icon name="arrow-left" :color="isFixed ? '#333' : '#fff'" size="28"></u-icon>
|
||||
</view>
|
||||
<view class="btn" :style="{ width: `${menuInfo.height}px`, height: `${menuInfo.height}px` }"
|
||||
@click="navClickHandle(2)">
|
||||
<u-icon name="kefu-ermai" :color="isFixed ? '#333' : '#fff'" size="38"></u-icon>
|
||||
<u-icon name="kefu-ermai" :color="isFixed ? '#333' : '#fff'" size="28"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -89,12 +89,12 @@
|
||||
<view class="operation-wrap" v-else>
|
||||
<view class="btn" v-if="item1.cartNumber != '0'"
|
||||
@click.stop="cartadd(item1,index,index1,'-',item1.productSkuResult == null ? '单规格':'')">
|
||||
<u-icon :name="require('@/static/icon_sub.png')" size="34"></u-icon>
|
||||
<u-icon :name="require('@/static/icon_sub.png')" size="36"></u-icon>
|
||||
</view>
|
||||
<text class="num">{{ item1.cartNumber }}</text>
|
||||
<view class="btn"
|
||||
@click.stop="cartadd(item1,index,index1,'+',item1.productSkuResult == null ? '单规格':'')">
|
||||
<u-icon :name="require('@/static/icon_add.png')" size="34"></u-icon>
|
||||
<u-icon :name="require('@/static/icon_add.png')" size="36"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -171,7 +171,7 @@
|
||||
<view class="col">
|
||||
<text class="t">{{ shopList.storeInfo.businessTime }}</text>
|
||||
</view>
|
||||
<view class="col">
|
||||
<view class="col" @click="makePhoneCall(shopList.storeInfo.phone)">
|
||||
<text class="t">{{ shopList.storeInfo.phone }}</text>
|
||||
</view>
|
||||
<view class="col">
|
||||
@@ -230,19 +230,23 @@
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<!-- <vastwu-barrage width="750rpx" height="1300rpx" ref="vBarrage"></vastwu-barrage> -->
|
||||
<l-barrage ref="lBarrage" @end="onEnd" :minTop='8' :maxTop='20' :avatar='barrageavatar'></l-barrage>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash';
|
||||
import navbar from '../../uni_modules/uview-ui/libs/config/props/navbar';
|
||||
import webSocketUtils from '@/common/js/websocket.js'
|
||||
// import vastwuBarrage from '@/components/vastwu-barrage/vastwu-barrage.vue'
|
||||
import webSocketUtils from '@/common/js/websocket.js';
|
||||
import orderdetail from '@/pages/order_detail/index';
|
||||
import lBarrage from '@/components/l-barrage/l-barrage.vue'
|
||||
export default {
|
||||
// components:{vastwuBarrage},
|
||||
components: {
|
||||
orderdetail,
|
||||
lBarrage
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
userInfo: uni.cache.get('userInfo'), //个人信息
|
||||
// #ifndef MP-WEIXIN
|
||||
menuInfo: uni.getSystemInfo(),
|
||||
// #endif
|
||||
@@ -262,12 +266,17 @@
|
||||
tableCode: '', //code,
|
||||
specifications: {},
|
||||
skuidname: [],
|
||||
cartLists: {},
|
||||
cartLists: {}, //购物车
|
||||
orderdetailcartLists: {}, //提交订单
|
||||
socketTicket: null,
|
||||
amountcartNumber: 0,
|
||||
skuidsearch: '', //
|
||||
salePrice: '', //钱数
|
||||
fixedtrue: true
|
||||
fixedtrue: true,
|
||||
datasocket: {}, //储存传参数据
|
||||
radiovalue: '1', //选择支付方式
|
||||
amountVIP: null, //余额
|
||||
barrageavatar: '' //弹幕头像
|
||||
};
|
||||
},
|
||||
onPageScroll(e) {
|
||||
@@ -292,22 +301,27 @@
|
||||
uni.cache.set('tableCode', this.tableCode)
|
||||
}
|
||||
uni.cache.set('types', 'types');
|
||||
uni.$on('message', this.getMessage)
|
||||
this.$nextTick(() => {
|
||||
this.countTitleTopNum(); //导航栏
|
||||
});
|
||||
// this.$refs.vBarrage.init([123])
|
||||
},
|
||||
onUnload() {
|
||||
this.socketTicket.Close()
|
||||
uni.$off('message')
|
||||
},
|
||||
onHide() {
|
||||
this.socketTicket.Close()
|
||||
uni.$off('message')
|
||||
this.fixedtrue = true
|
||||
},
|
||||
onShow() {
|
||||
setTimeout(() => {
|
||||
this.productqueryShopIdByTableCode() //获取shop User id
|
||||
}, 500)
|
||||
uni.$on('message', this.getMessage)
|
||||
this.productqueryShopIdByTableCode() //获取shop User id
|
||||
},
|
||||
methods: {
|
||||
onEnd() { //回调弹幕
|
||||
console.log('一波结束')
|
||||
},
|
||||
// 单独获取他的shopUserid
|
||||
async productqueryShopIdByTableCode() {
|
||||
let res = await this.api.productqueryShopIdByTableCode({
|
||||
@@ -315,7 +329,7 @@
|
||||
})
|
||||
if (res.code == 0) {
|
||||
uni.cache.set('shopUser', res.data)
|
||||
this.handlemessage()
|
||||
this.handlemessage() //监听websocket返回
|
||||
this.productqueryProduct() //list 数据
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
@@ -324,101 +338,87 @@
|
||||
}
|
||||
},
|
||||
getMessage(msg) { //wss 回显数据
|
||||
// console.log(this.shopList.productInfo)
|
||||
// console.log(msg.data)
|
||||
// const sumValuesByKey = (arr, key) => {
|
||||
// return arr.reduce((accumulator, current) => {
|
||||
// const existing = accumulator.find(item => item[key] === current[key]);
|
||||
// if (existing) {
|
||||
// existing.number += current.number;
|
||||
// } else {
|
||||
// accumulator.push({
|
||||
// ...current
|
||||
// });
|
||||
// }
|
||||
// return accumulator;
|
||||
// }, []);
|
||||
// };
|
||||
// const result = sumValuesByKey(msg.data, 'productId');
|
||||
// this.shopList.productInfo.forEach((item, index) => {
|
||||
// if (item.id == result.categoryId) {
|
||||
// item.products.forEach((item1,index1) => {
|
||||
|
||||
// })
|
||||
// }
|
||||
// });
|
||||
if (msg == 1) { // 网络在连接
|
||||
this.fixedtrue = true
|
||||
return false
|
||||
}
|
||||
this.fixedtrue = false
|
||||
if (msg.status != 'success') {
|
||||
uni.showToast({
|
||||
title: msg.msg,
|
||||
icon: "none",
|
||||
})
|
||||
if (msg.msg == '桌码不存在') { //卓码不存在直接退出
|
||||
this.socketTicket.Close()
|
||||
uni.$off('message')
|
||||
uni.navigateBack()
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
switch (msg.type) {
|
||||
case 'sku': // sku 数量 查询这个商品的价格和数量
|
||||
this.$set(this, 'amountcartNumber', msg.amount)
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
case 'clearCart':
|
||||
this.skuidname = []
|
||||
this.showCart = false
|
||||
setTimeout(() => {
|
||||
uni.showToast({
|
||||
title: msg.msg,
|
||||
icon: "none",
|
||||
})
|
||||
}, 500)
|
||||
this.cartLists = msg
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
case 'order':
|
||||
console.log('clearCart')
|
||||
this.skuidname = []
|
||||
this.showCart = false
|
||||
this.cartLists = msg
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
case 'createOrder': //去结算
|
||||
let item = JSON.stringify(msg.data)
|
||||
uni.redirectTo({
|
||||
url: '/pages/order_detail/order_detail?tablelist=' + item
|
||||
});
|
||||
break;
|
||||
case 'queryCart': //待提交
|
||||
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) {
|
||||
let nums = 0
|
||||
msg.data.forEach((item, index, arr) => { //初始化skuidname的数据 选择第一个
|
||||
if (item.skuId == this.skuidsearch) {
|
||||
nums = item.number
|
||||
if (msg.type == 'heartbeat') { //后台心跳 处理返回 不然控制台一直报错
|
||||
return false
|
||||
}
|
||||
try {
|
||||
if (msg.status != 'success') {
|
||||
uni.showToast({
|
||||
title: msg.msg,
|
||||
icon: "none",
|
||||
})
|
||||
if (msg.msg == '桌码不存在') { //卓码不存在直接退出
|
||||
this.socketTicket.Close()
|
||||
uni.$off('message')
|
||||
uni.navigateBack()
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
switch (msg.type) {
|
||||
case 'sku': // sku 数量 查询这个商品的价格和数量
|
||||
this.$set(this, 'amountcartNumber', msg.amount)
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
case 'clearCart':
|
||||
this.cartLists = msg
|
||||
this.productqueryProduct() //list 数据
|
||||
this.skuidname = []
|
||||
this.showCart = false
|
||||
setTimeout(() => {
|
||||
uni.showToast({
|
||||
title: msg.msg,
|
||||
icon: "none",
|
||||
})
|
||||
}, 500)
|
||||
break;
|
||||
case 'order':
|
||||
this.skuidname = []
|
||||
this.showCart = false
|
||||
this.cartLists = msg
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
case 'addCart': //初始化add
|
||||
this.cartLists = msg
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
case 'addcart':
|
||||
this.cartLists = msg
|
||||
console.log(msg, 1111)
|
||||
this.productqueryProduct() //list 数据
|
||||
try {
|
||||
if (msg.data.length != 0) {
|
||||
let nums = 0
|
||||
msg.data.forEach((item, index, arr) => { //初始化skuidname的数据 选择第一个
|
||||
if (item.skuId == this.skuidsearch) {
|
||||
nums = item.number
|
||||
}
|
||||
})
|
||||
this.$set(this, 'amountcartNumber', nums)
|
||||
} else {
|
||||
this.$set(this, 'amountcartNumber', 0)
|
||||
}
|
||||
})
|
||||
this.$set(this, 'amountcartNumber', nums)
|
||||
} else {
|
||||
this.$set(this, 'amountcartNumber', 0)
|
||||
}
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
default:
|
||||
this.cartLists = msg
|
||||
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
try {
|
||||
this.barrageavatar = msg.reqData.headImg
|
||||
/*插入一条弹幕*/
|
||||
this.$refs.lBarrage.add(
|
||||
`${msg.reqData.nickName?msg.reqData.nickName:'微信用户'}${msg.reqData.num==-1?'取消了':'添加了'}${msg.reqData.name}(${msg.reqData.num})`
|
||||
);
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
},
|
||||
handlemessage() {
|
||||
@@ -432,12 +432,8 @@
|
||||
},
|
||||
// 数据处理
|
||||
socketSendMsg(data) {
|
||||
console.log(data, 1111)
|
||||
if (this.socketTicket) {
|
||||
console.log(222)
|
||||
this.socketTicket.send(data);
|
||||
} else {
|
||||
console.log(333)
|
||||
}
|
||||
},
|
||||
getQueryString(url, name) { //解码
|
||||
@@ -449,16 +445,15 @@
|
||||
return null;
|
||||
},
|
||||
async cartadd(item, index, index1, a, b) { //列表添加 a传参加减号 b是判断单规格多规格
|
||||
console.log(item, index, index1, a, b)
|
||||
if (b == '单规格') { //没有规格为空
|
||||
this.skuidname = []
|
||||
}
|
||||
this.hodgepodge(item, 1, a) //获取skuid /1添加购物车
|
||||
},
|
||||
async cartListadd(item, index, a) {
|
||||
console.log(item, index, a)
|
||||
async cartListadd(item, index, a) { //购物车加减
|
||||
try {
|
||||
const data = { //定义socket数据传参
|
||||
"name": item.name,
|
||||
"skuId": item.skuId,
|
||||
"num": a == '-' ? -1 : 1, //skuId
|
||||
"type": "addcart", //“addcart:添加购物车,create0rder:生成订单,clearCart:清空购物车”,
|
||||
@@ -466,6 +461,7 @@
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
};
|
||||
this.datasocket = data
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
@@ -519,8 +515,6 @@
|
||||
this.hodgepodge(item, 2)
|
||||
},
|
||||
async hodgepodge(item, a, c) { //此接口去获取商品id !!!赋值库存 数量 价格等
|
||||
console.log(11111)
|
||||
|
||||
try {
|
||||
let res = await this.api.productqueryProductSku({
|
||||
shopId: uni.cache.get('shopUser'),
|
||||
@@ -538,6 +532,9 @@
|
||||
let data = null
|
||||
if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格)
|
||||
data = { //定义socket数据传参
|
||||
"nickName": this.userInfo.nickName,
|
||||
"barrageavatar": this.userInfo.headImg,
|
||||
'name': item.name,
|
||||
"skuId": res.data.id,
|
||||
"num": c == '-' ? -1 : 1, //数量
|
||||
"type": "addcart", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
|
||||
@@ -547,6 +544,7 @@
|
||||
};
|
||||
} else {
|
||||
data = { //查询这个商品的价格
|
||||
"name": item.name,
|
||||
"skuId": res.data.id,
|
||||
"num": '', //数量
|
||||
"type": "sku", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
|
||||
@@ -556,23 +554,35 @@
|
||||
};
|
||||
this.showShopsku = true //打开弹框
|
||||
}
|
||||
this.datasocket = data
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
}
|
||||
} catch (e) {}
|
||||
},
|
||||
orderdetail() { // 直接生成订单
|
||||
let data = {
|
||||
"skuId": '',
|
||||
"num": '', //数量
|
||||
"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,
|
||||
if (this.cartLists.data.length == 0) {
|
||||
uni.showToast({
|
||||
title: '请先添加商品',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
uni.navigateTo({
|
||||
url: '/pages/order_detail/indexs?tableId=' + JSON.stringify(this.cartLists)
|
||||
});
|
||||
// let data = {
|
||||
// "skuId": '',
|
||||
// "num": '', //数量
|
||||
// "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,
|
||||
// }
|
||||
// this.datasocket = data
|
||||
// uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
},
|
||||
async cartclear() { //清空购物车
|
||||
try {
|
||||
@@ -584,11 +594,11 @@
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
};
|
||||
this.datasocket = data
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
},
|
||||
// 导航栏点击
|
||||
navClickHandle(t) {
|
||||
@@ -608,6 +618,12 @@
|
||||
break;
|
||||
}
|
||||
},
|
||||
//打电话
|
||||
makePhoneCall(phone) {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: phone //仅为示例
|
||||
});
|
||||
},
|
||||
// 点击菜单商品滚动到指定为止
|
||||
titleClickHandle(id) {
|
||||
uni.createSelectorQuery()
|
||||
@@ -657,7 +673,7 @@
|
||||
.exec();
|
||||
}
|
||||
this.titleTopNums = topNums;
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -687,7 +703,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: $paddingSize;
|
||||
// margin-right: $paddingSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -943,12 +959,23 @@
|
||||
}
|
||||
|
||||
.btn {
|
||||
position: relative;
|
||||
padding: 6upx 10upx;
|
||||
background-color: $color-priamry;
|
||||
border-radius: 12upx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: -10px;
|
||||
top: -10px;
|
||||
right: -10px;
|
||||
bottom: -10px;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1153,18 +1180,111 @@
|
||||
}
|
||||
|
||||
.btn {
|
||||
position: relative;
|
||||
padding: 16upx 20upx;
|
||||
background-color: $color-priamry;
|
||||
border-radius: 12upx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: -10px;
|
||||
top: -10px;
|
||||
right: -10px;
|
||||
bottom: -10px;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.classorderdetailshow {
|
||||
position: relative;
|
||||
|
||||
.orderdetailuicon {
|
||||
position: absolute;
|
||||
top: 10rpx;
|
||||
left: 10rpx;
|
||||
}
|
||||
|
||||
.payType {
|
||||
padding: 32rpx 34rpx;
|
||||
margin-top: 48rpx;
|
||||
background-color: #fff;
|
||||
|
||||
>view:first-child {
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
>view:last-child {
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.dfs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.fixedview {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
.flex-between {
|
||||
width: 100%;
|
||||
padding: 24rpx 28rpx;
|
||||
background: #FFFFFF;
|
||||
flex-wrap: nowrap;
|
||||
|
||||
.fixedview_one {
|
||||
.fixedview_oneone {
|
||||
font-size: 28rpx;
|
||||
font-family: SourceHanSansCN-Bold-, SourceHanSansCN-Bold;
|
||||
font-weight: normal;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.fixedview_onetow {
|
||||
font-size: 44rpx;
|
||||
font-family: SourceHanSansCN-Bold-, SourceHanSansCN-Bold;
|
||||
font-weight: normal;
|
||||
color: #F45C4C;
|
||||
font-weight: bold;
|
||||
|
||||
text {
|
||||
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 {
|
||||
background: red;
|
||||
border-radius: 34rpx;
|
||||
padding: 10rpx 44rpx;
|
||||
font-size: 32rpx;
|
||||
font-family: PingFang SC-Bold, PingFang SC;
|
||||
font-weight: bold;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.shop-info-wrap {
|
||||
.info-wrap {
|
||||
padding: $paddingSize * 2 0;
|
||||
|
||||
Reference in New Issue
Block a user