import request from '../utils/request.js'

class LuckDraw extends request {

    static getActivityDetail(id) {
        let params = {
            id
        }
        return this.postRequest(`${this.BASE_URL}open/luck-draw/detail`, params, true)
    }

    static drawPrize(activityId, mobile) {
        const params = {
            activityId,
            mobile
        }
        return this.postRequest(`${this.BASE_URL}open/luck-draw/draw-prize`, params, true)
    }

    static getHitList(activityId) {
        const params = {
            activityId
        }
        return this.postRequest(`${this.BASE_URL}open/luck-draw/hit-list`, params, true)
    }

    static getActivityList(params) {
        return this.postRequest(`${this.BASE_URL}open/luck-draw/activity-list`, params)
    }

    /**
     * 用户抽奖记录
     * @param {} params 
     */
    static getUserDrawRecord(params) {
        return this.postRequest(`${this.BASE_URL}open/luck-draw/user-draw-record`, params)
    }

    /**
     * @param {*} params 
     */
    static getUserPrizeList(params) {
        return this.postRequest(`${this.BASE_URL}open/luck-draw/user-prize-list`, params)
    }

    /**
     * 分享回调
     */
    static shareActivity(activityId, mobile, catchErrorFunc) {
        const params = {
            activityId,
            mobile
        }
        return this.postRequest(`${this.BASE_URL}open/luck-draw/share-activity`, params, true, catchErrorFunc)
    }

    static getTimes(activityId, mobile) {
        const params = {
            activityId,
            mobile
        }
        return this.postRequest(`${this.BASE_URL}open/luck-draw/get-times`, params, true)
    }

}

export default LuckDraw;

// 示例
// LuckDraw.drawPrize(3, "16602120168").then(res => {

// }).catch(_ => {})
// LuckDraw.getHitList(3).then(res => {

// }).catch(_ => {})
// LuckDraw.getActivityList({
//     page: 1,
//     pageSize: 20
// }).then(res => {

// }).catch(_ => {})

// LuckDraw.getUserDrawRecord({
//     mobile: "16602120168",
//     activityId: 3,
//     page: 1,
//     pageSize: 20
// }).then(res => {

// }).catch(_ => {})

// LuckDraw.getUserPrizeList({
//     mobile: "16602120168",
//     goodsType: 1,
//     page: 1,
//     pageSize: 20
// }).then(res => {

// }).catch(_ => {})

// LuckDraw.shareActivity(3, "16602120168").then(res => {
// }).catch(_ => {})
// LuckDraw.getTimes(3, "16602120168").then(res => {
// }).catch(_ => {})