/**
 * @description 兑换码数据
 * @author kaka
 */

import { Data } from "../../../mk/data/Data";

export default class RedeemData extends Data {
    init_redeemData = false;
    _redeemData: any = null;

    init_btnChange = false;
    showBtn = true;

    set redeemData(value) {
        this._redeemData = value;
        this.init_redeemData = true;
        this.showBtn = this.redeemData.code == 1;
        this.init_btnChange = true;
    }

    get redeemData() {
        return this._redeemData;
    }

    init() {
        this.redeemGetRedemption();
    }

    /**兑换礼包*/
    async redeemExchange(input: string) {
        let data = { code: input };
        let response = await mk.http.sendData('redemption/exchange', data);

        if (response.errcode != 0) {
            return;
        }

        return response;
    }

    /**获取礼包*/
    async redeemGetRedemption() {
        let data = {};
        let response = await mk.http.sendData('redemption/getRedemption', data);

        if (response.errcode != 0) {
            return;
        }

        this.redeemData = response.data;

        return response;
    }
}
