var toast = new auiToast();

function getData(){
    toast.loading({
        title:"加载中",
        duration:2000
    })
    _vp.getUserData(
        {},
        function(res){
            toast.hide();
            if (res.status == 2001) {
                //需要登录
                top.location.href = "login.html";
                return;
            }else if(res.status == -1) {
                toast.fail({
                    title:"系统繁忙",
                    duration:2000
                });
                return;
            }
            $("#vpayName").val(res.data.vpay_name);
            $("#phone").val(res.data.phone);
        })
}

function submit(){
    var vpay_name = $("#vpayName").val();
    if(!vpay_name){
        toast.fail({
            title:"Vpay用户名不能为空!",
            duration:2000
        });
    }
    toast.loading({
        title:"加载中",
        duration:2000
    })
    _vp.UserInformation(
        {
            vpay_name: vpay_name
        },
        function(res){
            toast.hide();
            if (res.status == 2001) {
                //需要登录
                top.location.href = "login.html";
                return;
            }else if(res.status == -1) {
                toast.fail({
                    title:"系统繁忙",
                    duration:2000
                });
                return;
            }else if(res.status == 1){
                window.location.href = 'personal.html'
            }
        })
}

$(function(){
    getData();
})