<template>
  <view class="address">
    <view class="address-type">用户信息：</view>
    <view
      class="address-item ss-flex ss-row-between ss-col-center"
      :class="[{ 'border-bottom': props.hasBorderBottom }]"
    >
      <view class="item-left">
        <view class="person-text">自取时间</view>
        <view class="area-text ss-flex ss-col-center">
          <uni-datetime-picker v-model="state.selffetch_time" type="datetime" @change="onChangeTime" :end="state.today" style="z-index: 201;">
            <button class="ss-reset-button date-btn">
              <text>{{ !dateFilterText || dateFilterText.length === 0 ? '请选择自取时间' : dateFilterText }}</text>
              <text class="cicon-drop-down ss-seldate-icon"></text>
            </button>
          </uni-datetime-picker>
        </view>
      </view>
      <view class="item-right">
        <view class="item-right-label">预留电话</view>
        <view class="item-right-value">
          <uni-easyinput
            placeholder="请输入预留电话"
            v-model="state.phone"
            :inputBorder="false"
            placeholderStyle="font-size:26rpx !important;line-height:normal;"
            @blur="onInput($event)"
            type="text">
          </uni-easyinput>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
  import { onLoad } from '@dcloudio/uni-app';
  import dayjs from 'dayjs';
  import { computed, reactive } from 'vue';
  import sheep from '@/sheep';
  import { isEmpty } from 'lodash';
  const userInfo = computed(() => sheep.$store('user').userInfo);
  const dateFilterText = computed(() => {
    return state.selffetch_time;
  });

  const props = defineProps({
    hasBorderBottom: {
      type: Boolean,
      defult: true,
    },
  });

  const state = reactive({
    selffetch_time: '',
    today: '',
    phone: '',
  });

  function onChangeTime(e) {
    state.selffetch_time = e;
    uni.$emit('zitiinfo', {
      selffetch_time: e,
      phone: state.phone,
    });
  }

  function onInput(e) {
    uni.$emit('zitiinfo', {
      selffetch_time: state.selffetch_time,
      phone: e.target.value,
    });
  }

  onLoad(async (options) => {
    state.phone = userInfo.mobile;
  });
</script>

<style lang="scss" scoped>
  .address {
    border-top: 10rpx solid #f2f2f2;
    padding: 39rpx 0 0;
  }
  .address-type {
    padding-left: 30rpx;
    font-size: 26rpx;
    font-weight: bold;
    color: #333333;
  }
  .address-item {
    padding: 24rpx 30rpx;
    font-size: 24rpx;
    .item-left, .item-right {
      flex: 1;
    }

    .area-text {
      font-weight: 400;
      color: $dark-9;
      font-size: 24rpx;
      color: #000000;
      margin-top: 10rpx;
    }

    .address-text {
      font-size: 32rpx;
      font-weight: 500;
      color: #333333;
      line-height: 48rpx;
    }

    .person-text {
      display: flex;
      align-items: center;
      font-size: 26rpx;
      color: #000000;
      .name {
        font-weight: 500;
      }
      .phone {
        font-weight: 400;
        display: inline-block;
        margin-left: 15rpx;
        margin-right: 10rpx;
      }
      .default-address {
        display: inline-block;
        padding: 3rpx 20rpx;
        text-align: center;
        background: var(--ui-BG-Main);
        border-radius: 14rpx 14rpx 14rpx 14rpx;
        font-weight: 400;
        font-size: 18rpx;
        color: #FFFFFF;
      }
    }
  }

  .edit-btn {
    width: 46rpx;
    height: 46rpx;
    .edit-icon {
      width: 46rpx;
      height: 46rpx;
    }
  }
  image {
    width: 100%;
    height: 100%;
  }
  .date-btn {
      background-color: $white;
      line-height: 54rpx;
      border-radius: 27rpx;
      font-size: 26rpx;
      font-weight: 400;
      color: $dark-6;

      .ss-seldate-icon {
        font-size: 50rpx;
        color: $dark-9;
      }
    }
</style>
