添加购物车
parent
fb9be58020
commit
0c2e5ebf2b
|
@ -59,6 +59,7 @@
|
|||
<el-col :span="12">
|
||||
<h1>商品名称</h1>
|
||||
<h3>商品规格({{checkSkuInfo.sku}})</h3>
|
||||
<h2 style="color: #2200ff">库存:{{checkSkuInfo.stock}}</h2>
|
||||
<h2 style="color: red">¥{{checkSkuInfo.price}}</h2>
|
||||
<el-form ref="form" :model="form" label-width="80px" style="margin-top: 110px">
|
||||
<el-form-item v-for="(ruleAttr, index) in projectDetail.ruleAttrModelList" :label="ruleAttr.name">
|
||||
|
@ -72,7 +73,7 @@
|
|||
<el-input-number v-model="form.num" :min="1" :max="10" label="描述文字"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary">加入购物车</el-button>
|
||||
<el-button type="primary" @click="addCart">加入购物车</el-button>
|
||||
<el-button>立即购买</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
@ -102,14 +103,13 @@
|
|||
|
||||
<script>
|
||||
import {getDetailInfo} from "@/api/product/info";
|
||||
import {addInfo} from "@/api/shopCart/Info";
|
||||
import {Message} from "element-ui";
|
||||
|
||||
export default {
|
||||
name: "productDetail",
|
||||
data() {
|
||||
return {
|
||||
like: true,
|
||||
value1: 415,
|
||||
value2: 1314,
|
||||
title: "销量人气",
|
||||
form: {
|
||||
num: 1
|
||||
|
@ -135,6 +135,11 @@ export default {
|
|||
this.initProjectDetailInfo(detailId);
|
||||
},
|
||||
methods: {
|
||||
addCart(){
|
||||
addInfo(this.form).then(response => {
|
||||
Message({message: , type: 'success'})
|
||||
})
|
||||
},
|
||||
initSku(){
|
||||
let sku = this.projectDetail.projectSkuInfoList[0]["sku"];
|
||||
let skuArr = sku.split("-");
|
||||
|
@ -153,6 +158,7 @@ export default {
|
|||
}
|
||||
sku += "-";
|
||||
}
|
||||
this.form.projectSku = sku;
|
||||
this.checkSkuInfo = this.projectDetail.projectSkuInfoList.find(skuInfo => skuInfo.sku === sku)
|
||||
},
|
||||
initProjectDetailInfo(detailId){
|
||||
|
@ -162,7 +168,7 @@ export default {
|
|||
let key = productAttributeInfo.attributeId;
|
||||
this.attributeMap[key] = productAttributeInfo["value"]
|
||||
})
|
||||
console.log(this.attributeMap)
|
||||
this.form.projectId = this.projectDetail.projectInfo.id;
|
||||
let ruleAttrLength = this.projectDetail.ruleAttrModelList.length;
|
||||
for (let index = 0; index < ruleAttrLength; index++) {
|
||||
this.form["rule"+index] = null;
|
||||
|
|
Loading…
Reference in New Issue