<template>
	<view class="p-root-person-pwdLogin g_w_all g_h_all g_bg_f_5 g_kuaishou">
		<view class="g_pt_10">
			<g-panel-form-slot
				:list="[
					{
						icon: '',
						label: '原密码',
						result: '',
						path: '',
						tip: 'old-pwd',
						type: 'slot',
						pColumn: 12,
						flexSlot: '1',
					},
				]"
			>
				<slot>
					<!-- #ifdef APP-PLUS || H5 || MP-TOUTIAO || MP-KUAISHOU -->
					<u-input type="text" :clearable="false" :password-icon="false" placeholder="请输入原密码" input-align="right" class="g_text_r" placeholder-style="color:#999999;font-size:32rpx;line-height:1" v-model="oldPwd" style="width: calc(100vw - (106px);flex: none;" />
					<!-- #endif -->
					<!-- #ifdef MP-WEIXIN -->
					<u-input type="text" :clearable="false" :password-icon="false" placeholder="请输入原密码" input-align="right" class="g_text_r g_w_all" placeholder-style="color:#999999;font-size:32rpx;line-height:1" v-model="oldPwd" />
					<!-- #endif -->
				</slot>
			</g-panel-form-slot>
		</view>
		<view class="g_flex_row_end g_pr_20 g_mt_8 g_fs_14 g_mb_24" style="color: #576b95" @click="goPage"> 忘记原密码 </view>
		<view class="">
			<g-panel-form-slot
				:list="[
					{
						icon: '',
						label: '新密码',
						result: '',
						path: '',
						tip: 'slot-new-pwd',
						value: newPwd,
						type: 'slot',
						placeholder: '请输入新密码',
						pColumn: 12,
					},
					{
						icon: '',
						label: '确认密码',
						result: '',
						path: '',
						tip: 'slot-confirm-pwd',
						value: confirmPwd,
						type: 'slot',
						placeholder: '再次输入新密码',
						pColumn: 12,
					},
				]"
				@changeNewPwd="getNewPwd"
				@changeConfirmPwd="getConfirmPwd"
			>
			</g-panel-form-slot>
		</view>
		<view class="g_pt_90 g_flex_row_center">
			<rh-button  btnText="修改密码" type="primary" @clickBtn="submitForm" />
		</view>
	</view>
</template>

<script>

export default {
	onReady() {},
	onShareAppMessage() {
		return this.G.shareFun();
	},
	components: {
	},
	data() {
		return {
			oldPwd: "",
			newPwd: "",
			confirmPwd: "",
		};
	},
	methods: {
		getNewPwd(e) {
			this.newPwd = e;
		},
		getConfirmPwd(e) {
			this.confirmPwd = e;
		},
		submitForm() {
			let that = this;
			if (that.oldPwd == "") {
				uni.showToast({
					title: "请输入原密码",
					icon: "none",
				});
				return false;
			}
			if (that.newPwd == "") {
				uni.showToast({
					title: "请输入新密码",
					icon: "none",
				});
				return false;
			}
			if (that.confirmPwd == "") {
				uni.showToast({
					title: "请再次输入新密码",
					icon: "none",
				});
				return false;
			}
			if (that.confirmPwd != that.newPwd) {
				uni.showToast({
					title: "前后密码不一致",
					icon: "none",
				});
				return false;
			}
			that.G.Post(
				that.api.user_changeLoginPwd,
				{
					tel: uni.getStorageSync("apply-tel"),
					oldPassword: that.oldPwd,
					password: that.newPwd,
				},
				() => {
					uni.showToast({
						title: "修改成功",
						icon: "success",
					});
					setTimeout(() => {
						that.G.Get(that.api.login_out, {}, () => {
							that.G.clearLocalStorage();
							let params = {
								path: "",
								level: "",
							};
							uni.reLaunch({
								url: "/root/login/index?" + that.G.objToStr(params),
							});
						});
					}, 1500);
				}
			);
		},
		goPage() {
			uni.navigateTo({
				url: "/root/person/pwdForget",
			});
		},
	},
};
</script>

<style></style>
