import { httpRequest, commonRequest, getServiceUrl } from '@/services/http'
import { CommonParams, HttpParams } from '@/services/http/interface'

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

/**
 * 获取应用更新信息
 */
export function GetAppUpdateInfo(params: CommonParams<{ rsp: string }>) {
    return commonRequest('http://47.116.5.81:8012/PhoneService/GetUpdateInfo', 'get', params);
}

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

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

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

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

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

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

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

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

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

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