<?php
/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 16/9/7
 * Time: 下午3:52
 */

defined('InShopNC') or exit('Access Invalid!');

require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
require_once(BASE_ROOT_PATH . '/helper/model_helper.php');
require_once(BASE_ROOT_PATH . '/helper/user_session/storage.php');
require_once(BASE_ROOT_PATH . '/helper/ugc_helper.php');
require_once(BASE_ROOT_PATH . '/helper/url_helper.php');

class specialControl extends mobileHomeControl
{
    public function __construct() {
        parent::__construct();
    }

    public function indexOp()
    {
        $special_id = intval($_GET['special_id']);
        if($special_id < 0) {
            return self::outerr(errcode::ErrParamter);
        }

        $spitem = spid_helper::instance()->special($special_id);
        if($spitem == false) {
            return self::outerr(errcode::ErrParamter,"该专题不存在");
        }

        QueueClient::push('onClickSpecial',['special_id' => $special_id]);
        if($spitem->from_user())
        {
            if(session_helper::need_wechat_author())
            {
                $author = new thrid_author\wxauthor();
                $url = author_url::ugc_url($special_id);
                $url = $author->enter($url);
                return self::outsuccess(['direct_uri' => $url],"redirect");
            }

            $ret = $this->pri_special($special_id);
            $ret['spitem'] = $spitem;
            $tpl_obj = new tpl_ugc($ret);
            self::outsuccess(['tpl_obj' => $tpl_obj],'ugc/content');
        } else {
            $ret = $this->pub_special($special_id);
            self::outsuccess($ret);
        }
    }

    public function submitOp()
    {
        $special_id = intval($_GET['special_id']);
        $spitem = spid_helper::instance()->special($special_id);

        if($special_id < 0 || $spitem == false) {
            return self::outerr(errcode::ErrParamter,"该文章不存在");
        }
        $content = urldecode($_GET['content']);
        if(empty($content)) {
            $options = false;
        }
        else {
            $options = json_decode($content,true);
            if($options == null) $options = false;
        }

        $result = ugc_helper::submit($special_id,$options,$err);
        if($result == false) {
            return self::outerr($err['code'],$err['msg']);
        }
        else
        {
            $vote_result = $result['vote_result'];
            $type_sn = $result['type_sn'];
            if(!empty($type_sn)) {
                $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&type_sn={$type_sn}";
                $type = bonus\type::create_by_sn($type_sn);
                $sender_id = $type->sender_id();
                $minfo = new member_info($sender_id);
                $avatar = $minfo->avatar();
            } else {
                $url = "";
                $avatar = '';
            }
            $answer_diff = $result['answer_diff'];

            return self::outsuccess(['special_id' => $special_id,
                'vote_result' => $vote_result,
                'answer_diff' => $answer_diff,
                'bonus_url' => $url,
                'num' => $result['num'],
                'amount' => $result['amount'],
                'bonus_type' => $result['bonus_type'],
                'sender_avatar' => $avatar]);
        }
    }

    protected function pub_special($special_id)
    {
        $specials = special_manager::instance()->special($special_id,$goods_ids,true);
        if (!empty($goods_ids))
        {
            $helper = new goods_helper();
            $goodsex = $helper->online_summary($goods_ids, $related_goods);

            return array('special_list' => $specials,
                'tabs' => special_manager::instance()->tabs($special_id),
                'summary'  => $goodsex['summary'],
                'groupbuy' => $goodsex['groupbuy'],
                'limitime' => $goodsex['limitime'],
                'bundling' => $goodsex['bundling'],
                'mobile_page' => mobile_page(1));
        }
        else
        {
            return array('special_list' => $specials,
                'summary'  => array(),
                'groupbuy' => array(),
                'limitime' => array(),
                'bundling' => array(),
                'mobile_page' => mobile_page(1));
        }
    }

