<template>
	<view class="content">
		<view class="tip">{{ $t('mm.wlnd') }}</view>
		<view class="tit">{{ $t('mm.jmm') }}</view>
		<input type="password" class="shuru" :placeholder="$t('mm.qsrjmm')" v-model="oldpwd" />
		<view class="tit">{{ $t('mm.xmm') }}</view>
		<input type="password" class="shuru" :placeholder="$t('mm.qsrxmm')" v-model="newpwd" />
		<view class="tit">{{ $t('mm.qrmm') }}</view>
		<input type="password" class="shuru" :placeholder="$t('mm.qsrqrmm')" v-model="renewpwd" />
		<view class="loginout" @click="changepass()">{{ $t('mm.tj') }}</view>
	</view>
</template>

<script>
import { changepass } from '@/api/login.js';
export default {
	data() {
		return {
			//oldpwd newpwd
			oldpwd: '',
			newpwd: '',
			renewpwd: ''
		};
	},
	onLoad() {
		uni.setNavigationBarTitle({ title: this.$t('mm.mm') });
	},
	onShow() {},
	onReachBottom() {},
	onReady() {},
	methods: {
		changepass() {
			let obj = this;
			if (obj.oldpwd == '') {
				return obj.$api.msg(this.$t('mm.qsrjmm'));
			}
			if (obj.newpwd == '') {
				return obj.$api.msg(this.$t('mm.qsrxmm'));
			}
			if (obj.renewpwd == '') {
				return obj.$api.msg(this.$t('mm.qsrqrmm'));
			}
			if (obj.newpwd != obj.renewpwd) {
				return obj.$api.msg(this.$t('mm.lcmmbyz'));
			}
			changepass({
				oldpwd: obj.oldpwd,
				newpwd: obj.newpwd
			}).then(res => {
				uni.showToast({
					title: this.$t('xgcg'),
					duration: 2000,
					position: 'top'
				});
				setTimeout(() => {
					uni.switchTab({
						url: '/pages/index/index'
					});
				}, 1500);
			});
		}
	}
};
</script>

<style lang="scss">
page {
	height: 100%;
	background-color: #fff;
}

.tip {
	color: red;
	font-size: 26rpx;
	padding: 30rpx;
}

.shuru {
	display: block;
	background-color: #f5f5f5;
	width: 673rpx;
	height: 95rpx;
	margin: auto;
	padding-left: 30rpx;
	text-align: 95rpx;
}

.tit {
	padding: 60rpx 48rpx 20rpx;
}
.loginout {
	width: 675rpx;
	height: 70rpx;
	line-height: 70rpx;
	text-align: center;
	font-size: 26rpx;
	color: #000;
	background-color: #f4d03c;
	margin: 50rpx auto;
	border-radius: 20rpx;
	font-weight: bold;
}
</style>
