<template>
	<view class="content">
		<view class="tip">
			*為了您的資金安全，登錄密碼修改後24小時以內不允許提現。
		</view>
		<view class="tit">
			舊密碼
		</view>
		<input type="password" class="shuru" placeholder="請翰入舊密碼" v-model="oldpwd">
		<view class="tit">
			新密碼
		</view>
		<input type="password" class="shuru" placeholder="請翰入新密碼" v-model="newpwd">
		<view class="tit">
			確認密碼
		</view>
		<input type="password" class="shuru" placeholder="請翰入確認密碼" v-model="renewpwd">
		<view class="loginout" @click="changepass()">
			提交
		</view>
	</view>
</template>

<script>
	import {
		changepass
	} from '@/api/login.js'
	export default {
		data() {
			return {
				//oldpwd newpwd
				oldpwd: '',
				newpwd: '',
				renewpwd: ''
			}
		},
		onLoad() {

		},
		onShow() {

		},
		onReachBottom() {

		},
		onReady() {

		},
		methods: {
			changepass() {
				let obj = this
				if(obj.oldpwd == '') {
					return obj.$api.msg('請翰入舊密碼')
				}
				if(obj.newpwd == '') {
					return obj.$api.msg('請翰入新密碼')
				}
				if(obj.renewpwd == '') {
					return obj.$api.msg('請翰入確認密碼')
				}
				if(obj.newpwd != obj.renewpwd) {
					return obj.$api.msg('兩次密碼不一致')
				}
				changepass({
					oldpwd: obj.oldpwd,
					newpwd: obj.newpwd
				}).then(res => {
					uni.showToast({
						title: '修改成功',
						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>