    protected function pri_special($special_id)
    {
        $result = special_manager::instance()->special($special_id,$goods_ids,false);
        if (!empty($goods_ids))
        {
            $helper = new goods_helper();
            $goodsex = $helper->online_summary($goods_ids, $related_goods);

            return array('special_list' => $result['specials'],
                'sender_info' => $result['sender_info'],
                'special_info' => $result['special_info'],
                'summary'  => $goodsex['summary'],
                'groupbuy' => $goodsex['groupbuy'],
                'limitime' => $goodsex['limitime'],
                'bundling' => $goodsex['bundling'],
                'mobile_page' => mobile_page(1));
        }
        else
        {
            return array('special_list' => $result['specials'],
                'sender_info' => $result['sender_info'],
                'special_info' => $result['special_info'],
                'summary'  => array(),
                'groupbuy' => array(),
                'limitime' => array(),
                'bundling' => array(),
                'mobile_page' => mobile_page(1));
        }
    }
}

class tpl_ugc
{
    private $spitem;
    private $special_list;
    private $summary;
    private $mem_info;
    private $special;
    private $mQuestionIndex;
    private $mVoteIndex;
    private $mAuthorRelation;

    public function __construct($output)
    {
        $this->mQuestionIndex = 0;
        $this->mVoteIndex = 0;
        $this->spitem = $output['spitem'];
        $this->special_list = $output['special_list'];
        $this->summary = $output['summary'];
        if(!empty($output['sender_info'])) {
            $this->mem_info = new member_info($output['sender_info']);
        } else {
            $this->mem_info = null;
        }

        $special_id = $output['special_info']['special_id'];
        $mod_special = Model('mb_special');
        $special_info = $mod_special->getMbSpecialByID($special_id,'*',true);
        if(!empty($special_info)) {
            $this->special = new ugc\special($special_info);
        } else {
            $this->special = null;
        }

        if(session_helper::logined()) {
            $memberid = session_helper::memberid();
            if($this->special->memberid() == $memberid) {
                $this->mAuthorRelation = 2;
            }
            else
            {
                $ret = relation_helper::subscribed($memberid,$this->special->memberid());
                $this->mAuthorRelation = $ret == true ? 1 : 0;
            }

        } else {
            $this->mAuthorRelation = false;
        }
    }

    public function preview()
    {
        return $this->special->preview();
    }
    public function special_id()
    {
        return $this->special->special_id();
    }
    public function browse_title()
    {
        if(session_helper::isapp()) {
            return "文章内容";
        } else {
            $title = $this->special->share_title();
            return $title;
        }
    }

    public function title() {
        $title =  $this->special->share_title();
        $title = str_replace( array( "\n", "\r" ), array( " ", " " ), $title );
        return $title;
    }

    public function image() {
        return $this->special->share_img();
    }
    public function url() {
        $special_id = $this->special_id();
        return url_helper::ugc_url($special_id);
    }

    public function sub_title()
    {
        $desc = $this->special->description();
        $desc = str_replace( array( "\n", "\r" ), array( " ", " " ), $desc);

        if(empty($desc)) return "";
        else
            return $desc;
    }

    public function last_title()
    {
        $submit_rule = $this->special->submit_rule();
        if(!empty($submit_rule)) {
            $submit_rule->avaliable();
            $desc = "点击领取红包";
        } else {
            $desc = "熊猫美妆";
        }
        return $desc;
    }
    public function show_title()
    {
        $title = $this->spitem->share_title();
        if(!empty($title))
        {
            $str = "<div class=\"title\">
                        <h3>{$title}</h3>
                    </div>";
            echo $str;
        }
    }

    private function format_time($tm)
    {
        $cur_tm = time();
        $delta = $cur_tm - $tm;
        if($delta < 600) {
            return "刚刚";
        }
        elseif ($delta < 3600) {
            $delta = intval($delta / 60);
            return "{$delta}分钟前";
        }
        elseif($delta < 3600 * 24) {
            $delta = intval($delta / 3600);
            return "{$delta}小时前";
        }
        else {
            return strftime("%m-%d",$tm);
        }
    }

    public function show_sender()
    {
        if($this->mem_info != null)
        {
            $nick_name = $this->mem_info->nickname();
            $avatar = $this->mem_info->avatar();
            $pubtime = $this->special->pubtime();
            $pubtime = $this->format_time($pubtime);

            $av_str = "<img src=\"{$avatar}\" alt=\"熊猫美妆\">";//
            $name_str = "<div class=\"author_pro\">
                            <span>文/{$nick_name}</span >
                            <span class=\"release_date\">{$pubtime}</span>
                         </div>";
            $str = $av_str . $name_str;
        } else {
            $str = '';
        }
        echo $str;
    }

