<template>
	<view>
		<view class="fllow_form">
			<view><text>*</text>旧密码</view>
			<view class="form_right">
				<input type="password" v-model="oldpassword" placeholder="请输入旧密码" class="rightinput" :class="oldpassword ? 'valueActive' : '' ">
				<view class="iconfont icon-arrows_right"></view>
			</view>
		</view>
		<view class="fllow_form">
			<view><text>*</text>新密码</view>
			<view class="form_right">
				<input type="password" v-model="newpassword" placeholder="请输入新密码" class="rightinput" :class="newpassword ? 'valueActive' : '' ">
				<view class="iconfont icon-arrows_right"></view>
			</view>
		</view>
		<view class="fllow_form">
			<view><text>*</text>确认新密码</view>
			<view class="form_right">
				<input type="password" v-model="renewpassword" placeholder="请确认新密码" class="rightinput" :class="renewpassword ? 'valueActive' : '' ">
				<view class="iconfont icon-arrows_right"></view>
			</view>
		</view>
		
		<view id="btn" class="btn_g bg-blue button-hover round" @click="$noMultipleClicks(subSave)">
			保存
		</view>
	</view>
</template>

<script>
	import { netEditPassword } from '@/api/login.js'
	
	export default{
		data() {
			return{
				noClick:true,    //防止  重复点击
				oldpassword:'',
				newpassword:'',
				renewpassword:'',
			}
		},
		methods:{
			subSave() {
				if(!this.oldpassword){
					uni.showToast({
						title:'请输入旧密码',
						icon:'none'
					})
					return
				}
				if(!this.newpassword){
					uni.showToast({
						title:'请输入新密码',
						icon:'none'
					})
					return
				}
				if(!this.renewpassword){
					uni.showToast({
						title:'请确认新密码',
						icon:'none'
					})
					return
				}
				let params = {
					oldpassword:this.oldpassword,
					newpassword:this.newpassword,
					renewpassword:this.renewpassword
				}
				netEditPassword(params).then(res=>{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
					setTimeout(()=>{
						uni.redirectTo({
							url:'/pages/profile/profile'
						})
					},2000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fllow_form {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
		border-bottom: 1rpx solid #EAEAEA;
		padding: 30rpx 20rpx;
		color: #999;
		font-size: 32rpx;
		.form_right {
			display: flex;
			align-items: center;
			color: #999;
			:first-child {
				width: 450rpx;
				text-align: right;
			}
			image {
				width: 40rpx;
				height: 40rpx;
				margin: 28rpx 5rpx 0 0;
			}
		}
		.theme {
			color: #5ca9fe;
		}
		text {
			color: #f00;
			margin-left: 10rpx;
		}
		.form_input {
			input {
				text-align: right;
				margin-right: 10rpx;
			}
		}
	}
</style>
