|
@@ -8,7 +8,7 @@
|
|
|
<!-- <uni-icons type="forward" size="20"></uni-icons> -->
|
|
|
</view>
|
|
|
<view class="num">
|
|
|
- 桌号:{{shopInfo.table}}
|
|
|
+ 桌号:{{shopInfo.table_name}}
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- <view class="one_2">
|
|
@@ -151,6 +151,8 @@
|
|
|
is_show: false,
|
|
|
// 规格弹框
|
|
|
popupShow: '1',
|
|
|
+ // 桌号
|
|
|
+ tableList: [],
|
|
|
}
|
|
|
},
|
|
|
onLoad: async function(e) {
|
|
@@ -167,10 +169,12 @@
|
|
|
async search() {
|
|
|
const that = this;
|
|
|
let res;
|
|
|
+ res = await that.$api(`table`, 'GET', {});
|
|
|
+ if (res.errcode == '0') that.$set(that, `tableList`, res.data);
|
|
|
res = await that.$api(`shop`, 'GET', {});
|
|
|
if (res.errcode == '0') {
|
|
|
let data = res.data[0]
|
|
|
- data.table = '1'
|
|
|
+ data.table_name = that.tableList[0].name
|
|
|
that.$set(that, `shopInfo`, data);
|
|
|
}
|
|
|
res = await that.$api(`goodsTags`, 'GET', {});
|
|
@@ -265,22 +269,38 @@
|
|
|
if (that.id) {
|
|
|
res = await that.$api(`cart/${that.id}`, 'GET', {});
|
|
|
if (res.errcode == '0') {
|
|
|
- let obj = {
|
|
|
- list: [...list, ...res.data.list],
|
|
|
- total: that.$plus(that.cartNum.total, res.data.total),
|
|
|
- }
|
|
|
- let cart = await that.$api(`cart/${res.data._id}`, 'POST', obj);
|
|
|
- if (cart.errcode == '0') {
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pagesHome/order/add?id=${cart.data._id}&order=${that.order}`
|
|
|
- })
|
|
|
+ let same = res.data.list.length === list.length && res.data.list.filter(t => !list
|
|
|
+ .includes(t));
|
|
|
+ if (same == false) {
|
|
|
+ let is_add = true
|
|
|
+ for (let val of res.data.list) {
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ if (val._id == list[i]._id) {
|
|
|
+ list[i].num = val.num + list[i].num
|
|
|
+ is_add = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (is_add) {
|
|
|
+ list.push(val)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let obj = {
|
|
|
+ list: that.buyList,
|
|
|
+ money: that.$plus(that.cartNum.total, res.data.total),
|
|
|
+ }
|
|
|
+ let update = await that.$api(`order/${that.order}`, 'POST', obj);
|
|
|
+ if (update.errcode == '0') {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pagesHome/order/add?id=${that.id}&order=${that.order}`
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
let obj = {
|
|
|
list: list,
|
|
|
total: that.cartNum.total,
|
|
|
- table: '63dc6a6b6a22ff30c8a11470'
|
|
|
+ table: that.tableList[0]._id
|
|
|
}
|
|
|
res = await that.$api(`cart`, 'POST', obj);
|
|
|
if (res.errcode == '0') {
|