    public function show_blocks()
    {
        $this->mQuestionIndex = 0;
        foreach ($this->special_list as $block)
        {
            $item_type = $block['item_type'];
            $items = $block['items'];
            if($item_type == 'home_ugc' && !empty($items)) {
                $this->show_items($items);
            }
        }

        $this->show_submit();
        $this->show_answer_page();
        $this->show_appreciate();
        $this->show_comment_header();
    }
    private function show_submit()
    {
        $vote_single = $this->special->vote_single();
        $submitor = new ugc\special_submitor($this->special_id(),$vote_single);
        $special = $this->special;

        if(!$submitor->submited())
        {
            $rule = $special->submit_rule();
            if($rule != false) {
                $avaliable = $rule->avaliable();
            } else {
                $avaliable = false;
            }

            if($special->has_vote() || $special->has_question())
            {
                if($special->has_vote() && $special->has_question()) {
                    $content = "提交";
                }
                elseif($special->has_vote()) {
                    $content = "投票";
                }
                else{
                    $content = "提交";
                }

                if($rule != false && $avaliable == true)
                {
                    $content .= " （领红包）";
                }

                if($special->has_over()) {
                    $str = "<button class=\"button_vote button_null\" id=\"submit_btn\" disabled>{$content} 已过期</button>";
                } else {
                    $str = "<button class=\"button_vote\" id=\"submit_btn\">{$content}</button>";
                }
            }
            else
            {
                if($rule == false) {
                    return;
                }
                else
                {
                    if($avaliable)
                    {
                        $content = "领红包";
                        if($special->has_over()) {
                            $str = "<button class=\"button_vote button_null\" id=\"submit_btn\" disabled>{$content} 已过期</button>";
                        } else {
                            $str = "<button class=\"button_vote\" id=\"submit_btn\">{$content}</button>";
                        }
                    }
                }
            }
        }
        else  {
            $str = "<button class=\"button_vote button_null\" disabled>您已经提交过</button>";
        }
        echo $str;
    }

    private function show_comment_header()
    {
        $report_url = BASE_SITE_URL . "/mobile/index.php?act=member_ugc&op=report_page&special_id={$this->special_id()}";
        $str = '';
        $clicks = $this->special->clicks();
        if(!$this->preview())
        {
            $str .= "<div class=\"comment\">
                        <div class=\"pro\">
                            <div class=\"pro_title\">评论</div>
                            <div class=\"reading\">浏览数 {$clicks}</div>
                            <div class=\"complaint\">
                                <a href=\"{$report_url}\">投诉</a>
                            </div>
                        </div>
                        <div class=\"comment_list\"></div>
                      </div>";
        }

        echo $str;
    }

    private function show_items($items)
    {
        foreach ($items as $item)
        {
            $show_type = $item['show_type'];
            if($show_type == 'image') {
                $this->show_image($item);
            }
            elseif($show_type == 'text') {
                $this->show_text($item);
            }
            elseif($show_type == 'vote')
            {
                $vote_single = $this->special->vote_single();

                $submitor = new ugc\special_submitor($this->special_id(),$vote_single);
                if($submitor->submited()) {
                    $this->show_vote_result($item);
                } else {
                    $this->show_vote($item);
                }
                $this->mVoteIndex++;
            }
            elseif($show_type == 'question') {
                $this->show_question($item);
                $this->mQuestionIndex++;
            }
            elseif($show_type == 'goods') {
                $this->show_goods($item);
            }
            else {

            }
        }
    }

    private function goods_summary($goods_id)
    {
        foreach ($this->summary as $summary)
        {
            if($summary['goods_id'] == $goods_id) {
                return $summary;
            }
        }
        return false;
    }

