vue购物车结算案例

<template>
  <div id="app">
    <h1>购物车结算</h1>
    <p>手机:  价格<input type="num" v-model="phonePay"> 数量<input type="num" v-model="phoneCount">  总额{{phoneSum}}元</p>
    <p>电脑:  价格<input type="num" v-model="comPay"> 数量<input type="num" v-model="comCount">  总额{{comSum}}元</p>
    <p>运费: <input type="num" v-model="transport">元</p>
    <p>共计: {{sum}}元</p>
    <p>优惠: {{cut}}元</p>
    <p>应付: {{pay}}元</p>
  </div>
</template>

<script>

export default {
  data () {
    return {
      phonePay:'',
      phoneCount:'',
      comPay: '',
      comCount: '',
      transport: ''
    }
  },
  computed:{
    phoneSum(){
    return  this.phonePay*this.phoneCount
    },
    comSum() {
      return this.comPay*this.comCount
    },
    sum() {
      return this.phoneSum + this.comSum + Number(this.transport)
    },
    cut() {
      let result = ''
      if(this.phoneSum + this.comSum >= 5000 && this.phoneSum + this.comSum < 8000) {
        result = 100
      } else if(this.phoneSum + this.comSum >= 8000) {
        result = 200
      } 
      return result
    },
    pay() {
      return this.sum - this.cut
    }
  },
}
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值