<template>
	<view class="content">

		<view class="messageBg">
			<!-- 新密码 -->
			<view class="message line">
				<view class="leftTitle">新密码：</view>
				<input password="tue" type="text" class="passWord" placeholder="请输入新密码" v-model="newPW" @confirm="newPWDone" />
			</view>

			<!-- 确认密码 -->
			<view class="message">
				<view class="leftTitle">确认密码：</view>
				<input password="tue" type="text" class="passWord" placeholder="请再次输入新密码" v-model="surePW" @confirm="surePWDone" />
			</view>


		</view>



		<!-- 修改 -->
		<view class="sureBtn" @click="changePW">确定修改</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newPW: '',
				surePW: '',

			}
		},
		methods: {
			newPWDone(e) {
				this.newPW = e.target.value;
				console.log(this.newPW);
			},
			surePWDone(e) {
				this.surePW = e.target.value;
				console.log(this.surePW);
			},
			changePW() {
				if (!this.newPW) {
					uni.showToast({
						title: '密码不能为空',
						duration: 2000,
						icon: 'none'
					})

					return

				}
				if ((this.surePW != this.newPW)) {
					uni.showToast({
						title: '请确认密码',
						duration: 2000,
						icon: 'none'
					})
					this.surePW = '';
					return

				}
				uni.showLoading({
					title: '加载中'
				})
				this.$http('accompany/SuperAccounts/updatePwd', {
					pwd: this.surePW,
				}, 'POST').then(res => {
					uni.hideLoading()
					
					
					uni.showToast({
						title: '修改成功',
					})
					setTimeout(function(){
						uni.navigateBack({
						
						})
					},1000)
				})
			}
		}
	}
</script>

<style>
	.content {
		background-color: #F4F5F7;
		min-height: 100vh;
		padding: 20rpx 24rpx;
	}

	/* #ifdef H5 */
	.content {
		background-color: #F4F5F7;
		min-height: calc(100vh - 44px);
		padding: 20rpx 24rpx;
	}

	/* #endif */

	.messageBg,
	.sureBtn {
		background-color: #FFFFFF;
		border-radius: 10rpx;
		margin: 20rpx 0rpx;

	}

	.message {
		display: flex;
		justify-content: flex-start;
		line-height: 98rpx;
		align-items: center;
	}

	.line {
		border-bottom: 1rpx solid #EEEEEE;
	}



	.leftTitle {
		font-size: 28rpx;
		color: #3C3C3C;
		margin-left: 20rpx;
		width: 140rpx;
	}

	.passWord {
		flex-grow: 1;
		font-size: 28rpx;
		color: #999999;
		margin-left: 52rpx;
		margin-right: 20rpx;
	}


	.sureBtn {
		line-height: 98rpx;
		text-align: center;
		color: #FFFFFF;
		background-color: #FF8700;
	}
</style>
