Guang.php 2.44 KB
<?php

namespace Home;

use LibModels\Wap\Home\GuangData;
use Action\AbstractAction;
use Plugin\Helpers;

/**
 * 我的逛数据处理
 */
class GuangModel
{

    //获取我的逛列表
    public static function getMyGuang($uid, $page,$yh_channel=1, $gender = '1,3', $limit = 10)
    {
        $result = array();
        //调用接口获取数据
        $res = GuangData::getGuangInfo($uid, $page, $yh_channel,$gender, $limit);
        $guangInfo = $res['data']['data'];
        if ($guangInfo)
        {
            foreach ($guangInfo as $k => $v)
            {
                $result[$k]['id'] = $v['id'];
                $result[$k]['author'] = $v['author'];
                $tag = self::getTag(TRUE, intval($v['category_id']));
                $result[$k]['url'] = $v['url'];
                $result[$k]['img'] = $v['src'];
                $result[$k]['title'] = $v['title'];
                $result[$k]['text'] = $v['intro'];
                $result[$k]['pageView'] = $v['views_num'];
                $result[$k]['publish_time'] = $v['publish_time'];
                $like = ($v['isPraise'] == "Y") ? true : false;
                $collect = ($v['isFavor'] == "Y") ? true : false;
                $result[$k]['like'] = array('isLiked' => $like, 'count' => $v['praise_num']);
                $result[$k]['collect'] = array('isCollected' => $collect, 'url' => $v['url']);
                $result[$k] += $tag;
                $result[$k]['share'] = $v['url'];
            }
        }

        return $result;
    }

    //【标签】isTip-小贴士;isCollocation-搭配 isFashionMan-潮人 isFashionGood-潮品 isTopic-话题
    private static function getTag($isShow, $tagId)
    {
        $ret['showTags'] = $isShow;
        $ret['isTopic'] = false;
        $ret['isCollocation'] = false;
        $ret['isFashionMan'] = false;
        $ret['isFashionGood'] = false;
        $ret['isTip'] = false;
        switch ($tagId)
        {
            case 1:
                $ret['isTopic'] = true;
                break;
            case 2:
                $ret['isCollocation'] = true;
                break;
            case 3:
                $ret['isFashionMan'] = true;
                break;
            case 4:
                $ret['isFashionGood'] = true;
                break;
            case 5:
                $ret['isTip'] = true;
                break;
            default:
                $ret['showTags'] = FALSE;
                break;
        }
        return $ret;
    }

}