import request from "@/utils/request";
import type { CloudChangeUserModel, CloudChangePassword } from './data';
import requestEncryption from "@/utils/requestEncryption";

//  更新账户信息
export async function modifyUserInfo(data: CloudChangeUserModel) {

    return request(`/FrameWork/ModifyUserInfo`, {
        method: 'POST',
        data,
        // requestType: 'form',
    });
}

//  更新密码
export async function modifyUserPassword(data: CloudChangePassword) {

    return request(`/FrameWork/ModifyUserPassword`, {
        method: 'POST',
        data,
        // requestType: 'form',
    });
}

//  上传用户头像
export async function changeUserHeadImg(data: any) {

    return request(`/FrameWork/ChangeUserHeadImg`, {
        method: 'POST',
        data,
        requestType: 'form',
    });
}

//  发送短信验证码
export async function getSMSIdentityCode(phone: string) {

    return request(`/Common/GetSMSIdentityCode?PhoneNumber=${phone}`, {
        method: 'GET'
    });
}

//  更新账户手机号码
export async function modifyUserMobilePhone(data: CloudChangeUserModel) {

    return request(`/FrameWork/ModifyUserMobilePhone`, {
        method: 'POST',
        data,
        // requestType: 'form',
    });
}


// 根据用户账号修改密码
export async function handleModifyPasswordByPassport(params: any) {
    const data = await requestEncryption(`/Logging/ModifyPasswordByPassport`, {
        method: 'POST',
        data: {
            ...params,
            requestEncryption: true
        },
    })

    if (data.Result_Code !== 100) {
        return data
    }

    return data
}