<template>
  <view class="user-info">
    <view>
      <uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="">
        <view class="user-info-title">用户名</view>
        <view slot="left"></view>
        <view slot="right">
          <button type="primary" class="user-btn" @click="save">保存</button>
        </view>
      </uni-nav-bar>
    </view>
    <view class="user-contant">
      <text class=""><uni-icons custom-prefix="iconfont" type="icon-required" size="14" color="#F5222D"></uni-icons></text>
      <text class="user-text">请输入新的用户名</text>
    </view>
    <view class="">
      <uni-easyinput maxlength="100" :inputBorder="false" type="textarea" class="user-info-input" v-model="name" placeholder="请输入内容"></uni-easyinput>
    </view>
  </view>
</template>
<script>
import { back, go2, uploadFile } from '@/utils/hook.js'
import { employeeName } from '@/apis/setting.js'
export default {
  data() {
    return {
      name: ''
    }
  },
  onLoad() {
    this.name = this.$store.state.userInfo.name
  },
  methods: {
    back,
    save() {
      if (this.name === '' || this.name === null) {
        uni.showToast({
          title: '请完善信息',
          icon: 'none'
        })
        return
      }
      var params = {
        userId: this.$store.state.userInfo.userId,
        name: this.name,
        enterpriseId: this.$store.state.supplierInfo.id
      }
      employeeName(params).then((res) => {
        if (res) {
          uni.showToast({
            title: '修改成功',
            icon: 'success'
          })
          setTimeout(() => {
            back()
          }, 1000)
        }
      })
    }
  }
}
</script>

<style lang="scss">
.user-info {
  background-color: #ffffff;
  height: 800rpx;
  .user-info-title {
    width: 100%;
    font-size: 36rpx;
    color: #000000;
    letter-spacing: 0;
    text-align: center;
    font-weight: 500;
  }
  .user-btn {
    height: 54rpx;
    background: #007aff;
    border-radius: 27rpx;
    font-size: 28rpx;
    color: #ffffff;
    letter-spacing: 0;
    font-weight: 500;
    line-height: 54rpx;
  }
  .user-text {
    font-size: 28rpx;
    color: #000000;
    letter-spacing: 0;
    font-weight: 500;
  }
  .user-contant {
    margin: 20rpx 32rpx;
  }
  .user-info-input {
    background: #f7f8fa;
    border-radius: 20rpx;
    margin: 10rpx 32rpx 32rpx 32rpx;
    width: 686rpx;
  }
}
</style>
