源码
https://blog.youkuaiyun.com/qq_39019768/article/details/85629189
点击出现蒙层样式实现
<template>
<div class="cab-common cab-food" @click="addCart">
<div class="item">
<div class="describe">
<span class="first">机上餐食</span>
<p class="second">Restaurant</p>
</div>
<div v-if="is_sku" class="specification_mask2">
<div class="specification_com2" @click.stop="is_sku==false">
<a class="sku-close" @click="cancelMask" aria-label="关闭">
<i class="iconfont icon-chahao"></i>
</a>
<div class="number-line">
<label for="number">您的座位号</label>
<span class="J_limitTxt limit-txt"></span>
<div class="number">
<input id="number" type="number" v-model="this.$route.query.seat">
</div>
</div>
<cube-button @click="sku_addCart" :primary="true">提交</cube-button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
is_sku: false, // 规格弹窗
skuArr: [],
selectArr: [], // 存放被选中的值
shopItemInfo: {} // 存放要和选中的值进行匹配的数据
}
},
created: function() {
var that = this
// 商家推荐
this.axios.get('/api/getgoods', function(res) {
console.log('eee')
})
},
methods: {
addCart() {
console.log('111')
this.is_sku = true
this.getGoodsSku()
},
// 点击蒙层取消
cancelMask: function() {
this.is_sku = false
}
}
}
</script>
<style lang="stylus" >
.item {
width: 100%;
text-align: center;
}
.specification_mask2 {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
}
.specification_com2 {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
background: #fff;
}
.choose_sku2 {
max-height: 300px;
overflow: scroll;
}
.sku_specification2 {
box-sizing: border-box;
padding: 10px;
}
.sku-close {
display block
text-align right
padding 10px
}
.sku_title2 {
font-size: 15px;
height: 0.5rem;
line-height: 0.5rem;
}
.sku_ul2 {
display: flex;
flex-wrap: wrap;
}
ol, ul {
margin: 0;
padding: 0;
list-style: none;
}
.productActive {
background: #ffd100;
}
</style>
先上效果图
这里点击绿色,单价和库存变了
那么,它的内部逻辑究竟是怎么实现的呢?
项目里面涉及两个json数据
indexGoodsShow.json 这个是刚点进页面获取的数据
getGoodsSku.json 这个是点击加号以后渲染到页面的数据
点击加号以后显示的价钱和库存都是之前请求的indexGoodsShow.json里面的数据,而图片和名称是getGoodsSku.json里面的
这里的skuArr怎么来的呢?
发起请求,去请求json数据 ,成功以后的res赋给that.skuArr
这里有一个问题:淘宝上面的价格区间是怎么显示的呢?
这个地址怎么做出来的 https://oem.mobzhifu.com/Uploads/