<template>
	<view class="changePwd">
		<u-navbar ref="uNavbar" :border-bottom="false" :back-icon-color="setNav.backColor" :is-back="setNav.isdisPlayNavTitle"
		 :title-size="setNav.size" :title-bold="setNav.bold" :title="setNav.navTitle" :title-color="setNav.color" :background="setNav"></u-navbar>
		 
		 <view class="input">
			 <view class="lable">旧密码</view>
			 <input type="text" v-model="oldPassword" placeholder="请输入旧密码" />
		 </view>
		 <view class="input">
			 <view class="lable">新密码</view>
			 <input type="text" v-model="newPassword" placeholder="请输入新密码" />
		 </view>
		 <view class="input">
			 <view class="lable">再次确认密码</view>
			 <input type="text" v-model="newPassword1" placeholder="请再次输入新密码" />
		 </view>
		 <view class="btn" @click="getQueryList">确认修改</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				setNav: {
					backgroundColor: '#fff', //背景色
					color: '##343434', //字体颜色
					bold: true,
					size: '36',
					backColor: '##343434',
					isdisPlayNavTitle: true, //是否显示返回按钮
					navTitle: '修改密码' //导航标题
				},
				oldPassword: '',
				newPassword: '',
				newPassword1: '',
			}
		},
		onLoad() {
			
		},
		computed: {

		},
		methods: {
			async getQueryList() {
				if (!this.oldPassword) {
					return uni.showToast({
						'title': '请输入旧密码',
						icon: 'none'
					})
				}
				if (!this.newPassword) {
					return uni.showToast({
						'title': '请输入新密码',
						icon: 'none'
					})
				}
				if (!this.newPassword1) {
					return uni.showToast({
						'title': '请再次输入新密码',
						icon: 'none'
					})
				}
				if (this.newPassword != this.newPassword1) {
					return uni.showToast({
						'title': '新密码不匹配',
						icon: 'none'
					})
				}
				let res = await this.$u.put(`system/user/profile/updatePwd?oldPassword=${this.oldPassword}&newPassword=${this.newPassword}`, {
					"oldPassword": this.oldPassword,
					"newPassword": this.newPassword
				})
				console.log(res)
				if (res.code ==500){
					uni.showToast({
						'title': res.msg,
						icon: 'none'
					})
				} else {
					uni.showToast({
						'title': res.msg
					})
					setTimeout(function(){
						uni.navigateBack({
							
						})
					}, 1000)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.changePwd  {
		height: 100%;
		background: #fff;
		.input {
			display: flex;
			align-items: center;
			padding: 22rpx 34rpx;
			font-size: 28rpx;
			font-weight: 500;
			color: #343434;
			input {
				font-size: 28rpx;
				font-weight: 400;
				color: #AAAAAA;
				flex: 1;
				text-align: right;
			}
		}
		.btn {
			width: 90%;
			height: 82rpx;
			background: #009FE8;
			border-radius: 6px;
			margin: 100rpx auto;
			color: #fff;
			text-align: center;
			line-height: 82rpx;
			font-size: 28rpx;
		}
	}
</style>
