<template>
	<view class="web_box vflex acenter jbetween">
		<view class="" style="width: 100%;">
			<!-- <u-navbar height="44" leftIcon="arrow-left" leftIconColor="#000" leftText="个人资料" @leftClick="leftClick" :autoBack="true" bgColor="#fff">
			</u-navbar> -->
			<view class="cell hflex acenter jbetween" v-if="active == 0">
				<view class="hflex acenter">
					<view class="label">昵称</view>
					<input type="text" v-model="user_name">
				</view>
			</view>
			<view class="cell hflex acenter jbetween" v-else>
				<view class="hflex acenter">
					<view class="label">工作单位</view>
					<input type="text" v-model="work_units">
				</view>
			</view>
		</view>
		<view class="bottom">
			<u-button @click="save">保存</u-button>
		</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	export default {
		data() {
			return {
				user_name: '',
				work_units: '',
				active: 0
			}
		},
		onLoad(options) {
			var index = options.index
			console.log(index);
			this.active = index
		},
		methods: {
			leftClick() {
			},
			// 保存
			save() {
				var that = this
				var data = {}
				if(that.active == 0) {
					data.user_name = that.user_name
				} else {
					data.work_units = that.work_units
				}
				data = encodeURIComponent(JSON.stringify(data))
				$api.jump('/pages/mine/personal?data=' + data,1)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.web_box::v-deep {
		padding: 0 30rpx;
		
		.u-navbar {
			width: 100%;
			box-sizing: border-box;
			padding: 36px 16px 88rpx 0;
		}
		.cell {
			width: 100%;
			box-sizing: border-box;
			padding: 12rpx 24rpx 12rpx 40rpx;
			margin-top: 20rpx;
			background: #FFFFFF;
			box-shadow: 0px 2px 6px 0px rgba(213,213,213,0.5);
			border-radius: 16rpx;
		}
		.label {
			width: 148rpx;
			font-size: 32rpx;
			font-weight: 400;
			color: #666666;
		}
		.title {
			font-size: 28rpx;
			color: #333333;
		}
		.bottom {
			width: 100%;
			margin-bottom: 152rpx;
		}
		.u-button {
			width: 690rpx;
			height: 68rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			font-size: 28rpx;
			font-weight: 400;
			color: #333333;
		}
	}
</style>