import { getAxios, postAxios, downFile } from '@/utils/axios.js'
import axios from 'axios'
import { ElMessage } from "element-plus";
//获取vx二维码
export function getVxQrcode() {
    return getAxios({ url: 'user/qrcode' })
}
//获取扫码结果
export function getScanResult(data) {
    return getAxios({ url: 'user/check/' + data})
}
//获取用户信息
export function getUserInfo(data) {
    return postAxios({ url: 'user/getUserInfo',data})
    }
//修改用户信息
export function editUserInfo(data) {
    return postAxios({ url: 'user/updateUserInfo', data })
}
//检查用户名
export function checkUsername(data) {
    return postAxios({ url: 'user/checkUserName', data })
}
//注册
export function register(data) {
    return postAxios({ url: 'user/registerWithMail', data })
}
//查询验证状态
export function checkStatus(data) {
    return postAxios({ url: 'user/getUserInfo', data })
}
//重发邮件
export function resendEmail(data) {
    return postAxios({ url: 'user/resendMail', data })
}
//登录
export function login(data) {
    return postAxios({ url: 'user/loginWithMail', data })
}
//获取pk列表
export function getPkList(data) {
    return postAxios({ url: 'pk/pkList', data })
}
//站内信列表
export function getNoticeList(data) {
    return postAxios({ url: 'systemMessage/list', data })
}
//主播库列表
export function getAnchorList(data) {
    return postAxios({ url: 'anchor/list', data })
}
//主播库添加主播
export function addAnchor(data) {
    return postAxios({ url: 'anchor/add', data })
}
//主播库删除主播
export function delAnchor(data) {
    return postAxios({ url: 'anchor/deleteMyAnchor', data })
    }
//主播库修改主播
export function editAnchor(data) {
    return postAxios({ url: 'anchor/updateAnchorInfo', data })
}
//获取主播头像
export function getAnchorAvatar(data) {
    const url = "https://python.yolojt.com/api/" + data.name
    return new Promise((resolve, reject) => {
        axios.get(
            url
        ).then(res => {
            if (res.code == 200) {
                resolve(res.data) 
            }else {
                reject(res);
            }
        }).catch(err => {
            reject(err)
        })
    })
}
//获取PK信息
export function getPkInfo(data) {
    return postAxios({ url: 'user/queryMyAllPkData', data })
}
//发布PK信息
export function releasePkInfo(data) {
    return postAxios({ url: 'pk/addPkData', data })
}
//修改PK信息
export function editPkInfo(data) {
    return postAxios({ url: 'pk/updatePkInfoById', data })
}
//删除PK信息
export function delPkInfo(data) {
    return postAxios({ url: 'pk/deletePkDataWithId', data })
}
//置顶PK信息
export function topPkInfo(data) {
    return postAxios({ url: 'user/pinToTop', data })
}
//取消置顶PK信息
export function cancelTopPkInfo(data) {
    return postAxios({ url: 'user/cancelPin', data })
}
//获取积分详情
export function getIntegralDetail(data) {
    return postAxios({ url: 'user/pointsDetail', data })
}
//获取PK记录
export function getPkRecord(data) {
    return postAxios({ url: 'user/handlePkInfo', data })
}
//签到
export function signIn(data) {
    return postAxios({ url: 'user/signIn', data })
}
//修改邮箱
export function editEmail(data) {
    return postAxios({ url: 'user/updateUserMail', data })
}
//获取OTP
export function getOtp() {
    return getAxios({ url: 'otp/getotp' })
}
//根据用户id查询该用户已发布的未被邀请的主播列表
export function getAnchorListById(data) {
    return postAxios({ url: 'pk/listUninvitedPublishedAnchorsByUserId', data })
}
//创建pk记录
export function createPkRecord(data) {
    return postAxios({ url: 'pk/createPkRecord', data })
}
//查询pk记录信息
export function queryPkRecord(data) {
    return postAxios({ url: 'pk/singleRecord', data })
}
//pk文章详情
export function pkArticleDetail(data) {
    return postAxios({ url: 'pk/pkInfoDetail', data })
}
//更新pk记录状态(同意/拒绝)
export function updatePkRecordStatus(data) {
    return postAxios({ url: 'pk/updatePkStatus', data })
}
//查询pk中每个场次的详细数据
export function queryPkDetail(data) {
    return postAxios({ url: 'pk/fetchDetailPkDataWithId', data })
}
//退出登录
export function logout(data) {
    return postAxios({ url: 'user/logout',data})
}
//忘记密码
export function forgetPassword(data) {
    return postAxios({ url: 'user/forgetMail', data })
}
//重设密码
export function resetPassword(data) {
    return postAxios({ url: 'user/resetPassword', data })
}