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: [],
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;

View File

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

View File

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

View File

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