<template>
	<view class="bocx">
		<view class="box-che">
			<input v-model="name" class="box-input" placeholder-class="inpTextBox" type="text" placeholder="请输入" maxlength="15" />
		</view>
		<view  class="nic">请输入签名 (不超过15个字)</view>
		<view class="cev" @click="saveName()">保存</view>
	</view>
</template>

<script>
	var app = getApp();
	var util = require("../../utils/util.js");
	var config = require("../../config");

	export default {
		data() {
			return {
				name: "",
			};
		},
		onLoad: function(options) {
			var userInfos = uni.getStorageSync('weapp_session_userInfo_data');
			this.name=userInfos.personalProfile;
		},
		methods: {
			saveName() {
			  var userInfos = uni.getStorageSync('weapp_session_userInfo_data');
			  if (this.name == "") {
			    uni.showModal({
			      title: '提示',
			      content: '签名不能为空',
			      showCancel: false
			    });
			  } else {
			    util.getRequestPromise(config.service.upload, {
			      personalProfile: this.name
			    }).then(data => {
	
			      userInfos.personalProfile = this.name;
				  
			      uni.setStorageSync('weapp_session_userInfo_data', userInfos); //写入缓存
			      uni.navigateBack({
			        delta: 1
			      });
				  
			    });
			  }
			}
		}
	};
</script>
<style>
	.bocx{
		width: 100%;
		height: 100vh;
		background-color: #F8F8F8;
	}
	.box-che{
		width: 100%;
		height: 102rpx;
		background: #FFFFFF;
		margin-top: 20rpx;
	}
	.box-input{
		width: 90%;
		height: 100%;
		line-height: 102rpx;
		border: none;
		margin-left: 30rpx;
		font-size: 30rpx;
		color: #303030;
	}
	.nic{
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		line-height: 24rpx;
		margin-left: 30rpx;
		margin-top: 20rpx;
	}
	.inpTextBox {
		width: 90%;
		height: 100%;
		line-height: 102rpx;
		border: none;
		font-size: 30rpx;
		color: #B2B2B2;
	}
	.cev{
		width: 690rpx;
		height: 88rpx;
		background: #2671E2;
		border-radius: 8rpx;
		text-align: center;
		line-height: 88rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		margin: 0 auto;
		margin-top: 220rpx;
	}
</style>