<commit_before><style lang="less" src="./shopcart.less" scoped></style>
<template>
	<div class="shopcart">
    <div class="content">
      <div class="con-left">
        <div class="logo-wrapper">
          <div class="logo" :class="{'highlight': totalCount>0}">
            <i class="icon i-cart" :class="{'highlight': totalCount>0}"></i>
          </div>
          <div class="num" v-show="totalCount>0">{{totalCount}}</div>
        </div>
        <div class="price" :class="{'highlight': totalPrice>0}">￥{{totalPrice}}</div>
        <div class="desc">另需配送费￥{{deliveryPrice}}元</div>
      </div>
      <div class="con-right">
        <div class="pay not-enough">￥{{minPrice}}起送</div>
      </div>
    </div>
    <!-- 购车车弹出层food列表 -->
    <div class="shopcart-list" v-show="listShow">
      <div class="list-header">
        <h1 class="title">购物车</h1>
        <span class="empty">清空</span>
      </div>
      <div class="list-content">
        <ul>
          <li class="food">
            <span class="name">娃娃菜炖豆腐</span>
            <div class="price">
              <span>￥30</span>
            </div>
          </li>
          <li class="food">
            <span class="name">娃娃菜炖豆腐</span>
            <div class="price">
              <span>￥30</span>
            </div>
          </li>
          <li class="food">
            <span class="name">娃娃菜炖豆腐</span>
            <div class="price">
              <span>￥30</span>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!-- 弹出层后 其他部分蒙层 -->
    <transition name="fade">
      <div class="list-mask" @click="hideList()" v-show="listShow"></div>
    </transition>
  </div>
</template>
<script>
  export default {
    props: {
      selectFoods: {
        type: Array,
        default () {
          return []
        }
      },
      deliveryPrice: {
        type: Number,
        default: 0
      },
      minPrice: {
        type: Number,
        default: 0
      }
    },
    data () {
      return {
        listShow: false
      }
    },
    computed: {
      totalCount () {
        let count = 0
        this.selectFoods.forEach((food) => {
          count += food.count
        })
        return count
      },
      totalPrice () {
        let total = 0
        this.selectFoods.forEach((food) => {
          total += food.price * food.count
        })
        return total
      }
    }
  }
</script><commit_msg>update 价格同步<commit_after><style lang="less" src="./shopcart.less" scoped></style>
<template>
	<div class="shopcart">
    <div class="content">
      <div class="con-left">
        <div class="logo-wrapper">
          <div class="logo" :class="{'highlight': totalCount>0}">
            <i class="icon i-cart" :class="{'highlight': totalCount>0}"></i>
          </div>
          <div class="num" v-show="totalCount>0">{{totalCount}}</div>
        </div>
        <div class="price" :class="{'highlight': totalPrice>0}">￥{{totalPrice}}</div>
        <div class="desc">另需配送费￥{{deliveryPrice}}元</div>
      </div>
      <div class="con-right">
        <div class="pay" :class="payClass">{{payDesc}}</div>
      </div>
    </div>
    <!-- 购车车弹出层food列表 -->
    <div class="shopcart-list" v-show="listShow">
      <div class="list-header">
        <h1 class="title">购物车</h1>
        <span class="empty">清空</span>
      </div>
      <div class="list-content">
        <ul>
          <li class="food">
            <span class="name">娃娃菜炖豆腐</span>
            <div class="price">
              <span>￥30</span>
            </div>
          </li>
          <li class="food">
            <span class="name">娃娃菜炖豆腐</span>
            <div class="price">
              <span>￥30</span>
            </div>
          </li>
          <li class="food">
            <span class="name">娃娃菜炖豆腐</span>
            <div class="price">
              <span>￥30</span>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!-- 弹出层后 其他部分蒙层 -->
    <transition name="fade">
      <div class="list-mask" @click="hideList()" v-show="listShow"></div>
    </transition>
  </div>
</template>
<script>
  export default {
    props: {
      selectFoods: {
        type: Array,
        default () {
          return []
        }
      },
      deliveryPrice: {
        type: Number,
        default: 0
      },
      minPrice: {
        type: Number,
        default: 0
      }
    },
    data () {
      return {
        listShow: false
      }
    },
    computed: {
      totalCount () {
        let count = 0
        this.selectFoods.forEach((food) => {
          count += food.count
        })
        return count
      },
      totalPrice () {
        let total = 0
        this.selectFoods.forEach((food) => {
          total += food.price * food.count
        })
        return total
      },
      payDesc () {
        let diff = this.minPrice - this.totalPrice
        if (this.totalPrice === 0) {
          return `￥${this.minPrice}起送`
        } else if (this.totalPrice < this.minPrice) {
          return `还差${diff}元起送`
        } else {
          return '去结算'
        }
      },
      payClass () {
        if (this.totalPrice < this.minPrice) {
          return 'not-enough'
        } else {
          return 'enough'
        }
      }
    }
  }
</script>
{'fraction_non_alphanumeric': 0.17810302223911803, 'fraction_numerical': 0.006272571754419312, 'mean_word_length': 1.5921182266009852, 'pattern_counts': {'":': 0, '<': 145, '<?xml version=': 0, '>': 155, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3099695', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1831, 'n_words': 308}