desk
parent
87ffa823de
commit
2c3d45f7cc
|
|
@ -101,11 +101,15 @@ export default {
|
|||
},
|
||||
|
||||
cartList: [],
|
||||
selectedCart: []
|
||||
selectedCart: [],
|
||||
|
||||
// 桌号
|
||||
desk: ''
|
||||
};
|
||||
},
|
||||
onLoad(e) {
|
||||
this.mid = e.mid
|
||||
this.desk = uni.getStorageSync('desk')
|
||||
},
|
||||
onShow() {
|
||||
this.getCartList()
|
||||
|
|
@ -143,6 +147,9 @@ export default {
|
|||
//结算
|
||||
onSubmit() {
|
||||
if (this.selectedCart.length == 0) return this.$u.toast('请选择需要结算的商品');
|
||||
if (this.desk) {
|
||||
return this.handleOrder()
|
||||
}
|
||||
const cart = this.cartList.filter(item => this.selectedCart.indexOf(item.id) >= 0)
|
||||
const params = { store_id: this.mid, products: cart.map(item => {
|
||||
return {
|
||||
|
|
@ -158,6 +165,12 @@ export default {
|
|||
this.$u.route('/pageB/code/index', { id: res.order_pre })
|
||||
})
|
||||
},
|
||||
// 下单
|
||||
handleOrder() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/confirm_order/confirm_order?mid='+this.mid+'&store_cart=' + this.selectedCart.join(',')
|
||||
})
|
||||
},
|
||||
// 数量改变
|
||||
onNumChange(value, id) {
|
||||
if (isNaN(value)) return;
|
||||
|
|
|
|||
|
|
@ -186,11 +186,41 @@
|
|||
couponShow: false,
|
||||
isFirstLoading:true,
|
||||
addressAry:[],
|
||||
cuId:null
|
||||
cuId:null,
|
||||
|
||||
// 桌号信息
|
||||
desk: '',
|
||||
// 门店id
|
||||
mid: '',
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
const data = JSON.parse(decodeURIComponent(options.data));
|
||||
let data = {}
|
||||
if (options.data) {
|
||||
data = JSON.parse(decodeURIComponent(options.data));
|
||||
}
|
||||
else if (options.store_cart) {
|
||||
// 桌号 id
|
||||
let desk = uni.getStorageSync('desk')
|
||||
this.$api.get(`/v1/store/desk/${desk}`).then(res => {
|
||||
this.desk = res
|
||||
this.type = 'desk'
|
||||
})
|
||||
// 商户 id
|
||||
this.mid = options.mid
|
||||
// 购物车商品 id
|
||||
let ids = options.store_cart.split(',').map(value => parseInt(value))
|
||||
this.$store.dispatch('storeCart/getCart').then(res => {
|
||||
const goods = res.filter(item => ids.indexOf(item.id) >= 0)
|
||||
this.goods = goods.map(item => {
|
||||
return {
|
||||
sku_id: item.id,
|
||||
num: item.number
|
||||
}
|
||||
})
|
||||
this.getDetail()
|
||||
})
|
||||
}
|
||||
|
||||
uni.$on('address:select', this.addressUpdate);
|
||||
|
||||
|
|
@ -236,7 +266,9 @@
|
|||
}
|
||||
},
|
||||
onShow() {
|
||||
if (this.goods.length > 0 || this.cards.length > 0) {
|
||||
this.getDetail();
|
||||
}
|
||||
this.getAddress()
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -248,7 +280,7 @@
|
|||
couponId,
|
||||
isDistribution
|
||||
} = this;
|
||||
if(this.type != 'points' || this.skuOne?.require_shipping_address){
|
||||
if((this.type != 'points' && this.type != 'desk') || this.skuOne?.require_shipping_address){
|
||||
if (!addressId) return this.$u.toast('收货地址不能为空');
|
||||
if (!isDistribution) return this.$u.toast('所在地区不支持配送');
|
||||
}
|
||||
|
|
@ -260,10 +292,7 @@
|
|||
};
|
||||
|
||||
if(this.type == 'points'){
|
||||
const {
|
||||
num,
|
||||
sku_id
|
||||
} = this.goods[0];
|
||||
const {num, sku_id } = this.goods[0];
|
||||
params.sku_id = sku_id
|
||||
params.quantity = num
|
||||
}else if (this.type == 'bargains') {
|
||||
|
|
@ -271,14 +300,12 @@
|
|||
} else if (this.type == 'cart') {
|
||||
params.shopping_cart = this.cards;
|
||||
} else {
|
||||
const {
|
||||
num,
|
||||
sku_id
|
||||
} = this.goods[0];
|
||||
params.product = {
|
||||
sku_id: sku_id,
|
||||
quantity: num,
|
||||
};
|
||||
params.products = this.goods.map(item => {
|
||||
return {
|
||||
sku_id: item.sku_id,
|
||||
quantity: item.num,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (btnLoading) return;
|
||||
|
|
@ -290,7 +317,14 @@
|
|||
order = await this.$api.post(`/v1/points/orders`, params);
|
||||
}else if(this.type == 'bargains'){
|
||||
order = await this.$api.post(`/v1/bargains/create-mall-order/${this.cuId}`, params);
|
||||
}else{
|
||||
}
|
||||
// 桌号
|
||||
else if (this.type == 'desk') {
|
||||
params.desk = this.desk.id
|
||||
params.store_id = this.mid
|
||||
order = await this.$api.post(`/v1/order/orders`, params)
|
||||
}
|
||||
else {
|
||||
order = await this.$api.post('/v1/order/orders', params);
|
||||
}
|
||||
if(order.status==1 || order.status==2){//支付成功
|
||||
|
|
@ -347,10 +381,7 @@
|
|||
shipping_address_id: this.addressId,
|
||||
};
|
||||
if(this.type == 'points'){
|
||||
const {
|
||||
num,
|
||||
sku_id
|
||||
} = this.goods[0];
|
||||
const { num, sku_id } = this.goods[0];
|
||||
params.sku_id = sku_id
|
||||
params.quantity= num
|
||||
} else if(this.type == 'bargains'){
|
||||
|
|
@ -366,10 +397,7 @@
|
|||
}else if (this.type == 'cart') {
|
||||
params.shopping_cart = this.cards;
|
||||
} else {
|
||||
const {
|
||||
num,
|
||||
sku_id
|
||||
} = this.goods[0];
|
||||
const { num, sku_id } = this.goods[0];
|
||||
params.product = {
|
||||
sku_id: sku_id,
|
||||
quantity: num,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
onLoad(e) {
|
||||
const scene = strToParams(decodeURIComponent(e.scene))
|
||||
this.scene = scene
|
||||
// 清空桌号
|
||||
uni.removeStorageSync('desk');
|
||||
// 优先存储 invite_code
|
||||
if (scene.i) {
|
||||
uni.setStorageSync('INVITE_CODE', scene.i)
|
||||
|
|
@ -31,11 +33,23 @@
|
|||
})
|
||||
}
|
||||
// 扫码下单
|
||||
if (scene.o) {
|
||||
else if (scene.o) {
|
||||
uni.redirectTo({
|
||||
url: '/pageB/select_product/com_order?id=' + scene.o
|
||||
})
|
||||
}
|
||||
// 扫码桌号
|
||||
else if (scene.d) {
|
||||
const desk = scene.d
|
||||
uni.setStorageSync('desk', desk);
|
||||
// 商品分类
|
||||
const id = scene.c
|
||||
// 店铺 id
|
||||
const mid = scene.s
|
||||
uni.redirectTo({
|
||||
url: `/pageB/select_product/search?mid=${mid}&cid=${id}`
|
||||
});
|
||||
}
|
||||
// 默认跳转首页
|
||||
else {
|
||||
uni.switchTab({
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ const actions = {
|
|||
resolve(cart)
|
||||
})
|
||||
},
|
||||
getCart() {
|
||||
return uni.getStorageSync(CART)
|
||||
},
|
||||
// 获取购物车列表
|
||||
getCartList({ commit, rootGetters, state, dispatch }, params) {
|
||||
const { mid } = params
|
||||
|
|
|
|||
Loading…
Reference in New Issue