<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'}">
    <u-col :custom-style="{backgroundColor:'#ffffff',borderRadius:'10rpx',padding:'30rpx 40rpx'}">
      <u-form
          labelPosition="left"
          :model="model1"
          :rules="rules"
          ref="form1"
          labelWidth="200rpx"
      >
        <u-form-item
            :custom-style="{
                  padding:'36rpx 0'
              }"
            label="姓名"
            prop="userInfo.name"
            borderBottom
            ref="item1"
        >
          <u-input
              fontSize="28"
              placeholder="请填写您的真实姓名"
              v-model="model1.userInfo.name"
              border="none"
          ></u-input>
        </u-form-item>
        <u-form-item
            :custom-style="{
                  padding:'36rpx 0'
              }"
            label="手机号码"
            prop="userInfo.name"
            borderBottom
            ref="item1"
        >
          <u-input
              fontSize="28"
              placeholder="请输入"
              v-model="model1.userInfo.name"
              border="none"
          ></u-input>
        </u-form-item>
        <u-form-item
            :custom-style="{
                  padding:'36rpx 0'
              }"
            label="地区"
            prop="userInfo.name"
            borderBottom
            ref="item1"
        >
          <u-input
              fontSize="28"
              placeholder="请选择地区"
              v-model="model1.userInfo.name"
              border="none"
          ></u-input>
        </u-form-item>
        <u-form-item
            :custom-style="{
                  padding:'36rpx 0'
              }"
            label="详细地址"
            prop="userInfo.name"
            borderBottom
            ref="item1"
        >
          <u-input
              fontSize="28"
              placeholder="请输入详细收货地址"
              v-model="model1.userInfo.name"
              border="none"
          ></u-input>
        </u-form-item>
        <u-form-item
            :custom-style="{
                  padding:'36rpx 0'
              }"
            label="设为默认收货地址"
            prop="userInfo.name"
            labelWidth="260rpx"
            ref="item1"
        >
          <u-switch
              size="32"
              :custom-style="{marginLeft:'auto'}"
              v-model="switchValue"
              activeColor="#FF9545"
              inactiveColor="#DDDDDD"
          >

          </u-switch>
        </u-form-item>

      </u-form>
    </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="uni.navigateTo({url:'/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 {
      switchValue:false,
      model1: {
        userInfo: {
          name: '',
          sex: 1,
        },
      },
      rules: {
        'userInfo.name': {
          type: 'string',
          required: true,
          message: '请填写姓名',
          trigger: ['blur', 'change']
        },
        'userInfo.sex': {
          type: 'string',
          max: 1,
          required: true,
          message: '请选择男或女',
          trigger: ['blur', 'change']
        },
      },
      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() {

  },
  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;
    },
    listHeight() {
      let that = this;
      let height;
      let info = uni.createSelectorQuery().in(this).select('.subsection');
      info.boundingClientRect(function (data) {
        that.size.height = data.height;
      }).exec(function (res) {

      });
      // that.size.height = (api.navHeight().windowHeight - height);
    }
  },
  methods: {
    chatDetail(item) {
      wx.navigateTo({
        url: '/pages/ChatDetail/index?id=' + item.id
      });
    },
    checkSection(index) {
      this.current = index;
    },
    scrollToLower() {

    },
  },
  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/edit.scss';
</style>