<template>
  <div scroll-y="true" :class="['scroll-Y' , theme]">
    <div>
      <div class="parkingFeeCoupon">
        <van-checkbox-group :value="checkedCouponList">
          <div class="card-list" v-if="couponList.length">
            <div class="item" v-for="(item, index) in couponList" :key="index">
              <div class="item-image cro">
                <div class="cro_right_top"></div>
                <div class="cro_right_bottom"></div>
                <div class="img">
                  <div>
                    <span style="font-weight: bold; color: var(--k-color-primary)">￥</span>
                    <span class="itemValue">{{ item.discountFee }}</span>
                  </div>
                  <span style="color: var(--k-color-primary); font-size: 30px">停车劵</span>
                </div>
              </div>
              <div class="item-content cro_">
                <div class="cro_left_top"></div>
                <div class="cro_left_bottom"></div>
                <div class="content">
                  <span class="h3">{{ item.name }}</span>
                  <span class="span">有效期至 {{ item.expirationDate }}</span>
                </div>
                <div class="erwm_box">
                  <van-checkbox color="#fff" @click="checkboxItemChange(`coupon${index}`, index)" checked-color="var(--k-color-primary)" :disabled="item.disabled" :name="`coupon${index}`"/>
                </div>
              </div>
            </div>
          </div>
          <div class="no-coupon" v-else>
            <img :src="require('../../static/images/no-card.png')"/>
            <span class="message">您还没有卡券</span>
          </div>
        </van-checkbox-group>
        <!-- 为避免冲突，小程序 和 H5 跳转 CRM小程序：积分商城 的逻辑分开处理 -->
        <div :class="['guide-box', 'mgb-110', !couponList.length && 'flex-bottom']" v-if="platform === 'miniprogram'">
          <div class="guide-title">优惠券兑换指导</div>
          <div class="guide-desc" @click="navigateToMiniProgram">
            停车优惠券可直接使用，若您还没有兑换或继续兑换，可前往
            <span class="guide-mini">嘉里中心小程序>积分商城</span>
            进行兑换
          </div>
        </div>
        <div :class="['guide-box', 'mgb-110', !couponList.length && 'flex-bottom']" v-if="platform === 'micromessenger'">
          <div class="guide-title">优惠券兑换指导</div>
          <div class="guide-desc">
            停车优惠券可直接使用，若您还没有兑换或继续兑换，可前往
            <span class="guide-mini">嘉里中心小程序>积分商城</span>
            <wx-open-launch-weapp username="gh_0bd6a97b6d38" id="launch-btn" :path="`pages/pointsMall/pointsMall.html${launchPath}`" class="wx-open-launch-weapp" :env-version="envVersion" :extra-data="{...extraData, navigate_time:new Date().getTime()}" @launch="launchFn" @error="launchErrorFn">
              <script type="text/wxtag-template">
                <span style="white-space: nowrap;display: inline-block;color: transparent;text-decoration: underline;margin: 0 5px;font-size: 14PX;"></span>
              </script>
            </wx-open-launch-weapp>
            进行兑换
          </div>
        </div>
        <div style="height: 60px;">
          
        </div>
      </div>
    </div>
    <div class="flewx">
      <div class="flewx-content">
        <div style="color: #333; font-size: 24px; padding-top: 5px">合计:</div>
        <div class="actualFee-box">
          <div style="color: #333333; font-size: 32px; padding-left: 5px">
            {{ actualPayFee | currency }}
          </div>
          <div style="color: #ee4d3f; font-size: 24px; padding-left: 5px">已优惠{{ usingTotalDiscount | currency }}元</div>
        </div>
      </div>
      <div
        :class="{
          flewx_index3: true,
          blue_flewx_index3: custTypeId === 1,
          green_flewx_index3: custTypeId === 2,
          'btn-disabled': !checkedCouponList.length,
        }"
        @click="confirm"
      >
        确定
      </div>
    </div>
  </div>
</template>

<script>
import parkingFeeCouponJs from '../../mixins/parkingFeeCoupon';

export default {
  mixins: [parkingFeeCouponJs],
};
</script>

<style lang="less" scoped>
//@import '../../styles/common.less';

.scroll-Y {
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #f4f7ff;

  .parkingFeeCoupon {
    min-height: 99.88vh;
    background: #f4f7ff;
  }
}

