6
0
Fork 0
develop
panliang 2023-02-23 16:28:15 +08:00
parent 87ffa823de
commit 2c3d45f7cc
4 changed files with 86 additions and 28 deletions

View File

@ -101,11 +101,15 @@ export default {
}, },
cartList: [], cartList: [],
selectedCart: [] selectedCart: [],
//
desk: ''
}; };
}, },
onLoad(e) { onLoad(e) {
this.mid = e.mid this.mid = e.mid
this.desk = uni.getStorageSync('desk')
}, },
onShow() { onShow() {
this.getCartList() this.getCartList()
@ -143,6 +147,9 @@ export default {
// //
onSubmit() { onSubmit() {
if (this.selectedCart.length == 0) return this.$u.toast('请选择需要结算的商品'); 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 cart = this.cartList.filter(item => this.selectedCart.indexOf(item.id) >= 0)
const params = { store_id: this.mid, products: cart.map(item => { const params = { store_id: this.mid, products: cart.map(item => {
return { return {
@ -158,6 +165,12 @@ export default {
this.$u.route('/pageB/code/index', { id: res.order_pre }) 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) { onNumChange(value, id) {
if (isNaN(value)) return; if (isNaN(value)) return;

View File

@ -186,11 +186,41 @@
couponShow: false, couponShow: false,
isFirstLoading:true, isFirstLoading:true,
addressAry:[], addressAry:[],
cuId:null cuId:null,
//
desk: '',
// id
mid: '',
}; };
}, },
onLoad(options) { 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); uni.$on('address:select', this.addressUpdate);
@ -236,7 +266,9 @@
} }
}, },
onShow() { onShow() {
this.getDetail(); if (this.goods.length > 0 || this.cards.length > 0) {
this.getDetail();
}
this.getAddress() this.getAddress()
}, },
methods: { methods: {
@ -248,7 +280,7 @@
couponId, couponId,
isDistribution isDistribution
} = this; } = 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 (!addressId) return this.$u.toast('收货地址不能为空');
if (!isDistribution) return this.$u.toast('所在地区不支持配送'); if (!isDistribution) return this.$u.toast('所在地区不支持配送');
} }
@ -260,10 +292,7 @@
}; };
if(this.type == 'points'){ if(this.type == 'points'){
const { const {num, sku_id } = this.goods[0];
num,
sku_id
} = this.goods[0];
params.sku_id = sku_id params.sku_id = sku_id
params.quantity = num params.quantity = num
}else if (this.type == 'bargains') { }else if (this.type == 'bargains') {
@ -271,14 +300,12 @@
} else if (this.type == 'cart') { } else if (this.type == 'cart') {
params.shopping_cart = this.cards; params.shopping_cart = this.cards;
} else { } else {
const { params.products = this.goods.map(item => {
num, return {
sku_id sku_id: item.sku_id,
} = this.goods[0]; quantity: item.num,
params.product = { }
sku_id: sku_id, })
quantity: num,
};
} }
if (btnLoading) return; if (btnLoading) return;
@ -290,7 +317,14 @@
order = await this.$api.post(`/v1/points/orders`, params); order = await this.$api.post(`/v1/points/orders`, params);
}else if(this.type == 'bargains'){ }else if(this.type == 'bargains'){
order = await this.$api.post(`/v1/bargains/create-mall-order/${this.cuId}`, params); 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); order = await this.$api.post('/v1/order/orders', params);
} }
if(order.status==1 || order.status==2){// if(order.status==1 || order.status==2){//
@ -347,13 +381,10 @@
shipping_address_id: this.addressId, shipping_address_id: this.addressId,
}; };
if(this.type == 'points'){ if(this.type == 'points'){
const { const { num, sku_id } = this.goods[0];
num,
sku_id
} = this.goods[0];
params.sku_id = sku_id params.sku_id = sku_id
params.quantity= num params.quantity= num
}else if(this.type == 'bargains'){ } else if(this.type == 'bargains'){
params.bargain_order_id = this.cuId params.bargain_order_id = this.cuId
const { const {
num, num,
@ -366,10 +397,7 @@
}else if (this.type == 'cart') { }else if (this.type == 'cart') {
params.shopping_cart = this.cards; params.shopping_cart = this.cards;
} else { } else {
const { const { num, sku_id } = this.goods[0];
num,
sku_id
} = this.goods[0];
params.product = { params.product = {
sku_id: sku_id, sku_id: sku_id,
quantity: num, quantity: num,

View File

@ -20,6 +20,8 @@
onLoad(e) { onLoad(e) {
const scene = strToParams(decodeURIComponent(e.scene)) const scene = strToParams(decodeURIComponent(e.scene))
this.scene = scene this.scene = scene
//
uni.removeStorageSync('desk');
// invite_code // invite_code
if (scene.i) { if (scene.i) {
uni.setStorageSync('INVITE_CODE', scene.i) uni.setStorageSync('INVITE_CODE', scene.i)
@ -31,11 +33,23 @@
}) })
} }
// //
if (scene.o) { else if (scene.o) {
uni.redirectTo({ uni.redirectTo({
url: '/pageB/select_product/com_order?id=' + scene.o 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 { else {
uni.switchTab({ uni.switchTab({

View File

@ -83,6 +83,9 @@ const actions = {
resolve(cart) resolve(cart)
}) })
}, },
getCart() {
return uni.getStorageSync(CART)
},
// 获取购物车列表 // 获取购物车列表
getCartList({ commit, rootGetters, state, dispatch }, params) { getCartList({ commit, rootGetters, state, dispatch }, params) {
const { mid } = params const { mid } = params