vue实现仿淘宝结账页面实例代码

2020-06-16 05:35:20易采站长站整理

});
},
changeMoney: function(index, way) {
if (way > 0) {
this.table_list[index].product_quantity++;
} else {
this.table_list[index].product_quantity--;
if (this.table_list[index].product_quantity < 1) {
this.table_list[index].product_quantity = 1;
}
}
this.calcTotalPrice();
},
calcTotalPrice: function() {
var _this = this;
_this.allProductTotal = 0;
this.table_list.forEach(function(item, index) {
if (index > 0) { //因为第一行为表头不需要进行计算
item.total_amount = item.product_price * item.product_quantity; //根据商品数量计算每一个商品对应的总金额
}
if (item.checked) {
_this.allProductTotal += item.product_price * item.product_quantity; //根据是否否选该商品的checkbox,计算总价
}
});
},
},
watch: { //深度 watcher
'checkList': {
handler: function(val, oldVal) {
if (val.length === this.table_list.length - 1) {
this.checked = true;
} else {
this.checked = false;
}
},
deep: true
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.container {
padding: 69px 0 54px 0;
}
table {
border-collapse: collapse;
border-color: transparent;
text-align: center;
}
.product_table,
.product_table tbody {
width: 100%
}
.product_table tr:first-child {
background: #ece6e6;
color: #e66280;
font-size: 20px;
}
.product_table td {
border: 1px solid #f3e8e8;
height: 62px;
line-height: 62px;
}
.product_table a.update:link,
.product_table a.update:visited,
.product_table a.update:hover,
.product_table a.update:active {
color: #1CE24A;
}
.product_table a.delete:link,
.product_table a.delete:visited,
.product_table a.delete:hover,
.product_table a.delete:active {
color: #ffa700;
}
.product_table .txt_number {
text-align: center;
}
.product_table .numbers {
font-weight: bold;
}
.price_total_bottom {
font-size: 20px;
padding: 20px 10px;
}
.price_total_ms {
text-align: right;
}
.price_total_bottom .price_total_ms label {
margin-right: 100px;
}
.price_total_bottom .price_total_ms a {
cursor: default;
text-align: center;
display: inline-block;
font-size: 20px;
color: #fff;
font-weight: bold;
width: 220px;
height: 54px;
line-height: 54px;
border: 0;
background-color: #f71455;
}
</style>

总结

以上所述是小编给大家介绍的vue实现仿淘宝结账页面实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对软件开发网网站的支持!