<template>
	<view>
		<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:{
			submit(){
				let param = {
					oldPassword:this.form.oldPassword,
					newPassword:this.form.newPassword,
					confirmPassword:this.form.confirmPassword
				};
				this.$u.api.modifyPwd(param)
				.then(res=>{
					this.$refs.uToast.show({
						title: res.msg,
						type: 'success',
						url:'pages/index/index'
					});
					console.log('modifyPwd',res)
				}).catch(err=>{
					this.$refs.uToast.show({
						title: err.msg,
						type: 'error',
					});
					console.log('modifyPwd ',err)
				});
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	page{background-color: #F4F4F4;}
	.u-form-item{background-color: #fff;padding-left: 40rpx;padding-right: 40rpx;}
	.submit-btn{background-color: #3397FA;color: #fff;border: 0;margin: 274rpx 40rpx 40rpx;}
	// @import "./modifypwd.scss";
</style>
