personalCenter.js 10.4 KB
$(document).ready(function() {

    //获取个人信息(传一个token)
    var url = "/login/userInfo"; // 接口    
    var header = {
            "Content-Type": "application/x-www-form-urlencoded",
            "token": localStorage.getItem('token'),
        }
        // 调用公共ajax
    ajax(url, "GET", header, function(res) {
            console.log(res);


        }, function(res) {
            console.log(res);
            // $("#Pnumber").html(res.data.phoneNumber)
            // $('#surname').html(res.data.surname)
            // $('#userName').html(res.data.userName)
            // $('#specialty').html(res.data.specialty)
            // $('#school').html(res.data.school)
            // $('#phone').html(res.data.phone)
            // $('#emailAddress').html(res.data.emailAddress)
            //缺一个img
            //input用val,a用html
            $('#phone').val(res.data.phone)
            $('#surname').val(res.data.surname)
            $('#userName').val(res.data.userName)
            $('#specialty').val(res.data.specialty)
            $('#school').val(res.data.school)
            $('#emailAddress').val(res.data.emailAddress)
            $('#WXname').html(res.data.wname)
            $('#Pnumber').html(res.data.phoneNumber)
            if (res.data.wname == null) {
                $("#WXunbind").html("绑定")
            } else {
                $("#WXunbind").html("解绑")
            }
            if (res.data.phoneNumber == null) {
                $("#Punbind").html("绑定")
            } else {
                $("#Punbind").html("解绑")
            }
        })
        // $.ajax({
        //         type: 'GET',
        //         url: 'http://192.168.1.241:9004/login/userInfo',
        //         headers: {
        //             "Content-Type": "application/x-www-form-urlencoded",
        //             "token": localStorage.getItem('token'),
        //         },
        //         success: function(res) {
        //             console.log(res);
        //             // $("#Pnumber").html(res.data.phoneNumber)
        //             // $('#surname').html(res.data.surname)
        //             // $('#userName').html(res.data.userName)
        //             // $('#specialty').html(res.data.specialty)
        //             // $('#school').html(res.data.school)
        //             // $('#phone').html(res.data.phone)
        //             // $('#emailAddress').html(res.data.emailAddress)
        //             //缺一个img
        //             //input用val,a用html
        //             $('#phone').val(res.data.phone)
        //             $('#surname').val(res.data.surname)
        //             $('#userName').val(res.data.userName)
        //             $('#specialty').val(res.data.specialty)
        //             $('#school').val(res.data.school)
        //             $('#emailAddress').val(res.data.emailAddress)
        //             $('#WXname').html(res.data.wname)
        //             $('#Pnumber').html(res.data.phoneNumber)

    //         }
    //     })
    //修改个人信息
    $(".btnSave button").click(function() {
        //姓
        var inputSurname = $("#surname").val();
        console.log(inputSurname);
        //名
        var inputUserName = $("#userName").val();
        console.log(inputUserName);
        //专业(null)
        var inputSpecialty = $("#specialty").val();
        console.log(inputSpecialty);
        //学校
        var inputSchool = $("#school").val();
        console.log(inputSchool);
        //手机号
        var inputPhone = $("#phone").val();
        console.log(inputPhone);
        //邮箱
        var inputEmailAddress = $("#emailAddress").val();
        console.log(inputEmailAddress);

        var url1 = "/login/updateSysUser"; // 接口    
        var header1 = {
            "Content-Type": "application/json",
        }
        var params = JSON.stringify({
                emailAddress: inputEmailAddress,
                id: localStorage.getItem("userId"),
                img: null,
                phone: inputPhone,
                specialty: inputSpecialty,
                school: inputSchool,
                surname: inputSurname,
                userName: inputUserName
            })
            // 调用公共ajax
        ajax(url1, "PUT", header1, params, function(res) {
                console.log(res);

            }, function(res) {
                console.log(res);
                alert('保存成功!')
                location.reload();
            })
            // $.ajax({
            //     type: "PUT",
            //     url: "http://192.168.1.241:9004/login/updateSysUser",
            //     headers: {
            //         "Content-Type": "application/json"
            //     },
            //     //图片为空!!!!!!!!!!!!!!!!!!!!
            //     data: JSON.stringify({
            //         emailAddress: inputEmailAddress,
            //         id: localStorage.getItem("userId"),
            //         img: null,
            //         phone: inputPhone,
            //         specialty: inputSpecialty,
            //         school: inputSchool,
            //         surname: inputSurname,
            //         userName: inputUserName
            //     }),
            //     success: function(msg) {
            //         alert('保存成功!')
            //         location.reload();
            //     },
            //     error: function(res) {
            //         alert('保存失败!')
            //     }
            // });

    })



    //删除微信(传token)

    $("#WXunbind").click(function() {
        var url2 = "/login/deleteWeXin"; // 接口    
        // 调用公共ajax
        ajax(url2, "DELETE", header, function(res) {
                console.log(res);

            }, function(res) {
                console.log(res);
                alert("解绑成功!")
                location.reload();
            })
            // $.ajax({
            //     type: "DELETE",
            //     url: "http://192.168.1.241:9004/login/deleteWeXin",
            //     headers: {
            //         "Content-Type": "application/x-www-form-urlencoded",
            //         "token": localStorage.getItem('token'),
            //     },
            //     success: function(res) {
            //         alert("解绑成功!")
            //         location.reload();
            //     },
            //     error: function(res) {
            //         alert('解绑失败!')
            //     }
            // });
    })

    //删除手机号(传token)
    $("#Punbind").click(function() {
        var url3 = "/login/deletePhone"; // 接口    
        // 调用公共ajax
        ajax(url3, "DELETE", header, function(res) {
                console.log(res);

            }, function(res) {
                console.log(res);
                // alert("解绑成功!")
                // location.reload();
            })
            // $.ajax({
            //     type: "DELETE",
            //     url: "http://192.168.1.241:9004/login/deletePhone",
            //     headers: {
            //         "Content-Type": "application/x-www-form-urlencoded",
            //         "token": localStorage.getItem('token'),
            //     },
            //     success: function(res) {
            //         alert("解绑成功!")
            //         location.reload();
            //     },
            //     error: function(res) {
            //         alert('解绑失败!')
            //     }
            // });
    })

    //查看会员信息
    // $.ajax({
    //     type: "GET",
    //     url: "http://192.168.1.241:9004/login/memberList",
    //     headers: {
    //         "Content-Type": "application/x-www-form-urlencoded",
    //         "token": localStorage.getItem('token'),
    //     },
    //     success: function(res) {
    //         console.log(res.data);
    //     },
    //     error: function(res) {

    //     }
    // })


});