    private function show_goods($item)
    {
        $goods_id = intval($item['data']);
        $summary = $this->goods_summary($goods_id);
        if($summary == false) return;
        $recoment = $item['reserved'];

        if(session_helper::isapp()) {
            $url = "xmmz://p.lrlz.com/goods/goods?goodsId={$goods_id}";
        } else {
            $url = BASE_SITE_URL . "/mshop/goods_detail?goods_id={$goods_id}";
        }

        if($summary['goods_storage'] <= 0) {
            $state = '<span class="badge_null">已经售罄</span>';
        }
        elseif($summary['act_id'] > 0) {
            $state = '<span class="badge_limit">限时特价</span>';
        }
        elseif($summary['is_new']) {
            $state = '<span class="badge_new">熊猫新品</span>';
        }
        else {
            $state = '';
        }

        $goods_price = $summary['goods_price'];
        $bonus_price = $summary['bonus_price'];
        $discount = $goods_price - $bonus_price;

        $str = "<div class=\"recommend_goods\">
                    <div class=\"goods_item\">
                        <a href=\"{$url}\">
                            {$state}
                            <div class=\"goods\">
                                <div class=\"goods_img\"><img src=\"{$summary['goods_image_url']}\" alt=\"熊猫美妆\"></div>
                                <div class=\"goods_desc\">
                                    <p class=\"goods_title\">{$summary['goods_mobile_name']}</p>
                                    <p class=\"goods_pro\">{$summary['goods_jingle']}</p>
                                    <p class=\"goods_price\">
                                        ¥{$bonus_price}
                                        <span class=\"shoppe\">专柜价 {$goods_price} / 红包抵<span class=\"bonus_price\">{$discount}</span>元</span>
                                    </p>
                                </div>
                            </div>";
        if(!empty($recoment))
        {
            $str        .= "<div class=\"recommend\">
                                <span class=\"label\">推荐理由：</span><span>{$recoment}</span>
                            </div>";
        }
        $str .=         "</a>
                    </div>
                </div>";
        echo $str;
    }
    private function show_question($item)
    {
        if(empty($item['data'])) return false;
        $options = json_decode($item['data'],true);

        $title = $item['title'];
        $qindex = $this->mQuestionIndex;
        $i = $qindex + 1;
        $show_title = "第{$i}题、{$title}";

        $reserved = $item['reserved'];
        $kv = preg_split('/=/',$reserved);
        if(!empty($kv))
        {
            $k = trim($kv[0]);
            $v = trim($kv[1]);
            if(!empty($k) && $k == 'answer_type') {
                $answer_type = $v;
            }
        }
        $answer_type = intval($answer_type);
        if($answer_type == 0) {
            $sanswer_type = '单选';
            $box = "radio";
        }
        else {
            $sanswer_type = '多选';
            $box = "checkbox";
        }

        $header = "<div class=\"question_list\">
                        <div class=\"question\">
                            <div class=\"question_pro\">
                                <div class=\"question_title\">{$show_title}</div>
                                <div class=\"question_type\" data-type=\"{$answer_type}\">/{$sanswer_type}</div>
                            </div>
                            <div class=\"question_options\">";
        $opindex = 65;
        $soptions = '';
        foreach ($options as $val)
        {
            $key = $val['id'];
            $option = $val['text'];

            $si = sprintf("%c",$opindex++);
            $soptions .=        "<div class=\"question_option\">
                                     <label>
                                         <input type=\"{$box}\" value=\"{$key}\" class=\"check\" name=\"question{$qindex}\">
                                         <span class=\"label\">{$si}、{$option}</span>
                                     </label>
                                  </div>";
        }
        $end =              '</div>
                        </div>
                    </div>';

        $str = "{$header}{$soptions}{$end}";
        echo $str;
    }

    private function show_vote($item)
    {
        if(empty($item['data'])) return false;
        $options = json_decode($item['data'],true);
        if(empty($options)) return false;
        $title = $item['title'];

        $reserved = $item['reserved'];
        $kv = preg_split('/=/',$reserved);
        if(!empty($kv))
        {
            $k = trim($kv[0]);
            $v = trim($kv[1]);
            if(!empty($k) && $k == 'vote_type') {
                $vote_type = $v;
            }
        }

        $vote_type = intval($vote_type);
        if($vote_type == 0) {
            $svote_type = '单选';
            $box = "radio";
        }
        elseif ($vote_type == 1) {
            $svote_type = '多选';
            $box = "checkbox";
        }
        else {
            $svote_type = '最多选两项';
            $box = "checkbox";
        }

        $index = $this->mVoteIndex + 1;
        $str = "<div class=\"vote\">
                    <div class=\"vote_pro\">
                        <div class=\"vote_question\">投票{$index}: {$title}</div>
                        <div class=\"vote_type\" data-type=\"{$vote_type}\">/{$svote_type}</div>
                    </div>
                    <div class=\"vote_options\">";
        foreach ($options as $val)
        {
            $key = $val['id'];
            $option = $val['text'];
            $soption = "<div class=\"vote_option\">
                            <label>
                                <input type=\"{$box}\" value=\"{$key}\" class=\"check\" name=\"vote{$this->mVoteIndex}\">
                                <span class=\"label\">{$option}</span>
                            </label>
                        </div>";
            $str .= $soption;
        }
        $str .=     '</div>';
        $str .= '</div>';

        echo $str;
    }

