|
@@ -170,18 +170,17 @@
|
|
|
<view class="popup_box">
|
|
|
<view class="check_head">
|
|
|
<view class="headers">
|
|
|
- <view class="grade">选择规格</view>
|
|
|
+ <view class="grade">选择规格{{ isCheckSku }}</view>
|
|
|
<u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="pop_prices">
|
|
|
+ <view v-if="Object.keys(skuItem).length" class="pop_prices">
|
|
|
<view class="lefts">
|
|
|
- <!-- <image :src="$method.splitImgHost(item.coverUrl, true)" class="imgs"></image> -->
|
|
|
- <!-- <image src="" class="imgs"></image> -->
|
|
|
+ <image :src="$method.splitImgHost(skuItem.coverUrl, true)" class="imgs"></image>
|
|
|
</view>
|
|
|
<view class="rights">
|
|
|
- <view class="goods_titles">【建筑全科】2022年一建精华 2022年一建精华班</view>
|
|
|
- <view class="goods_price">¥154.00</view>
|
|
|
+ <view class="goods_titles">{{ skuItem.goodsName }}</view>
|
|
|
+ <view class="goods_price">¥{{ skuItem.standPrice }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="lines"></view>
|
|
@@ -189,8 +188,8 @@
|
|
|
<view v-for="(item, index) in specList" :key="index" class="check_items">
|
|
|
<view class="grades">{{ item.name }}</view>
|
|
|
<view class="grade_names">
|
|
|
- <!-- :class="{nactive: skuIndex == index}" -->
|
|
|
- <view class="course_items" v-for="(child, c_index) in item.specAttrList" :key="c_index" @click="selectSku(child, index, c_index)">
|
|
|
+ <view class="course_items" v-for="(child, c_index) in item.specAttrList" :key="c_index" :class="{'nactive': child.check }"
|
|
|
+ @click="selectSku(child, index, c_index)">
|
|
|
{{ child.name }}
|
|
|
</view>
|
|
|
</view>
|
|
@@ -241,67 +240,28 @@ export default {
|
|
|
States: {0: 0},
|
|
|
goodsType: 1, // 1视频2题库 3补考 4前培 6直播
|
|
|
toggleSkuShow: false,
|
|
|
- courseSku: ['基础班', '钻石班', '基础班', '钻石班', '基础班', '钻石班'],
|
|
|
skuItem: {},
|
|
|
- skuIndex: -1,
|
|
|
isCarOrBuy: 1, // 1加入购物车 2立即购买
|
|
|
- specList: [
|
|
|
- {
|
|
|
- "specId":62,
|
|
|
- "specTemplateId":28,
|
|
|
- name:"一建规格-001",
|
|
|
- "code":null,
|
|
|
- "sort":null,
|
|
|
- "status":1,
|
|
|
- specAttrList: [
|
|
|
- {
|
|
|
- "specAttributeId":115,
|
|
|
- "specId":62,
|
|
|
- name:"一建规格属性0011",
|
|
|
- "code":null,
|
|
|
- "sort":null,
|
|
|
- "status":1
|
|
|
- },
|
|
|
- {
|
|
|
- "specAttributeId":116,
|
|
|
- "specId":62,
|
|
|
- name:"一建规格属性0012",
|
|
|
- "code":null,
|
|
|
- "sort":null,
|
|
|
- "status":1
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "specId":63,
|
|
|
- "specTemplateId":28,
|
|
|
- name:"一建规格-002",
|
|
|
- "code":null,
|
|
|
- "sort":null,
|
|
|
- "status":1,
|
|
|
- specAttrList: [
|
|
|
- {
|
|
|
- "specAttributeId":117,
|
|
|
- "specId":63,
|
|
|
- name:"一建规格属性0021",
|
|
|
- "code":null,
|
|
|
- "sort":null,
|
|
|
- "status":1
|
|
|
- },
|
|
|
- {
|
|
|
- "specAttributeId":118,
|
|
|
- "specId":63,
|
|
|
- name:"一建规格属性0022",
|
|
|
- "code":null,
|
|
|
- "sort":null,
|
|
|
- "status":1
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ], // 规格列表
|
|
|
+ specList: [], // 规格列表
|
|
|
};
|
|
|
},
|
|
|
- computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList','playSectionId','hideBuyState']) },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(['userInfo','goodsAuditionConfigIdList','playSectionId','hideBuyState']),
|
|
|
+ isCheckSku() {
|
|
|
+ let checkCout = 0
|
|
|
+ this.specList.forEach((item, index) => {
|
|
|
+ if (item.specAttrList && item.specAttrList.length) {
|
|
|
+ item.specAttrList.forEach((child, c_index) => {
|
|
|
+ if (child.check) {
|
|
|
+ checkCout++
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ return checkCout
|
|
|
+ },
|
|
|
+ },
|
|
|
onLoad(option) {
|
|
|
// this.id => goodsId
|
|
|
this.id = option.id;
|
|
@@ -673,14 +633,7 @@ export default {
|
|
|
},
|
|
|
addCart(){
|
|
|
// this.getSpecDetail()
|
|
|
- this.toggleSkuShow = true
|
|
|
- this.specList.forEach((item, index) => {
|
|
|
- item.specAttrList.forEach((child) => {
|
|
|
- child['check'] = false
|
|
|
- })
|
|
|
- })
|
|
|
- console.log('000', this.specList)
|
|
|
- return
|
|
|
+ // return
|
|
|
if(this.$method.isGoLogin()){
|
|
|
return
|
|
|
}
|
|
@@ -693,11 +646,9 @@ export default {
|
|
|
this.addShopCart()
|
|
|
},
|
|
|
getSpecDetail() {
|
|
|
- // ${this.detail.specTemplateId}
|
|
|
- // 这里id到时候需要改回来
|
|
|
- console.log('1111111111')
|
|
|
+ // || 35
|
|
|
this.$http({
|
|
|
- url: `/app/common/spec/28`,
|
|
|
+ url: `/app/common/spec/${this.detail.specTemplateId}`,
|
|
|
method: 'get',
|
|
|
noToken: true
|
|
|
}).then((res) => {
|
|
@@ -707,11 +658,10 @@ export default {
|
|
|
if (data) {
|
|
|
this.specList = data && (data.specList || [])
|
|
|
this.specList.forEach((item, index) => {
|
|
|
- item.specAttrList.forEach((child) => {
|
|
|
- child['check'] = false
|
|
|
+ item.specAttrList.forEach((child, i_index) => {
|
|
|
+ this.$set(this.specList[index].specAttrList[i_index], 'check', false)
|
|
|
})
|
|
|
})
|
|
|
- console.log('this.specList', this.specList)
|
|
|
}
|
|
|
} else {
|
|
|
this.$u.toast('暂无数据')
|
|
@@ -861,23 +811,55 @@ export default {
|
|
|
},
|
|
|
closePop() {
|
|
|
this.toggleSkuShow = false
|
|
|
+ this.skuItem = {}
|
|
|
},
|
|
|
selectSku(item, index, c_index) {
|
|
|
- console.log('defhd', item, index, c_index)
|
|
|
- this.$set(this.specList[index].specAttrList[c_index], '')
|
|
|
- // this.specList
|
|
|
- // this.skuItem = item
|
|
|
- // this.skuIndex = index
|
|
|
+ this.specList[index].specAttrList.forEach((i_item, i_index) => {
|
|
|
+ if (item.specAttributeId == i_item.specAttributeId) {
|
|
|
+ this.$set(this.specList[index].specAttrList[i_index], 'check', true)
|
|
|
+ } else {
|
|
|
+ this.$set(this.specList[index].specAttrList[i_index], 'check', false)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // console.log('this.specList', this.specList, this.isCheckSku)
|
|
|
+ if (this.specList.length == this.isCheckSku) {
|
|
|
+ let specAttrIds = []
|
|
|
+ this.specList.forEach((item) => {
|
|
|
+ let result = item.specAttrList.find(e => e.check)
|
|
|
+ if (result) {
|
|
|
+ specAttrIds.push(result.specAttributeId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.getGoodsInfos(specAttrIds)
|
|
|
+ }
|
|
|
},
|
|
|
+ // 获取规格属性值对应的商品信息
|
|
|
+ getGoodsInfos(specAttrIds) {
|
|
|
+ this.$http({
|
|
|
+ url: '/app/common/attr/goods',
|
|
|
+ method: 'get',
|
|
|
+ data: {
|
|
|
+ specTemplateId: this.detail.specTemplateId,
|
|
|
+ specAttrIds: specAttrIds.join(',')
|
|
|
+ },
|
|
|
+ noToken: true
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ this.skuItem = res.data.data || {}
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
rightNowBuy() {
|
|
|
- // if (Object.keys(this.skuItem).length == 0) {
|
|
|
- // this.$u.toast('请选择科目')
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if(this.$method.isGoLogin()){
|
|
|
- // return
|
|
|
- // }
|
|
|
- // this.$navTo.togo('/pages2/order/confirm_list?id='+this.skuItem.goodsId)
|
|
|
+ if (this.specList.length != this.isCheckSku) {
|
|
|
+ this.$u.toast('请先选择所有的规格')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.isCarOrBuy == 1) { // 加入购物车
|
|
|
+ this.addShopCart()
|
|
|
+ } else {
|
|
|
+ this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
|
|
|
+ }
|
|
|
+ this.closePop()
|
|
|
}
|
|
|
}
|
|
|
};
|