<template>
    <lj-win-common title="修改密码">
        <div slot="body">
            <group>
                <x-input title="原密码" v-model="psw_ori" type="password"/>
                <x-input title="新密码" v-model="psw_new" type="password"/>
                <x-input title="确认新密码" v-model="psw_new_again" type="password"/>
            </group>

        </div>
        <mu-button large slot="footer" color="primary" @click="handlePasswordEdit" style="width: 100%">
            立即修改
        </mu-button>
    </lj-win-common>
</template>

<script>
    import {Group, XInput} from 'vux'
    import LjWinCommon from "components/lj-win-common";

    export default {
        components: {
            Group,
            XInput,
            LjWinCommon
        },
        data() {
            return {
                psw_ori: "",
                account: "",
                usercode: "",
                psw_new: "",
                psw_new_again: ""
            }
        },
        created() {
            let pageParm = $lj.getPageParam();
            this.account = pageParm.account;
            this.usercode = pageParm.usercode;
        },
        methods: {
            handlePasswordEdit() {
                if (this.psw_new !== this.psw_new_again) {
                    alert("两次输入的新密码不一致");
                    return;
                }
                let requestBody = {
                    account: this.account,
                    userid: this.usercode,
                    oldpassword: this.psw_ori,
                    newpassword: this.psw_new
                };
                $lj.postLJRequest("ChangePassword", requestBody, function (ret) {
                    alert("修改成功!");
                    $lj.openWin("login");
                    $lj.closeWin();
                });
            }
        }
    }
</script>

<style scoped>

</style>