<template>
	<view>
		<form @submit="formSubmit" @reset="formReset">
		<view class="form-list">
			<template>
				<view class="form-item">
					<view class="item-name">{{$t('MN_F_28')}}</view>
					<input v-model="form.oldPassword" type="password" value="" :placeholder="$t('w_0348')" placeholder-class="placeholderclass gray9 f28" password class="form-input" />
				</view>
				<view class="form-tips"></view>
			</template>
			<template>
				<view class="form-item">
					<view class="item-name">{{$t('MN_F_29')}}</view>
					<input v-model="form.payPassword" type="password" value="" :placeholder="$t('w_0048')" placeholder-class="placeholderclass gray9 f28" password class="form-input" />
				</view>
				<view class="form-tips">{{ $t('PER_DA_42') }}</view>
			</template>
			<template>
				<view class="form-item">
					<view class="item-name">{{$t('w_0050')}}</view>
					<input v-model="form.confirmPassword" value="" :placeholder="$t('w_0332')" placeholder-class="placeholderclass gray9 f28" password class="form-input" />
				</view>
				<view class="form-tips">{{ $t('PER_DA_42') }}</view>
			</template>
		</view>
		<view class="normal-sub-btn "><button form-type="submit" class="f32 mt60 normal-sub-btn">{{$t('w_0035')}}</button></view>
		</form>
	</view>
</template>

<script>
export default {
	data() {
		return {
			form: {
				// loginPassword: '',
				oldPassword: '',
				confirmPassword: '',
				payPassword:''
			}
		};
	},
	methods: {
		/*提交*/
		formSubmit: function(e) {
			let self = this;
			var formdata = self.form;
			if (formdata.oldPassword == '') {
				uni.showToast({
					title: self.$t('w_0348'),
					duration: 1000,
					icon: 'none'
				});
				return false;
			}
		
			if (formdata.payPassword == '') {
				uni.showToast({
					title:  self.$t('w_0048'),
					duration: 1000,
					icon: 'none'
				});
				return false;
			}
		
			if (formdata.payPassword != formdata.confirmPassword) {
				uni.showToast({
					title: self.$t('MN_F_35'),
					duration: 1000,
					icon: 'none'
				});
				return false;
			}
		
			self._putjson('member/api/member/update-password', formdata, function(res) {
				self.showSuccess(res.msg, function() {
					// #ifndef H5
					uni.navigateBack({
						delta: parseInt(self.delta)
					});
					// #endif
					// #ifdef H5
					history.go(-self.delta);
					// #endif
				});
			});
		},
	}
};
</script>

<style lang="scss">
.form-list {
	padding: 49rpx 58rpx 37rpx 52rpx;
	background-color: #ffffff;
	margin-bottom: 57rpx;
	.form-item {
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		color: #333;
		.item-name {
			width: 180rpx;
		}
		.form-input {
			flex: 1;
			height: 76rpx;
			line-height: 76rpx;
			border-radius: 38rpx;
			font-size: 28rpx;
			color: #333;
			background: #f5f6f8;
			padding: 0 20rpx 0 51rpx;
		}
	}
	.form-tips {
		color: #fb3024;
		line-height: 60rpx;
		min-height: 56rpx;
		padding-left: 180rpx;
	}
}

.placeholderclass {
}
</style>
