<template>
  <div class="formConfirm">
    <div class="list-content">
      <div class="item">
        <span class="tips">*</span>
        <div class="item-border">
          <div class="label">户主姓名</div>
          <div class="value">
            <u-input type="text" class="right" placeholder="请输入" height="44" input-align="right" v-model="info.name"></u-input>
          </div>
        </div>
      </div>
      <div class="item">
        <span class="tips">*</span>
        <div class="item-border">
          <div class="label">性别</div>
          <div class="value" @click="showSex=true">
            <span :class="info.sex == null ? 'color-999' : ''">{{ $dict.getLabel('sex', info.sex) || '请选择'}}</span>
            <img src="./img/arrow-right.png" alt="">
          </div>
        </div>
      </div>
      <div class="item">
        <span class="tips">*</span>
        <div class="item-border">
          <div class="label">联系电话</div>
          <div class="value">
            <u-input type="text" class="right" placeholder="请输入" height="44" input-align="right" v-model="info.phone"></u-input>
          </div>
        </div>
      </div>
      <div class="item">
        <span class="tips">*</span>
        <div class="item-border">
          <div class="label">出生日期</div>
          <div class="value" @click="showDate=true">
            <span :class="info.birthday == null ? 'color-999' : ''">{{ info.birthday || '请选择'}}</span>
            <img src="./img/arrow-right.png" alt="">
          </div>
        </div>
      </div>
      <div class="item">
        <span class="tips">*</span>
        <div class="item-border">
          <div class="label">民族</div>
          <div class="value"  @click="showNation=true">
            <span :class="info.nation == null ? 'color-999' : ''">{{ $dict.getLabel('nation', info.nation) || '请选择'}}</span>
            <img src="./img/arrow-right.png" alt="">
          </div>
        </div>
      </div>
      <div class="item">
        <span class="tips">*</span>
        <div class="item-border">
          <div class="label">家庭人口数</div>
          <div class="value">
            <u-input type="text" class="right" placeholder="请输入" height="44" input-align="right" v-model="info.householdNumber"></u-input>
          </div>
        </div>
      </div>
      <div class="item">
        <span class="tips">*</span>
        <div class="text-label">
          <div class="label">我要上报的事情</div>
        </div>
        <div class="text-value">
          <u-input type="textarea" placeholder="请输入" :height="300" input-align="left" v-model="info.reportThing" :clearable="false" maxlength="500"></u-input>
        </div>
      </div>
    </div>
    <div class="bottom-btn">
      <!-- <div class="confirm" @click="confirm('保存成功')">保存内容</div> -->
      <div class="confirm" @click="confirm('提交成功')">提交</div>
      <div class="cancel" @click="back">返回录制</div>
    </div>
    <u-picker mode="time" v-model="showDate" :params="deteParams" start-year="1930" @confirm="dateConfirm">请选择</u-picker>
    <u-select v-model="showSex" :list="$dict.getDict('sex')" label-name="dictName" value-name="dictValue" @confirm="confirmSex"/>
    <u-select v-model="showNation" :list="$dict.getDict('nation')" label-name="dictName" value-name="dictValue" @confirm="confirmNation"/>
  </div>
</template>

<script>
import {mapState} from "vuex";

export default {
  name: 'formConfirm',
  data() {
    return {
      word: '',
      info: {},
      showSex: false,
      showNation: false,
      showDate: false,
      deteParams: {year: true, month: true, day: true, hour: false, minute: false, second: false},
    }
  },
  computed: {
    ...mapState(['user']),
  },
  onLoad(option) {
    this.info = JSON.parse(option.info)
    this.$dict.load('sex', 'nation').then(() => {
      // this.getInfo()
    })
  },
  onShow() {
    document.title = '婚姻家庭纠纷入户登记表'
  },
  methods: {
    getInfo() {
      uni.showLoading({title: '读取中'})
      this.$http.post(`/app/appbaiduai/queryByInfo?word=${this.word}`).then((res) => {
        if (res.code === 0) {
          this.info = {...res.data}
          uni.hideLoading()
        }
      }).catch(res => {
        this.$u.toast(res)
        uni.hideLoading()
      })
    },
    confirmSex(e) {
      this.info.sex = e[0].value
    },
    confirmNation(e) {
      this.info.nation = e[0].value
    },
    dateConfirm(e) {
      this.info.birthday = `${e.year}-${e.month}-${e.day}`
    },
    confirm(successText) {
      // if(this.info.name == null || !this.info.name) {
      //   return this.$u.toast('请输入户主姓名')
      // }
      // if(this.info.sex == null) {
      //   return this.$u.toast('请选择性别')
      // }
      // if(this.info.phone == null || !this.info.phone) {
      //   return this.$u.toast('请输入联系电话')
      // }
      // if(this.info.birthday == null) {
      //   return this.$u.toast('请选择出生日期')
      // }
      // if(this.info.nation == null) {
      //   return this.$u.toast('请选择民族')
      // }
      // if(this.info.householdNumber == null || !this.info.householdNumber) {
      //   return this.$u.toast('请输入家庭人口数')
      // }
      // this.showModel = true
      this.$confirm('已流转到城管部门处理', '上报成功').then(() => {
        this.back()
      })
    },
    back() {
      uni.navigateBack({delta: 2})
    }
  },
}
</script>

<style lang="scss" scoped>
uni-page-body {
  min-height: 100%;
  // height: 100vh;
  background: #F5F5F5;
}
.formConfirm {
  .list-content {
    padding-bottom: 328px;
    .item {
      padding-left: 32px;
      position: relative;
      margin-bottom: 16px;
      background-color: #fff;
      .tips {
        position: absolute;
        top: 34px;
        left: 8px;
        font-family: PingFangSC-Regular;
        font-size: 32px;
        color: #F46;
      }
      .label {
        font-family: PingFangSC-Regular;
        font-size: 32px;
        color: #333;
        line-height: 44px;
        width: 240px;
      }
      .item-border {
        padding: 34px 32px 34px 0;
        width: 100%;
        box-sizing: border-box;
        border-bottom: 1px solid #D8DDE6;
        display: flex;
        .value {
          width: calc(100% - 240px);
          text-align: right;
          .u-input {
            display: inline-block;
            width: calc(100% - 40px);
            vertical-align: sub;
          }
          img {
            display: inline-block;
            width: 32px;
            height: 32px;
            margin-left: 8px;
            vertical-align: middle;
          }
          .color-999 {
            color: rgb(192, 196, 204);
          }
        }
      }
      .text-label {
        padding: 34px 32px 34px 0;
      }
      .text-value {
        padding-right: 32px;
        ::v-deep .uni-textarea-textarea{
          font-size: 28px;
        }
      }
    }
  }
  .bottom-btn {
    position: fixed;
    bottom: 0;
    left: 0;
    background-color: #F5F5F5;
    div {
      margin-left: 32px;
      width: 686px;
      height: 88px;
      border-radius: 44px;
      font-family: PingFangSC-Medium;
      font-weight: 500;
      font-size: 34px;
      text-align: center;
      line-height: 86px;
      margin-bottom: 32px;
    }
    .confirm {
      background: #3975C6;
      color: #fff;
    }
    .cancel {
      color: #666;
      border: 1px solid #CCC;
    }
  }
  ::v-deep .u-input__right-icon {
    display: none;
  }
}
</style>