// function name(params) {

// }
$('#meau_nav>div').click(function() {
    // var index = $(this).index();
    $(this).addClass('active-click').siblings().removeClass('active-click');

})

var actualFee = ''
var memberMonth = ''
var memberName = ''
var paymentType = ''

function clickVIPone() {
    actualFee = 99
    memberMonth = 1
    memberName = '基础会员'
}

function clickVIPtwo() {
    actualFee = 399
    memberMonth = 6
    memberName = '标准会员'
}

function clickVIPthree() {
    actualFee = 699
    memberMonth = 12
    memberName = '超级会员'
}

function checkRadio() {
    paymentType = $("input[name='zhifu']:checked").val()
}
//提交订单
function payment() {
    console.log(paymentType);
    console.log(actualFee);
    console.log(memberMonth);
    console.log(memberName);
    var url4 = "/orderLog/orderAdd"; // 接口    
    var header2 = {
        "Content-Type": "application/json",
        "token": localStorage.getItem('token'),
    }
    var params = JSON.stringify({
            actualFee: actualFee,
            memberMonth: memberMonth,
            memberName: memberName,
            paymentType: paymentType
        })
        // 调用公共ajax
    ajax(url4, "POST", header2, params, function(res) {
        console.log(res);
        console.log(res);
        console.log(res.data);
        $(".hide_box").fadeToggle();
        $(".shang_box").fadeToggle();
    }, function(res) {

    })
}
//获取用户VIP信息判断是否是VIP
function ifVIP() {
    var url5 = "/login/userInfo"; // 接口    
    var header = {
            "Content-Type": "application/json",
            "token": localStorage.getItem('token'),
        }
        // 调用公共ajax
    ajax(url5, "GET", header, function(res) {
        console.log(res);

    }, function(res) {
        console.log(res);
        if (res.data.status1 == 1) {
            window.location.href = 'personalCenter.html'
        } else {
            window.location.href = 'personalCenter2.html'
        }
    })

    // $.ajax({
    //     type: 'GET',
    //     url: 'http://192.168.1.241:9004/login/userInfo',
    //     headers: {
    //         "Content-Type": "application/json",
    //         "token": localStorage.getItem('token'),
    //     },
    //     success: function(res) {
    //         console.log(res);
    //         if (res.data.status1 == 1) {
    //             window.location.href = 'personalCenter.html'
    //         } else {
    //             window.location.href = 'personalCenter2.html'
    //         }
    //     }
    // })
}