<template>
  <div class="editIntegral">
    <div class="item">
      <div class="title"><span>*</span>学习强国</div>
      <div class="inp">
        <u-input v-model="learningIntegral" placeholder="请输入学习强国积分" :type="number" clearable maxlength="10" />
      </div>
    </div>

    <div class="btn">
      <div class="submitBtn" @click="submit">提交</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'editIntegral',
  appName: '修改学习强国',
  data() {
    return {
      learningIntegral: '',
      partyMemberId: '',
      flag: false,
    }
  },
  onLoad(o) {
    this.partyMemberId = o.partyMemberId
    this.getIntegral()
  },
  methods: {
    getIntegral() {
      this.$instance.post('/app/appparty/getPartyIntegralDetail',null,{
        params: {
          id: this.partyMemberId,
        }
      }).then((res) => {
        if(res?.data) {
          this.learningIntegral = res.data.learningIntegral
        }
      })
    },
    submit() {
      if(this.flag) return
      if(!this.learningIntegral) {
        return this.$u.toast('请输入学习强国积分')
      }
      this.flag = true
      this.$instance.post('/app/appparty/editLearningIntegral',null,{
        params: {
          partyMemberId: this.partyMemberId,
          learningIntegral: this.learningIntegral,
        }
      }).then((res) => {
        if (res.code == 0) {
          this.$u.toast('修改成功')
          setTimeout(() => {
            uni.$emit('update')
            uni.navigateBack()
          },600)
        }
      })
    }
  },

}
</script>

<style lang="scss" scoped>
.editIntegral {
  background: #F3F4F5;
  .item {
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    padding: 30px 30px;
    background: #FFF;
    .title {
      width: 200px;
      height: 76px;
      line-height: 76px;
      span {
        color:#FF4466;
      }
    }

    .inp {
      width: calc(100% - 200px);
      ::v-deep .u-input .u-input__input {
        text-align: right;
      }
    }
  }
  .btn {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    padding: 16px 32px;
    box-sizing: border-box;
    display: flex;
    background: #F3F6F9;
    .submitBtn {
      flex: 1;
      height: 88px;
      line-height: 88px;
      text-align: center;
      color: #FFF;
      background: #4181FF;
      border-radius: 16px;
    }
  }
}
</style>