<template>
	<view class="">
		<view class="body">
			归属人：{{name}}
		</view>
		<form @submit="updata">
			<view class="body">
				登录名：<input class="input" name="userName" :value=username />
			</view>
			<view class="body">
				旧密码：<input class="input" password name="oldPassword" />
			</view>
			<view class="body">
				新密码：<input class="input" password name="password" />
			</view>
			<view class="body">
				确认密码：<input class="input" password name="password1" />
			</view>
			<view class="">
				<button type="primary" formType="submit" class="button">
					<p class="p">提交</p>
				</button>
			</view>
		</form>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from 'vuex'

	export default {

		data() {
			return {
				name: '',
				username: "",
				parm: {
					name: null,
					id: null
				},

			};
		},
		onPullDownRefresh() {},
		onShow() {
			var token = uni.getStorageSync("token");
			if (token.length > 1) {
				var name = uni.getStorageSync("name");
				this.name = name;
				this.username = uni.getStorageSync("globalUser").userName;
			} else {
				uni.reLaunch({
					url: '../Login/Login',
				});
			}
		},
		onLoad() {

		},
		methods: {
			// ...mapActions('chart', ['updata']),
			updata(event) {
				const {
					value: user
				} = event.detail;
				var password = user.password;
				var password1 = user.password1;
				if (password != password1) {
					uni.showModal({
						title: '提示',
						content: '两次输入密码不一致',
					});
					return null;
				}
				this.$store.dispatch('updataPassword', user).then(_ => {
						uni.showModal({
							title: '提示',
							content: _.message,
							success: function(res) {
								uni.navigateTo({
									url: '/pages/Login/Login',
								});
							}
						});

					});

			},
		}
	}
</script>

<style>
	.body {
		background-color: #FFFFFF;
		padding: 20upx 20upx 20upx 20upx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
	}

	.input {
		/* padding: 10upx 20upx 10upx 0upx; */
		padding-left: 20upx;
		padding-top: 10upx;
		background-color: #FFFFFF;
		width: 500upx;
		height: 50upx;
		box-shadow: 0upx 0upx 20upx #D3D3D3;
		border-radius: 5upx;
	}

	.button {
		margin: auto;
		width: 60%;
		height: 100upx;
	}

	.p {
		/* #ifdef H5 */
		top: -13%;
		/* #endif */
		width: 80upx;
		height: 60upx;
		font-size: 40upx;
		padding-top: 6upx;
		/* #ifndef H5 */
		padding-top: 10upx;
		/* #endif */

		position: absolute;
		/* 水平居中 */
		left: 50%;
		-webkit-transform: translateX(-50%);
		transform: translateX(-50%);
	}
</style>
