import { connect } from 'herculex';
Component(connect({
  mapStateToProps: {
    globalCar: state => state.$global.globalCar || []
  }
})({
  props: {
    componentData: {},
    tabBarHight: 0,
    onCarClick: () => null,
    onConfirmClick: () => null,
    showFlag: false,
    startDeliveryAmount: 0
  },
  data: {
    inactiveIcon: 'https://gw.alipayobjects.com/mdn/rms_0e8a29/afts/img/A*JCnoQ6bVRA4AAAAAAAAAAAAAARQnAQ',
    activeIcon: 'https://gw.alipayobjects.com/mdn/rms_0e8a29/afts/img/A*tFN4R7f6ZesAAAAAAAAAAAAAARQnAQ'
  },

  didMount() {},

  didUpdate() {},

  methods: {
    showModal() {
      const {
        startDeliveryAmount
      } = this.props;
      const {
        disCountTotalPrice,
        deliveryPackingFee
      } = this.data.globalCar;
      my.alert({
        title: '起送说明',
        content: `当前商品${disCountTotalPrice}元,打包费${deliveryPackingFee}元,起送金额为${startDeliveryAmount}元`,
        buttonText: '我知道了'
      });
    },

    // 点击查看购物车
    handleCarClick() {
      this.props.onCarClick();
    },

    // 点击去确认下单
    handleToConfirm() {
      const {
        carts: currentCar = []
      } = this.data.globalCar;
      const selectedList = currentCar.filter(v => v.checkedState === 'Y');

      if (!selectedList.length) {
        return;
      }

      this.props.onConfirmClick();
    }

  }
}));