<template>
	<view>
		<view class="logo">
			<view class="img">
				<image mode="widthFix" src="../../../static/img/logo2.jpg">
				</image>
			</view>
		</view>
		<!-- 账号密码输入框 -->
		<view class="form">
			<view class="password">
				<image src="../../../static/img/pas.png" style="width: 40rpx;height: 40rpx;"></image><input
					placeholder="请输入旧密码" type="number" maxlength="6" v-model="jpasswd" password=true placeholder-style="color: #333333;" />
			</view>
			<view class="password">
				<image src="../../../static/img/pas.png" style="width: 40rpx;height: 40rpx;"></image><input
					placeholder="请输入新密码" type="number" maxlength="6" v-model="xpasswd" password=true placeholder-style="color: #333333;" />
			</view>
			<view class="btn mart50" @tap="updateUserPayPwd">确 认</view>
		</view>
	</view>
</template>

<script>
	import {
		updateUserPayPwd
	} from "../../../Utils/Api.js";
	let app =getApp();
	export default {
		data() {
			return {
				jpasswd: '',
				xpasswd: '',
			}
		},
		methods: {
			updateUserPayPwd() {
				uni.hideKeyboard();
				if (this.jpasswd == '') {
					uni.showToast({
						title: '请填写旧密码',
						icon: "none"
					});
					return false;
				}
				if (this.xpasswd == '') {
					uni.showToast({
						title: '请填写新密码',
						icon: "none"
					});
					return false;
				}
				uni.showLoading({
					title: '设置中...'
				})
				let datas = {
					"password": this.jpasswd,
					"newPassword":this.xpasswd
				}
				updateUserPayPwd(datas).then(res => {
					if (res.return_code == '000000') {
						uni.hideLoading();
						uni.showToast({
							title: '修改成功',
							icon: "none",
							duration:2000
						});
						app.globalData.userInfo = res.return_data
							.object
							.highUser;
						uni.setStorage({
							key: "user",
							data: res.return_data
								.object
								.highUser
						})
						uni.navigateBack({
						})
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.return_msg,
							icon: "none"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
@import "../../../static/css/login.scss";
.form {
		.res {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 100upx;
			color: rgba($color: #ffffff, $alpha: 0.8);
		}
	}
</style>
