<template>
	<view class="modifypwd">
		<u-navbar
		 title="修改密码" 
		 title-color="#fff" 
		 :custom-back="customBack" 
		 :border-bottom="false" 
		 back-icon-color="#CCE8FF" 
		 :background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"></u-navbar>
		<u-form :model="form" ref="uForm">
			<u-form-item class="u-m-t-40 u-m-b-40" label="原密码：" label-width="180rpx">
				<u-input v-model="form.oldPassword" placeholder="请输入原密码"/>
			</u-form-item>
			<u-form-item label="新密码：" label-width="180rpx">
				<u-input v-model="form.newPassword" placeholder="请输入新密码" />
			</u-form-item>
			<u-form-item label="确认新密码：" label-width="180rpx">
				<u-input v-model="form.confirmPassword" placeholder="请再次输入新密码"/>
			</u-form-item>
		</u-form>
		<u-button class="submit-btn" @click="submit">确认修改</u-button>
		
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default{
		data(){
			return{
				form:{
					oldPassword:null,
					newPassword:null,
					confirmPassword:null,
				}
			}
		},
		onLoad(){
			
		},
		methods:{
			customBack(){
				// this.$u.route({
				// 	// type:'switchTab',
				// 	url: 'pages/setting/setting'
				// });
				uni.navigateBack({
				    delta: 1
				});
			},
			submit(){
				let param = {
					oldPassword:this.form.oldPassword,
					newPassword:this.form.newPassword,
					confirmPassword:this.form.confirmPassword
				};
				this.$u.api.modifyPwd(param)
				.then(res=>{
					plus.nativeUI.toast('密码修改成功');
					uni.reLaunch({
					    url: '/pages/login/login'
					});
				}).catch(err=>{
					this.$refs.uToast.show({
						title: err.msg,
						type: 'error',
					});

				});
			}
			
		}
	}
</script>

<style lang="scss">
	@import "./modifypwd.scss";
</style>
