<template>
    <view>
        <cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">
				用户名
			</block>
            <block slot="right"></block>
            <block slot="right">
				<view class="text-main font-32" style="padding-right:35rpx;" @tap="save()">完成</view>
			</block>
 		</cu-custom>

         <view class="box">
             <view class="name flex align-end ">
                 <u-input v-model="name" placeholder="请输入用户名" class="flex-sub" maxlength="16"/>
             </view>
             <view style="padding-left:4rpx;margin-top:25rpx;" class="color-99 text-sm">注：字数限6-16个字符。</view>
         </view>
    </view>
</template>
<script>
export default {
components: {},
   data() {
      return {
          name: "",
          id: "",
      }
   },
 watch: {
},
// 接收 上个页面传递过来的参数
onLoad(option) {
    if(option.name != 'null' && option.name != 'undefined' && option.name != null && option.name != undefined && option.name != ''){
      this.name = option.name;
    }
    this.id = option.id;
    // this.id = option.id;
},
created(){
},
mounted(){
},
methods:{
    save() {
        if(this.name.length<6||this.name.length>16) {
            this.$api.msg("字数限6-16个字符")
            return
        }
        this.$u.api.updateUserInfo({serverId: this.id,nikeName:this.name}).then(res => {
          if (res.code === 200) {
            uni.navigateTo({
              url: '../main/main'
            })
          }
        })

      // uni.navigateBack({
      //     delta: 1
      // });
    }
}


}
</script>
<style lang='scss' scoped>
page {
    background: #fff;
}
.box {
    padding: 0 35rpx;
    border-top: 2rpx solid #eee;
}
.name {
    height: 106rpx;
    border-bottom: 2rpx solid #eee;
}
/deep/ .uni-input-input {
    font-weight: bold;
}
</style>

