import request from '@/utils/request'

export function getInfo(data) {
    return request({
        url: 'personal/getInfo',
        method: 'post',
        data
    })
}

export function setInfo(data) {
    return request({
        url: 'personal/setInfo',
        method: 'post',
        data
    })
}

export function changePassword(user) {
    const data = {
        id: user.id,
        oldPassword: user.oldPassword,
        newPassword: user.newPassword
        // oldPass: encrypt(user.oldPassword),
        // newPass: encrypt(user.newPassword)
    }
    return request({
        url: 'personal/changePassword',
        method: 'post',
        data
    })
}

export function updateEmail(form) {
    const data = {
        password: encrypt(form.pass),
        email: form.email
    }
    return request({
        url: 'api/users/updateEmail/' + form.code,
        method: 'post',
        data
    })
}
export function resetEmail(data) {
    return request({
        url: 'api/code/resetEmail?email=' + data,
        method: 'post'
    })
}
