diff --git a/pages/goods/detail/_id.vue b/pages/goods/detail/_id.vue index 4a060d5..96b7302 100644 --- a/pages/goods/detail/_id.vue +++ b/pages/goods/detail/_id.vue @@ -176,7 +176,7 @@ import UiMoney from "@/components/UiMoney.vue"; import UiButton from "@/components/UiButton.vue"; import UiGoodsItem from "@/components/UiGoodsItem.vue"; import BsChosen from "@/components/BsChosen.vue"; -import {ApiPutAddCart} from "@/plugins/api/cart"; +import { ApiPutAddCart } from "@/plugins/api/cart"; import { ApiGetGoodsDetail, ApiGetGoodsSkus, @@ -264,8 +264,15 @@ export default { }, }, methods: { - addCart(){ - this.$router.push(`/orderSubmit?mode=cart&ids=` + [this.detailData.id]) + addCart() { + let ids = [this.detailData.id]; + this.$router.push({ + path: `/orderSubmit`, + query: { + mode: "cart", + ids, + }, + }); }, isStock() { return this.skuData.some((item) => item.stock > 0); @@ -429,26 +436,26 @@ export default { }); }, - /** - * 加入购物车 - */ - async addCart(){ - if(!this.curSku.skuId){ + /** + * 加入购物车 + */ + async addCart() { + if (!this.curSku.skuId) { this.$message.error("请选择规格~"); - return false; - } - const {error, result} = await ApiPutAddCart({ - productSkuId : this.curSku.skuId, - productId : this.detailData.id, - number : this.curBuyNum - }); - if(error){ - this.$message.error(error.message); - return false; - } - this.$message.success('加入购物车成功~'); - // this.$Router.push('/cart'); - }, + return false; + } + const { error, result } = await ApiPutAddCart({ + productSkuId: this.curSku.skuId, + productId: this.detailData.id, + number: this.curBuyNum, + }); + if (error) { + this.$message.error(error.message); + return false; + } + this.$message.success("加入购物车成功~"); + // this.$Router.push('/cart'); + }, }, };