<template>
	<view class="content">
		<view class="">
			<u-input v-model="oldPwd" type="password" border="bottom" placeholder="请输入原密码"></u-input>
			<u-input v-model="newPwd" type="password" border="bottom" placeholder="请输入新密码"></u-input>
			<view class="text_style1">密码格式为6-16位数字，字母或符号</view>
		</view>
		<view class="btn" @click="save">完成</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	var that = ''
	export default {
		data() {
			return {
				oldPwd: '',
				newPwd: '',
			}
		},
		onLoad() {
			that = this
		},
		methods: {
			save() {
				if($api.formCheck(that.oldPwd,'required') && $api.formCheck(that.newPwd,'required')) {
					if(that.oldPwd !== that.newPwd) {
						$api.req({
							url: '/data/api.business.User/user_password',
							method: 'POST',
							data: {
								old_password: that.oldPwd,
								new_password: that.newPwd
							}
						}, function(res) {
							if(res.code == 1) {
								console.log(res);
								$api.info('修改成功')
							}
						})
					} else {
						$api.info('请输入与原密码不同的新密码')
					}
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content::v-deep {
		background-color: #fff;
		padding: 0 30rpx 0;
		.u-input {
			padding: 28rpx 0 !important;
			margin-top: 32rpx;
		}
		.btn {
			margin: 112rpx auto 0;
			width: 630rpx;
			height: 92rpx;
			border-radius: 50rpx;
			background-color: #506dff;
			color: #fff;
			font-size: 36rpx;
			text-align: center;
			line-height: 92rpx;
		}
		.text_style1 {
			font-size: 24rpx;
			color: #999;
			margin-top: 32rpx;
		}
	}
</style>