    private function show_vote_result($item)
    {
        if(empty($item['data'])) return false;
        $options = json_decode($item['data'],true);
        if(empty($options)) return false;
        $title = $item['title'];

        $reserved = $item['reserved'];
        $kv = preg_split('/=/',$reserved);
        if(!empty($kv))
        {
            $k = trim($kv[0]);
            $v = trim($kv[1]);
            if(!empty($k) && $k == 'vote_type') {
                $vote_type = $v;
            }
        }

        $vote_type = intval($vote_type);
        if($vote_type == 0) {
            $svote_type = '单选';
        }
        elseif ($vote_type == 1) {
            $svote_type = '多选';
        }
        else {
            $svote_type = '最多选两项';
        }

        $str = "<div class=\"vote\">
                    <div class=\"vote_pro\">
                        <div class=\"vote_question\">{$title}</div>
                        <div class=\"vote_type\" data-type=\"{$vote_type}\">/{$svote_type}</div>
                    </div>";

        $str .=    '<div class="results">';
        $vote_result = $this->special->vote_result();

        $result = $vote_result[$this->mVoteIndex];
        $total = 0;
        foreach ($result as $key => $val) {
            $total += $val;
        }

        foreach ($options as $val)
        {
            $id = $val['id'];
            $title = $val['text'];

            $count = $result[$id];
            if($total > 0) {
                $per = intval($count * 100 / $total + 0.5);
            } else {
                $per = 0;
            }

            $option =   "<div class=\"result\">
                            <div class=\"result_option\">{$title}</div>
                            <div class=\"status\">
                                <div class=\"status_line\">
                                    <div class=\"stat\"></div>
                                    <div class=\"status_bg\"></div>
                                </div>
                                <span class=\"num\">{$count}票</span>
                                <span class=\"percentage\">{$per}%</span>
                            </div>
                          </div>";
            $str .= $option;
        }
        $str .=     '</div>';
        $str .= '</div>';

        echo $str;
    }

    private function show_text($item)
    {
        $data  = $item['data'];
        echo "<article>{$data}</article>";
    }

    private function show_image($item)
    {
        $image = $item['show_data'];
        $type  = $item['type'];
        $title = $item['title'];

        if($type == 'url')
        {
            $url  = $item['data'];
            $str = "<div class=\"thumbnail\">
                        <a href=\"{$url}\">
                            <div class=\"thumbnail_image\">
                                <img src=\"/data/resource/mobile/ugc/images/picLazy_load.png\" data-original=\"{$image}\" alt=\"熊猫美妆\">
                            </div>                     
                        </a>                        
                        <div class=\"thumbnail_pro\">{$title}</div>
                    </div>";
        }
        elseif($type == 'video')
        {
            $video  = $item['data'];
            $str = "<div class=\"thumbnail\">
                        <div class=\"video_box\" data-poster=\"{$image}\" data-src=\"{$video}\"></div>
                        <div class=\"thumbnail_pro\">$title</div>
                    </div>";
        }
        else
        {
            $str = "<div class=\"thumbnail\">
                        <div class=\"thumbnail_image\">
                             <img src=\"/data/resource/mobile/ugc/images/picLazy_load.png\" data-original=\"{$image}\" alt=\"熊猫美妆\">
                        </div>
                        <div class=\"thumbnail_pro\">{$title}</div>
                    </div>";
        }
        echo $str;
    }

