<template>
	<view class="content">
		<view class="line">
			<view class="input-label">新密码</view>
			<view>
				<input type="password" v-model="userPwd1" class="input-field" placeholder="请输入新密码"/>
			</view>
		</view>
		<view class="line">
			<view class="input-label">新密码</view>
			<view>
				<input class="input-field" v-model="userPwd2" type="password" placeholder="请再次输入新密码"/>
			</view>
		</view>
		<view class="submit" @click="submitFn">提交</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userPwd1: '',
				userPwd2:'',
				userId:'',
			}
		},
		onLoad() {
          this.userId=uni.getStorageSync('loginInfo').userId
		},
		methods: {
          submitFn(){
			  if(this.userPwd2!=this.userPwd1){
				  uni.showToast({
				    icon: 'none',
				    title: '俩次密码不一致',
				    duration: 3000
				  });
				  return false
			  }
			  this.$http('imSys/changePwd', {
			     userId:this.userId,
				 userPwd:this.userPwd1
			    },'POST').then(res => {
					if(res.code==0){
						uni.showToast({
						  icon: 'none',
						  title: '修改成功',
						  duration: 3000
						});
						setTimeout(function() {
							uni.navigateBack(-1)
						}, 1000);
					
						/* uni.navigateTo({
											 url: './login'
						}) */
					}else{
						uni.showToast({
						  icon: 'none',
						  title: res.msg,
						  duration: 3000
						});
					}
					
			    }) 
		  }
		}
	}
</script>

<style>
	
	.submit{
		width: 650rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		background: #3F90F7;
		color: #ffffff;
		font-size: 30rpx;
		border-radius: 10rpx;
		position: fixed;
		bottom: 100rpx;
		left: 50rpx;
	}
	.line{
		display: flex;
		padding: 30rpx 20rpx;
		border-bottom: 1px solid #eee;
		color: #333333;
	}
	.input-field{
		padding-left: 50rpx;
	}
</style>
