<template>
  <div class="AddTag">
    <u-navbar back-icon-color="#000" title="居民标签管理" title-color="#000" title-width="300" title-size="32" 
        :title-bold="true" :background="backgroundNavbar" :is-fixed="true" height="44" z-index="999"></u-navbar>
    <div class="header-content-bg">
      <img src="https://cdn.sinoecare.com/i/2024/07/12/6690a1303d423.png" alt="">
    </div>
    <div class="list-content">
      <div class="item">
        <span class="tips">*</span>
        <div class="label">标签</div>
        <div class="value">
          <u-input v-model="labelName" input-align="right" height="44" placeholder="请输入..." maxlength="32" />
        </div>
      </div>
      <!-- <div class="item">
        <span class="tips">*</span>
        <div class="label">标签</div>
        <div class="value">
          <u-input v-model="text" input-align="right" height="44" placeholder="请输入..." />
        </div>
      </div>
      <div class="item">
        <span class="tips">*</span>
        <div class="label">标签</div>
        <div class="value">
          <u-input v-model="text" input-align="right" height="44" placeholder="请输入..." />
        </div>
      </div> -->
    </div>
    <!-- <div class="add-btn">
      <img src="https://cdn.sinoecare.com/i/2024/07/16/669618fc80480.png" alt="">
    </div> -->
    


    
    <!-- <AiEmpty class="emptyWrap" v-else></AiEmpty> -->
    <div class="footer" @click="confirm">
      <div class="btn">保存</div>
    </div>

  </div>
</template>

<script>
import {mapState} from 'vuex'

export default {
  name: 'AddTag',
  labelName: '居民标签管理',
  customNavigation: true,
  data() {
    return {
      backgroundNavbar: {
        background: 'url(https://cdn.sinoecare.com/i/2024/07/12/6690a1309c7d3.png) no-repeat',
        backgroundSize: 'cover',
      },
      labelName: '',
      id: ''
    }
  },
  computed: {
    ...mapState(['user']),
  },
  onLoad(e) {
    this.id = e.id || ''
    if(this.id) {
      this.getDetail()
    }
  },
  onShow() {
    uni.setNavigationBarColor({
      frontColor: 'black',
      backgroundColor: '#ffffff'
    })
  },
  methods: {
    getDetail() {
      this.$instance.post(`/app/appresidentlabelinfo/queryDetailById?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.labelName = res.data.labelName
        }
      })
    },
    confirm() {
      this.$instance.post(`/app/appresidentlabelinfo/addOrUpdate`, {id: this.id, labelName: this.labelName}).then((res) => {
        if (res.code == 0) {
          this.$u.toast(this.id ? '编辑成功!' : '新增成功!')
          setTimeout(()=> {
            uni.navigateBack()
            uni.$emit('updateTag')
          }, 600)
        }
      })
    }
    
  },
}
</script>

<style scoped lang="scss">
.AddTag {
  height: 100%;
  .header-content-bg {
    width: 100%;
    position: fixed;
    img {
      width: 100%;
      height: 592px;
    }
  }
  .list-content {
    padding: 16px 0 220px 0;
    .item {
      width: calc(100% - 64px);
      background-color: #fff;
      margin-left: 32px;
      padding: 34px 32px;
      box-sizing: border-box;
      position: relative;
      border-bottom: 1px solid #eee;
      .tips {
        position: absolute;
        top: 40px;
        left: 14px;
        font-family: PingFangSC-Regular;
        font-weight: 400;
        font-size: 32px;
        color: #F46;
      }
      .label {
        display: inline-block;
        width: 176px;
        line-height: 44px;
        font-family: PingFangSC-Regular;
        font-weight: 400;
        font-size: 32px;
        color: #333;
      }
      .value {
        display: inline-block;
        width: calc(100% - 176px);
      }
    }
    .item:nth-of-type(1) {
      border-top-left-radius: 16px;
      border-top-right-radius: 16px;
    }
    .item:nth-last-of-type(1) {
      border-bottom-left-radius: 16px;
      border-bottom-right-radius: 16px;
      border-bottom: none;
    }
  }
  .add-btn {
    position: fixed;
    bottom: 300px;
    right: 0;
    z-index: 9;
    padding: 30px;
    img {
      width: 104px;
      height: 104px;
    }
  }
  .footer {
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    background-color: #F4F5FA;
    padding: 64px 64px 68px 64px;
    z-index: 9;
    .btn {
      width: calc(100% - 128px);
      line-height: 88px;
      background: #026AF2;
      border-radius: 44px;
      font-family: PingFangSC-Medium;
      font-weight: 500;
      font-size: 34px;
      color: #FFF;
      text-align: center;
    }
  }
}
</style>
