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

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

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



// 获取自然日单品销售数据 
export async function handleGetDailyCommoditySaleList(params: any) {
    const data = await requestEncryption('/Revenue/GetDailyCommoditySaleList', {
        method: 'POST',
        data: {
            ...params,
            requestEncryption: true
        }
    })

    return data.Result_Data.List
}
//  更新密码
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
}