ActivityModel.lua 1.91 KB
cc.exports.ActivityModel = {}

ActivityModel.fightLotteryInfo = {};

function ActivityModel.init()
    cmsg.on("gateway_msg.show_btl_cnt_reward_msg_res",ActivityModel.onFightLotteryFun);
    cmsg.on("gateway_msg.get_btl_cnt_reward_msg_res",ActivityModel.onGetLotteryFun);
end

function ActivityModel.getFightLotteryInfo()
    SocketClient:getInstance():send("gateway_msg.show_btl_cnt_reward_msg", 
    {
    });
end

function ActivityModel.onFightLotteryFun(params)
    if params.errcode == EnumErrorCode.EC_SUCCESS then
        ActivityModel.fightLotteryInfo = {};
        ActivityModel.fightLotteryInfo.btl_cnt = params.data.btl_cnt;
        ActivityModel.fightLotteryInfo.get_sec = params.data.get_sec;
        EventListener.dispatchEvent(EnumEvent.ACT_SHOW_FIGHT_LOTTERY);
    end
end

function ActivityModel.getLottery()
    SocketClient:getInstance():send("gateway_msg.get_btl_cnt_reward_msg", 
    {
    });
end

function ActivityModel.onGetLotteryFun(params)
    if params.errcode == EnumErrorCode.EC_SUCCESS then
        ActivityModel.fightLotteryInfo.get_sec = UserModel.time_second;

        EventListener.dispatchEvent(EnumEvent.ACT_GET_LOTTERY,{id=params.data.id});
        EventListener.dispatchEvent(EnumEvent.UPDATE_ACTIVITY);
    end
end

function ActivityModel.getCurrentFirstPayInfo()
    local firstPayList = ShopInfo.getFirstPayList();
    local firstInfo = nil;
    for i,v in ipairs(firstPayList) do
        if not TableUtil.IsInTable(UserModel.first_pay_id,v.id) then
            firstInfo = v;
            break;
        end
    end
    return firstInfo;
end

--ȡÿ׳
function ActivityModel.getCurrentFirstPayDailyInfo()
    local dailyPayList = ShopInfo.getDailyPayList();
    local payInfo = nil;
    for i,v in ipairs(dailyPayList) do
        if not TableUtil.IsInTable(UserModel.first_pay_daily_id,v.id) then
            payInfo = v;
            break;
        end
    end
    return payInfo;
end

return ActivityModel