<template>
	<view>
		<u-navbar
			:title="$t('page.setting.updatePayPassword.title')"
			:safeAreaInsetTop="false"
			placeholder
			@leftClick="leftClick"
			>
		</u-navbar>
		
		<u--form
		labelPosition="left"
		:model="model1"
		:rules="rules"
		class="line"
		ref="uForm"
		>
			
			<u-form-item
			:label="$t('page.setting.updatePayPassword.OldPassword')"
			prop="payPass"
			borderBottom
			labelWidth="80px"
			>
				<u--input
				v-model="model1.payPass"
				type="password"
				:placeholder="$t('page.setting.updatePayPassword.OldPassword-Placeholder')"
				></u--input>
			</u-form-item>
			
			<u-form-item
			:label="$t('page.setting.updatePayPassword.newPassword')"
			prop="newPass"
			borderBottom
			labelWidth="80px"
			>
				<u--input
				v-model="model1.newPass"
				type="password"
				:placeholder="$t('page.setting.updatePayPassword.newPassword-Placeholder')"
				></u--input>
			</u-form-item>
			
			<u-form-item
			:label="$t('page.setting.updatePayPassword.confirmPassword')"
			prop="okPayPass"
			borderBottom
			labelWidth="80px"
			>
				<u--input
				v-model="model1.okPayPass"
				type="password"
				:placeholder="$t('page.setting.updatePayPassword.newPassword-Placeholder')"
				></u--input>
			</u-form-item>
			
		</u--form>
		<u-button class="submit"
		size="large" @click="submit"
		:text="$t('page.walletRecharge.submit')"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				model1: {
					id : 1,
					payPass: '',
					newPass: '',
					okPayPass : ''
				},
				rules: {
					'payPass': {
						type: 'string',
						required: true,
						message: this.$t('page.setting.updatePayPassword.OldPassword-Placeholder'),
						trigger: ['blur', 'change']
					},
					'newPass': {
						type: 'string',
						required: true,
						message: this.$t('page.setting.updatePayPassword.newPassword-Placeholder'),
						trigger: ['blur', 'change']
					},
					'okPayPass': {
						type: 'string',
						required: true,
						message: this.$t('page.setting.updatePayPassword.newPassword-Placeholder'),
						trigger: ['blur', 'change']
					},
				},
			}
		},
		methods: {
			leftClick(){
				uni.navigateTo({
					url: '/pages/setting/setting'
				})
			},
			editPayPassword(){
				this.request('editPayPass',this.model1).then(res=>{
					if(res.code === 200){
						uni.$u.toast(this.$t('page.setting.updatePayPassword.edit-success'))
						setTimeout(()=>{
							uni.switchTab({
								url: '/pages/home/home'
							})
						},1000)
					}
				})
			},
			submit(){
				this.$refs.uForm.validate().then(res => {
					this.editPayPassword();
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.line{
		background-color: #fff;
		padding: 5px 10px;
		margin-top: 10px;
		.celi{
			border-radius: 10px;
			margin: 10px 0;
		}
	}
	.submit{
		border-radius: 30px;
		background-color: #ED762F;
		color: #fff;
		margin: 10px;
		width: calc(100% - 20px);
	}
</style>
