<template>
  <div
    class="custom-btn"
    :class="[
      props.isBottom ? 'custom-btn-bottom' : '',
      props.subBtnText ? 'apposition-btn-style' : '',
    ]"
  >
    <wd-button
      custom-class="custom-sub-btn-class"
      v-if="props.subBtnText"
      @click="clickSubBtn"
    >
      {{ props.subBtnText }}
    </wd-button>
    <wd-button
      custom-class="custom-btn-class"
      @click="clickBtn"
      :disabled="props?.disabled"
      :class="[props?.disabled ? 'custom-btn-class-disabled' : '']"
      :plain="props?.plain"
      :loading="props?.isLoading"
    >
      {{ props.btnText }}
    </wd-button>
  </div>
</template>
<script setup>
import { reactive } from 'vue'
import { defineProps, defineEmits } from 'vue'
const state = reactive({})
const emits = defineEmits(['clickSubBtn', 'clickBtn'])
const props = defineProps({
  isBottom: false, //是否底部按钮
  btnText: '', //按钮文字
  subBtnText: '', //次要按钮文字
  disabled: false, //是否禁用
  plain: false, //是否镂空
  isLoading: false, //是否正在加载中
})

//点击副按钮
const clickSubBtn = () => {
  emits('clickSubBtn')
}

//点击主按钮
const clickBtn = () => {
  emits('clickBtn')
}
</script>
<style scoped lang="scss">
.custom-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  .custom-sub-btn-class {
    background-color: #eee9f8;
    padding: 18rpx 0;
    border-radius: 8rpx;
    box-shadow: 0 6px 12px 2px rgba(188, 188, 188, 0.08);
    font-size: 28rpx;
    font-weight: 500;
    line-height: 40rpx;
    color: $theme-primary;
    width: 426rpx;
    height: 76rpx;
  }
  .custom-btn-class {
    background-color: $theme-primary;
    padding: 18rpx 0;
    border-radius: 8rpx;
    box-shadow: 0 6px 12px 2px rgba(188, 188, 188, 0.08);
    font-size: 28rpx;
    font-weight: 500;
    line-height: 40rpx;
    width: 426rpx;
    height: 76rpx;
  }
}
.custom-btn-bottom {
  width: 100%;
  background-color: #fff;
  padding: 14rpx 0 72rpx;
  box-shadow: 0 1px 0 2px rgba(231, 231, 231, 1);
}
.apposition-btn-style {
  padding: 14rpx 30rpx 72rpx;
  .custom-sub-btn-class {
    padding: 18rpx 124rpx;
    margin: 0 20rpx 0 0;
  }
  .custom-btn-class {
    padding: 18rpx 124rpx;
  }
}
.custom-btn-class-disabled {
  background-color: #e6e6e6 !important;
  color: #bebebe !important;
}
</style>
