<template>
  <van-swipe-cell class="express-addr-list-item-swipe">
    <div class="address-list-item flex-default">
      <div class="address">
        <div class="top">
          <div class="default flex-default" v-show="itemData.defaultAddr === 1">
            <span>默认</span>
          </div>
          {{
            `${itemData.province}${itemData.city}${itemData.county}${itemData.street}`
          }}
        </div>
        <div class="center">
          {{ itemData.detailAddr }}
        </div>
        <div class="bottom flex-default">
          <div class="name">
            {{ itemData.name }}
          </div>
          <div class="phone">
            {{ itemData.phone }}
          </div>
        </div>
      </div>
      <div class="icon-con flex-default" @click="updateAddress">
        <div class="m-icon edit" />
      </div>
    </div>
    <template #right>
      <van-button square type="primary" text="删除" class="del-btn" @click="$emit('delete')"/>
    </template>
  </van-swipe-cell>
</template>

<script>
export default {
  props: {
    index: Number,
    itemData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {};
  },
  methods: {
    updateAddress() {
      let query = this.itemData;
      this.$router.push({ name: "add-express-addr", query });
    },
  },
};
</script>

<style lang="less">
.express-addr-list-item-swipe .del-btn {
  height: 100%;
}
.express-addr-list-item-swipe .address-list-item {
  padding: 0 16px;
  // border-bottom: 1px solid #f1f1f1;
  align-items: center;
  .address {
    width: 100%;
    flex-shrink: 1;
    padding: 12px 0 10px;
    .top {
      font-size: 12px;
      color: #aeaeae;
      line-height: 21px;
      .default {
        float: left;
        background: linear-gradient(295deg, #f07c5b 0%, #dd2e41 100%);
        height: 16px;
        // width: 30px;
        border-radius: 2px;
        text-align: center;
        padding: 0 5px;
        margin-top: 2px;
        margin-right: 7px;
        span {
          display: inline-block;
          font-size: 10px;
          // transform: scale(0.9);
          color: #ffffff;
          line-height: 16px;
          height: 16px;
        }
      }
    }
    .center {
      font-size: 13px;
      color: #140603;
      line-height: 18px;
      margin: 2px 0 8px;
      font-weight: bold;
    }
    .bottom {
      .name,
      .phone {
        font-size: 12px;
        color: #aeaeae;
        line-height: 19px;
      }
      .name {
        margin-right: 13px;
      }
    }
  }
  .icon-con {
    flex-shrink: 0;
    height: 100%;
    width: 25px;
    align-items: center;
    justify-content: flex-end;
    .edit {
      width: 14px;
      height: 14px;
      background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABN0lEQVQ4T2NkgILOzk5eNjY2Hhgfmf7////PoqKid9jkGEGCc+YtLmHn4G5hZGBkx6bo759ff79+eSualZX1HiS/YsXmRAZmJoaIUO/5jCCbpWRVX//4+rHhx48ve3C44FteXt41iOYtmQxMDP2M//8HhYf7bmPs7++XFBVXePb+7RPT3NzcM9gMgInBNDP8YwyPiPDeCBIn2gBsmok2AJvmvr4+IVDAEnQBNs1Tp07V5OYRufLu7VNRvAYsX7UlmZGBYSqyn0HOnjx5somgsMzp1y8fSOE1YOXqLcX///67GRHhtwU5cIk2AFeMDDcDUJPyT6xJGT0s2NnZXDl5BOqfPb4tCs5Mc+cuLmXj5G5mYsSemdAN+Pf//89f37/WJifHdoMNAAF82RndADY2ts/Z2dlfQOIA4rbwGXtKDA0AAAAASUVORK5CYII=);
      background-size: 100%;
    }
  }
}
</style>
