<?php
/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2017/11/9
 * Time: 下午7:07
 */


require_once(BASE_ROOT_PATH . '/helper/model_helper.php');

class invite_share
{
    public function info($nickname,$pos)
    {
        $infos = [];
        if(empty($nickname)) {
            $infos[] = ['title' => "“你爱我吗？”先帮我赚红包再说",'sub_title' => "熊猫美妆这个红包不领简直太亏了，小手一抖，红包无上限！"];
            $infos[] = ['title' => "我正在赚100%红包，加入我的粉丝团",'sub_title' => "领红包注册即可赚钱，大牌美妆免费等你拿！"];
        } else {
            $infos[] = ['title' => "“你爱我吗？”先帮我赚红包再说",'sub_title' => "熊猫美妆这个红包不领简直太亏了，小手一抖，红包无上限！"];
            $infos[] = ['title' => "我正在赚100%红包，加入我的粉丝团",'sub_title' => "领红包注册即可赚钱，大牌美妆免费等你拿！"];
            $infos[] = ['title' => "{$nickname}邀请您加入他的粉丝团，瓜分100%红包",'sub_title' => "边买边赚，每月为你省下1000元美妆支出"];
            $infos[] = ['title' => "和我一起上熊猫美妆，边买边赚钱",'sub_title' => "{$nickname} 邀请您加入他的粉丝团，瓜分100%红包！"];
            $infos[] = ['title' => "考验友谊！这个红包你帮我领，你也有得赚！",'sub_title' => "{$nickname} 邀请您加入他的粉丝团，瓜分100%红包！"];
            $infos[] = ['title' => "送您的100%红包待领取，请尽快查收",'sub_title' => "{$nickname} 邀请您加入他的粉丝团，瓜分100%红包！"];
        }

        $img = RESOURCE_SITE_URL . "/mobile/invite_friend/images/share.png";

        $count = count($infos);
        if($pos >= 0 && $pos < $count) {
            $result = $infos[$pos];
        } else {
            $pos = mt_rand(0,$count - 1);
            $result = $infos[$pos];
        }
        $result['img'] = $img;
        return $result;
    }
}

class invite_helper
{
    public static function share_info($user,$pos = -1)
    {
        if($user > 0) {
            $user_info = new member_info($user);
            $nickname  = $user_info->nickname();
        } else {
            $nickname = "";
        }

        $sharer = new invite_share();
        return $sharer->info($nickname,$pos);
    }
}