<template>
  <view class="body-background"></view>
  <u-navbar
      :title="title"
      :auto-back="true"
      left-icon-size="40rpx"
      :safe-area-inset-top="true"
      :placeholder="true"
      bgColor="#fff"
  ></u-navbar>
  <u-row :custom-style="{padding:'16rpx 26rpx',boxSizing:'border-box'}">
    <u-col :custom-style="{backgroundColor:'#ffffff',borderRadius:'10rpx'}">

        <uni-swipe-action>
        <u-list :height="size.height+'px'">
          <uni-swipe-action-item :right-options="options" v-for="(item,index) in lists">
            <u-list-item>
              <u-cell isLink
                      :border="false"
                      label="rightIcon"
                      :custom-style="{paddingLeft:'14rpx'}"
                      :right-icon-style="{fontSize:'32rpx'}">
                <template #title>
                  <view class="title-container">
                    <view class="title-group row">
                      <view class="title">
                        <u-text :block="true" mode="name" text="张某某" format="encrypt" size="32" color="#020b18"></u-text>
                      </view>
                      <view class="phone">
                        <u-text :block="true" mode="phone" text="15012345678" format="encrypt" size="32" color="#020b18"></u-text>
                      </view>
                    </view>
                    <view class="address">
                      <u-text text="四川省成都市双流区 海昌路168号" size="32" color="#020b18"></u-text>
                    </view>
                  </view>
                </template>
                <template #label>
                  <view class="label-container row">
                    <view class="checkbox">
                      <u-radio-group v-model="value">
                      <u-radio
                          activeColor="#FF9545"
                          :key="index"
                          :name="item.id"
                          size="35"
                          shape="circle"
                          iconSize="30"
                      ></u-radio>
                      </u-radio-group>
                    </view>
                    <view class="title">
                      <u-text text="设为默认地址" size="28" color="#020b18"></u-text>
                    </view>
                  </view>
                </template>
              </u-cell>
            </u-list-item>
          </uni-swipe-action-item>
        </u-list>
      </uni-swipe-action>
    </u-col>
  </u-row>
  <view class="foot-button border-box">
    <u-button
        type="primary"
        text="添加收货地址"
        shape="circle"
        :custom-style="{
              color:'#020B18',
              backgroundColor:'#FF9545',
              border:'none',
              fontSize:'36',
              fontWeight:'400',
              height:'80rpx'
            }"
        @click="navTo('/pages/Address/edit')"
    ></u-button>
  </view>
</template>

<script>
import {
  imghost
} from '@/config/host.js'
import MzSubsection from '@/components/MzSubsection/Index.vue';
import api from '@/utils/functions.js';

export default {
  components: {
    MzSubsection
  },
  data() {
    return {
      value:1,
      options: [
        {
          text: '删除',
          style: {
            backgroundColor: '#FC4956'
          }
        }
      ],
      title: '我的地址',
      loading: true,
      staticImage: {
        bg: imghost + '/static/image/BG.png',
        newIcon: imghost + '/static/image/new-icon.png',
      },
      isTop: false,
      lists: [
        {
          id: 1,
          thumb: imghost + '/static/image/new-1.png',
          title: '全市公安机关夏季治安打击整治“彭安行动”新闻发布会召开',
          desc: '需要您带一点猫砂上门，谢谢',
          time: '2023/06/16',
          is_new: true
        }, {
          id: 2,
          thumb: imghost + '/static/image/new-2.png',
          title: '全市公安机关夏季治安打击整治“彭安行动”新闻发布会召开',
          desc: '需要您带一点猫砂上门，谢谢',
          time: '2023/06/16',
          is_new: true
        }, {
          id: 3,
          thumb: imghost + '/static/image/new-3.png',
          title: '全市公安机关夏季治安打击整治“彭安行动”111开',
          desc: '需要您带一点猫砂上门，谢谢',
          time: '2023/06/16',
          is_new: false
        },
      ],
      size: {
        height: 500,
      },
    }
  },
  onLoad() {

  },
  onReady() {
    let that = this;
    let height = api.wxSystemInfo().system.windowHeight
    let headerHeight = uni.$u.getPx(44) + uni.$u.sys().statusBarHeight
    console.log('headerHeight',headerHeight)

    let info = uni.createSelectorQuery().in(this).select('.foot-button');
    info.boundingClientRect(function (data) {
      that.size.height = that.size.height = height - headerHeight - data.height - uni.$u.getPx('32rpx');
    }).exec(function (res) {});
  },
  computed: {
    api() {
      return api
    },
    sectionStyle() {
      const style = {};
      style.padding = '0 26rpx';
      style.position = 'sticky';
      style.zIndex = '9999';
      style.top = api.navHeight().systemBarHeight + 'px'
      return style;
    },
  },
  methods: {
    chatDetail(item) {
      wx.navigateTo({
        url: '/pages/ChatDetail/index?id=' + item.id
      });
    },
    checkSection(index) {
      this.current = index;
    },
    scrollToLower() {

    },
    navTo(url) {
      wx.navigateTo({
        url: url
      })
    },
  },
  onPageScroll(res) {
    if (res.scrollTop <= 20) {
      uni.$emit('isTop', true);
    } else {
      uni.$emit('isTop', false);
    }
  },
  created() {
    // this.listHeight();
    // this.pagePadding = (api.navHeight().navPaddingTop +
    // 	api.navHeight().navHeight + (api.navHeight().headerPadding * 2))
  }
}
</script>

<style lang="scss">
@import './components/index.scss';
</style>