.card-list {
  width: 100%;
  //background: #f4f7ff;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  box-sizing: border-box;
  flex: 1;
  position: relative;

  .item {
    display: flex;
    margin-bottom: 16px;

    .item-image {
      border: 2px solid #f2f2f2;
      border-right: 2px dashed #f2f2f2;
      padding: 16px;
      border-radius: 16px 0 0 16px;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #fff;

      &.cro {
        position: relative;
      }

      .img {
        width: 130px;
        height: 130px;
        border-radius: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        img {
          width: 100%;
          height: 100%;
        }

        .itemValue {
          font-size: 50px;
          font-weight: 600;
          color: var(--k-color-primary);
        }
      }
    }

    .item-content {
      flex: 1;
      border: 2px solid #f2f2f2;
      border-radius: 0 8px 8px 0;
      padding: 16px;
      box-sizing: border-box;
      background: #fff;
      display: flex;

      &.cro_ {
        position: relative;
      }

      .content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex: 1;

        .h3 {
          font-size: 28px;
          line-height: 48px;
          font-weight: 500;
        }

        .span {
          font-size: 24px;
          color: #999999;
          line-height: 40px;
        }
      }

      .erwm_box {
        display: flex;
        align-items: center;
        position: relative;

        img {
          width: 52px;
          height: 52px;
        }

        .tag {
          position: absolute;
          bottom: 0;
          right: 0;
          border-radius: 16px;
          padding: 5px 10px;
          box-sizing: border-box;
          background: #f7931e;
          text-align: center;
          color: #fff;
          width: 122px;
          font-size: 24px;
        }
      }
    }
  }
}

.no-coupon {
  text-align: center;

  img {
    width: 60%;
    display: block;
    margin: 100px auto 20px;
  }

  .message {
    font-size: 36px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #919baa;
    line-height: 50px;
  }
}

// 凹圆角
.cro_left_top,
.cro_left_bottom,
.cro_right_top,
.cro_right_bottom {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid #eee;
  z-index: 1;
  background: #f4f7ff;
}

.cro_left_top {
  top: -1px;
  left: -1px;
  border-radius: 0px 0px 8px 0px;
  border-bottom: 1px solid #f4f7ff;
  border-top: 1px solid #f4f7ff;
  border-right: 1px solid #f4f7ff;
  border-left: 1px solid #f4f7ff;
}

.cro_left_bottom {
  left: -1px;
  bottom: -1px;
  border-radius: 0px 8px 0px 0px;
  border-top: 1px solid #f4f7ff;
  border-bottom: 1px solid #f4f7ff;
  border-right: 1px solid #f4f7ff;
  border-left: 1px solid #f4f7ff;
}

.cro_right_top {
  top: -1px;
  right: -1px;
  border-radius: 0px 0px 0px 8px;
  border-top: 1px solid #f4f7ff;
  border-bottom: 1px solid #f4f7ff;
  border-left: 1px solid #f4f7ff;
  border-right: 1px solid #f4f7ff;
}

.cro_right_bottom {
  right: -1px;
  bottom: -1px;
  border-radius: 8px 0px 0px 0px;
  border-top: 1px solid #f4f7ff;
  border-bottom: 1px solid #f4f7ff;
  border-left: 1px solid #f4f7ff;
  border-right: 1px solid #f4f7ff;
}

.mgb-110 {
  margin-bottom: 110px !important;
}

.guide-box {
  width: calc(100% - 60px);
  margin-left: 30px;

  .guide-title {
    font-size: 34px;
    font-weight: 400;
    color: #333333;
    line-height: 48px;
    margin-bottom: 22px;
  }

  .guide-desc {
    font-size: 28px;
    font-weight: 400;
    color: #999999;
    line-height: 42px;
    position: relative;

    .guide-mini {
      display: inline-block;
      color: var(--k-color-primary);
      text-decoration: underline;
      margin: 0 5px;
    }
  }

  .wx-open-launch-weapp {
    height: 42px;
    position: absolute;
    width: 330px;
    white-space: nowrap;
    left: 90px;
    right: 50px;
    background-color: transparent;
    margin: 0 5px;
  }

  &.flex-bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 50px;
    z-index: 20;
  }
}

.flewx {
  width: 100%;
  height: 100px;
  background-color: #fff;
  position: fixed;
  bottom: 0;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  // padding-bottom: constant(safe-area-inset-bottom);
  // padding-bottom: env(safe-area-inset-bottom);
  padding-bottom: 40px;

  .flewx-content {
    position: absolute;
    left: 16px;
    display: flex;

    .actualFee-box {
      // display: flex;
    }
  }

  .flewx_index3 {
    width: 150px;
    height: 70px;
    border-radius: 50px;
    text-align: center;
    font-size: 28px;
    line-height: 70px;
    color: #fff;
    // background-image: linear-gradient(to right, #7e4fa1, #433c7f);
    background-color: var(--k-color-primary);
    // box-shadow: 2px 3px 5px #888888;
    position: absolute;
    right: 16px;
  }

  .blue_flewx_index3 {
    .color-background-color('blue');
  }

  .green_flewx_index3 {
    .color-background-color('green');
  }
}

/deep/ checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  background-color: red !important;
  border-radius: 50% !important;
  border: 1px solid red;
}

/deep/ checkbox .wx-checkbox-input {
  border-radius: 50% !important;
}
</style>
