feat:添加购物车

merge-requests/42/merge
张征 3 years ago
parent 83dd6c4a3f
commit fe4465369a

@ -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');
},
},
};
</script>

Loading…
Cancel
Save