    public function show_comments()
    {
        if($this->preview()) return;
        $supporter = new ugc\special_support($this->special_id(),0);
        $supported = $supporter->supported();

        $str = "<div class=\"bottom_flex\">
                    <div class=\"msg_btn\">我来说两句</div>";
        if($supported) {
            $str .= "<a href=\"javascript:void(0)\" class=\"like_btn active\">
                        <span class=\"like_icon_null like_icon\"></span>
                    </a>";
        } else {
            $str .= "<a href=\"javascript:void(0)\" class=\"like_btn active\">
                        <span class=\"like_icon_null\"></span>
                    </a>";
        }

        $str .= "<a href=\"javascript:void(0)\" class=\"comment_label\">
                        <span class=\"msg_icon_null\"></span>";
        $comments = $this->special->comments();
        if($comments > 0) {
            $str .= "<span class=\"superscript\">{$comments}</span>";
        }
        $str .= "</a>";

        if(session_helper::isapp())
        {
            $str .=    "<a href=\"javascript:void(0)\">
                            <span class=\"share_icon_null\"></span>
                        </a>
                    </div>";
        } else {
            $str .= "<a href=\" \" class=\"open_app_btn\">打开APP</a></div>";
        }

        echo $str;
    }
    private function show_appreciate()
    {
        $fappreciate = $this->special->has_appreciate();
        if($fappreciate == false) return;

        $nums = $this->special->appreciates();
        $header = "<div class=\"appreciate\">
                        <p class=\"appreciate_pro\">如果你喜欢该文章，请随意打赏。</p >
                        <div class=\"appreciate_box\">
                            <div class=\"btn_appreciate\">";
        if($nums > 0)
        {
            $header .=          "打赏<span class=\"appreciate_num\"> | 已有{$nums}次打赏</span>";
            $header .=      "</div>
                        </div>
                        <div class=\"appreciate_users\">";

            $avatars = $this->appreciate_avatars($this->special_id(),20);
            $sAvatars = '';
            foreach ($avatars as $avatar) {
                $sAvatars .= "<img src=\"{$avatar}\">";
            }
            $header .= $sAvatars;
            $header .= '</div>';
            if($nums > 20) {
                $header .= '<div class="appreciate_label">....超20人打赏</div>';
            }
        }
        else {
            $header .=          "打赏";
            $header .=     "</div>";
            $header .=  "</div>";
        }
        $header .='</div>';
        echo $header;
    }

    private function appreciate_avatars($special_id,$count)
    {
        $mod = Model('appreciate');
        $items = $mod->getTopAppreciate($special_id,'*',$count);

        $uids = [];
        foreach ($items as $item) {
            $uid = intval($item['member_id']);
            $uids[] = $uid;
        }

        $avatars = [];
        if(!empty($uids))
        {
            $mod_member = Model('member');
            $mInfos = $mod_member->getMemberList(array('member_id' => ['in',$uids]));

            foreach ($mInfos as $info) {
                $minfo = new member_info($info);
                $avatar = $minfo->avatar();
                $avatars[] = $avatar;
            }
        }

        return $avatars;
    }
    private function show_answer_page()
    {
        $specialid = $this->special_id();
        if($specialid <= 0) return;

        $special = $this->special;
        if($special->has_question()) {
            $answer_page = true;
        }

        if(isset($answer_page) && $answer_page == true)
        {
            $mod_answer = Model('ugc_answer');
            $count = $mod_answer->counts($specialid);
            if($count > 0) {
                $url = BASE_SITE_URL . "/mobile/index.php?act=member_ugc&op=answer_page&client_type=wap&special_id={$specialid}";
                $str = "<p class=\"look_question_result\" style=\"margin-top:40px; color: #FF4E4E; line-height: 70px; text-align: center;font-size: 26px;\"><a href=\"{$url}\">查看答题情况>></a></p >";
                echo $str;
                return;
            }
        }

        $rule = $this->special->submit_rule();
        if(!empty($rule))
        {
            $type_sn = $rule->type_sn();
            if(!empty($type_sn)) {
                $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$type_sn}";
                $str = "<p class=\"look_question_result\" style=\"margin-top:40px; color: #FF4E4E; line-height: 70px; text-align: center;font-size: 26px;\"><a href=\"{$url}\">查看红包领取情况>></a></p >";
                echo $str;
                return;
            }
        }
    }

    public function show_relation()
    {
        if($this->mAuthorRelation == 0) {
            echo '<div class="focus">+关注</div>';
        }
        elseif($this->mAuthorRelation == 1) {
            echo '<div class="focus active">已关注</div>';
        }
        else {

        }
    }
}
