import { httpRequest, commonRequest, getServiceUrl } from '@/services/http'
import { loginStore } from '@/stores'

const { userId } = loginStore.$mapGetters()

/**
 * 获取应用配置信息
 */
// export function GetAppConfig() {
//     return commonRequest<{ version: string, versionCode: string, apiUrl: string }>('./config/appconfig.json', 'get', params);
// }

/**
 * 获取应用更新信息(ios存在跨域问题)
 */
export function GetAppUpdateInfo() {
    return commonRequest<string>(getServiceUrl('androidUpdateUrl'), 'get');
}

/**
 * 用户注册
 */
export function userRegister(params: Model.RegisterReq) {
    return commonRequest<Model.RegisterRsp>(getServiceUrl('openApiUrl') + '/onlineopen/userInfo/add3', 'post', params);
}

/**
 * 发送注册短信验证码
 */
export function sendRegisterVerifyCode(params: { phonenumber: string }) {
    return commonRequest(getServiceUrl('openApiUrl') + '/verifycode/identifyCode/' + params.phonenumber, 'get');
}

/**
 * 重置密码
 */
export function resetPassword(params: Model.ResetPasswordReq) {
    return commonRequest<Model.ResetPasswordRsp>(getServiceUrl('commSearchUrl') + '/tradeoperation/resetpwdbycardnum', 'post', params);
}

/**
 * 发送重置密码短信验证码
 */
export function sendResetVerifyCode(params: Model.SendResetVerifyCodeReq) {
    return commonRequest<Model.SendResetVerifyCodeRsp>(getServiceUrl('commSearchUrl') + '/user/smsvcode', 'post', params);
}

/**
 * 文件上传
 */
export function uploadFile(params: Model.uploadFileReq) {
    return commonRequest<Model.uploadFileRsp>(getServiceUrl('uploadUrl'), 'post', params);
}

/**
 * 查询轮播图配置信息
 */
export function queryImageConfigs(params: Model.ImageConfigsReq) {
    return httpRequest<Model.ImageConfigsRsp[]>('/Common/QueryImageConfigs', 'get', params);
}

/**
 * 查询所有枚举信息
 */
export function queryAllEnums(params?: Model.EnumReq) {
    return httpRequest<Model.EnumRsp[]>('/Common/GetAllEnums', 'get', params, 'GetAllEnums');
}

/**
 * 获取数据库错误信息
 */
export function queryErrorInfos(params?: Model.ErrorInfosReq) {
    return httpRequest<Model.ErrorInfosRsp[]>('/Common/QueryErrorInfos', 'get', params, 'QueryErrorInfos');
}

/**
 * 用户签到
 * signinstatus 状态操作标志 1-签到成功 2-当日已签到，不能重复签到
 */
export function signin(params: { userid: number }) {
    return httpRequest<{ signinstatus: number }>('/Ferroalloy/Signin', 'post', params);
}

/**
 * 查询我的注册红包
 */
export function queryMyRegisterMoney(params: Model.MyRegisterMoneyReq) {
    return httpRequest<Model.MyRegisterMoneyRsp[]>('/Ferroalloy/QueryMyRegisterMoney', 'get', params);
}

/**
 * 查询用户等级信息
 */
export function queryUserLevelInfo(params: Model.UserLevelInfoReq) {
    return httpRequest<Model.UserLevelInfoRsp>('/Ferroalloy/QueryUserLevelInfo', 'get', params);
}

/**
 * 查询查询我推荐的好友等级
 */
export function queryInvestorLevelGroup() {
    return httpRequest<Model.InvestorLevelGroupRsp[]>('/Ferroalloy/QueryInvestorLevelGroup', 'get');
}

/**
 * 查询好友
 */
export function queryTHJFriends(params: Model.THJFriendsReq) {
    return httpRequest<Model.THJFriendsRsp[]>('/Ferroalloy/QueryTHJFriends', 'get', params);
}

/**
 * 查询收益
 */
export function queryTHJProfits(params: Model.THJProfitsReq) {
    params.userid = userId.value
    return httpRequest<Model.THJProfitsRsp[]>('/Ferroalloy/QueryTHJProfits', 'get', params);
}

/**
 * 查询本人定金比例
 */
export function queryMyDeposit(params: Partial<Model.MyDepositReq>) {
    params.userid = userId.value
    return httpRequest<Model.MyDepositRsp[]>('/Ferroalloy/QueryMyDeposit', 'get', params);
}

/**
 * 定金比例个性化查询
 */
export function queryTHJinvesotrdeposit(params: Partial<Model.THJinvesotrdepositReq>) {
    return httpRequest<Model.THJinvesotrdepositRsp[]>('/Ferroalloy/QueryTHJinvesotrdeposit', 'get', params);
}

/**
 * 比例变更流水查询
 */
export function queryTHJInvesotrDepositLog(params: Partial<Model.THJInvesotrDepositLogReq>) {
    return httpRequest<Model.THJInvesotrDepositLogRsp[]>('/Ferroalloy/QueryTHJInvesotrDepositLog', 'get', params);
}