<template>
  <view class="wl_footer">
    <slot />
    <view class="wl_footer_contents" v-if="!$slots.default">
      <view
        class="wl_footer_item first_child_btn"
        v-if="props?.btnOtherShow"
        @click="handleOtherClick"
      >
        <hs-button :label="props?.btnOtherName || '返回'" type="display" size="md" />
      </view>
      <view class="wl_footer_item" @click="handleParmaryClick">
        <hs-button
          :label="props?.btnParimaryName || '提交'"
          :disabled="props?.loading"
          type="primary"
          :openType="props?.openType || ''"
          size="md"
        />
      </view>
    </view>
  </view>
</template>
<script lang="ts" setup>
const props = defineProps([
  'btnParimaryName',
  'btnOtherName',
  'btnOtherShow',
  'back',
  'loading',
  'openType',
  'url'
])
const emit = defineEmits(['handleParmaryClick', 'handleOtherClick'])
const handleParmaryClick = () => {
  if (props?.url) {
    uni.navigateTo({ url: props?.url })
    return
  }
  emit('handleParmaryClick')
}
const handleOtherClick = () => {
  emit('handleOtherClick')
  if (props?.back) {
    uni.navigateBack({ delta: 1 })
  }
}
</script>
<style lang="scss" scoped>
.wl_footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  box-shadow: 0px -3px 7px rgba(206, 206, 206, 0.25);
  padding: 30rpx 30rpx 0 30rpx;
  z-index: 100;
  background-color: #fff;
  padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
  padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  .wl_footer_contents {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .wl_footer_item {
    flex: 1;
  }
  .first_child_btn {
    margin-right: 30rpx;
  }
}
</style>
