diff --git a/honey_box/pages/mall/index.vue b/honey_box/pages/mall/index.vue index 358b9e98..2eaa697b 100644 --- a/honey_box/pages/mall/index.vue +++ b/honey_box/pages/mall/index.vue @@ -213,6 +213,14 @@ export default { async order_money(data) { console.log(234); + // 检查库存 + if (data.sale_stock <= 0) { + uni.showToast({ + title: '库存不足', + icon: 'none', + }); + return; + } this.goodsId = data.id; // API: mall_ordermoney const res = await calcMallOrderMoney({ @@ -338,23 +346,17 @@ export default { if (type == 1) { this.close('pop'); - if (res.data.status == 1) { - const status = await this.$platform.pay({ - data: res.data.res - }, this); - if (status == 'success') { + this.$c.toast({ + title: res.msg || '购买成功', + duration: 500, + success: () => { this.getData(); } - } else { - this.$c.toast({ - title: res.msg, - duration: 500, - success: () => { - this.getData(); - } - }); - } + }); } + } else { + // 购买失败也刷新数据 + this.getData(); } },