<template>
  <div
    class="address-display"
    @click="toAddress"
  >
    <div class="address-top">
      <div class="icon-position"></div>
      <div class="address-content" >
        <div class="address-none"  v-if="waybillAddress.length === 0 && !onlyShow">新建收货地址</div>
         <!-- 用户地址 -->
        <template v-if="!onlyShow">
          <div class="user-info" v-if="waybillAddress.length">
            <span>{{waybillAddress[0].consigneeName}}</span>
            <span class="spacing">{{waybillAddress[0].consigneeMobile}}</span>
          </div>
          <div class="address-info" v-if="waybillAddress.length">
            <span>{{waybillAddress[0].address}}&nbsp;&nbsp;&nbsp;&nbsp;{{waybillAddress[0].detailAddress}}</span>
            <!-- <span class="spacing">{{waybillAddress[0].detailAddress}}</span> -->
          </div>
        </template>
        <!-- 门店地址 -->
        <template v-else>
          <div class="user-info">
            <span>门店地址:</span>
            <span class="spacing"></span>
          </div>
          <div class="address-info">
            <span>{{storeAddress.address}}</span>
            <span class="spacing">{{ storeAddress.name }}</span>
          </div>
        </template>
      </div>

      <!-- #ifndef MP-TOUTIAO -->
      <div class="icon-right-arrow" v-if="!onlyShow"></div>
      <!-- #endif -->

      <!-- #ifdef MP-TOUTIAO -->
      <div class="icon-right-arrow" v-if="!storeAddress"></div>
      <!-- #endif -->
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { jumpPage } from "@/utils/uniapi.js";
export default {
  props: {
    waybillAddress: {
      type: Array,
      default: []
    },
    storeAddress: {
      type: Object,
      default:{}
    },
    onlyShow: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
    }
  },
  computed: {
    ...mapGetters({
      addressList: "addressVue/addressList"
    })
  },
  methods: {
    toAddress() {
      if (this.onlyShow) return false
      jumpPage('navigateTo','/pagesAddress/mine-address/index')
    }
  }
}
</script>

<style lang="scss">
@import "./address-display.scss";
</style>