Esempio n. 1
0
    /**
     * 指定用户关注的人
     *
     * @param integer $uid
     */
    public function actionUidConcern($uid)
    {
        $login_uid = ZCommonSessionFun::get_user_id();
        $this->layout = false;
        $uid = intval($uid);
        $this->view->title = User::getUidShowName($uid) . '关注的人';
        $model = new UsersFriends();
        $condition['uid'] = $uid;
        $data = $model->getList($condition, null, $this->pageSize);
        if (isset($_GET['ajax'])) {
            $status = 0;
            $html = '';
            if (isset($_GET[$data['pagination']->pageParam]) && $data['pagination']->pageCount < $_GET[$data['pagination']->pageParam]) {
                $data['models'] = [];
            }
            $my_fans_uids = ZCommonFun::listData($data['models'], 'fuid', 'fuid');
            $concer_data = [];
            if (count($my_fans_uids) > 0) {
                $my_fans_uids_str = implode(',', $my_fans_uids);
                $sql = <<<str

select uf.uid uf_uid,uf.fuid fans /*我关注的人*/,(
select count(id) from users_friends where uid=uf_uid and fuid={$login_uid}
) fans_is_concern_ta /*uf.uid关注了他 */
,(
select count(id) from users_friends where uid={$login_uid} and fuid=uf_uid
)ta_is_concern_fans /* 他关注了uf.uid */
,up.*
from users_friends uf
left join user_profile up on up.uid=uf.uid
where uf.uid in({$my_fans_uids_str} )
group by uf.uid

str;
                $query = new Query();
                $concer_data = $query->createCommand()->setSql($sql)->queryAll();
            }
            //             ZCommonFun::print_r_debug($concer_data);
            //             exit;
            // ZCommonFun::print_r_debug($data);
            foreach ($data['models'] as $key => $row) {
                $ta_url = Yii::$app->urlManager->createUrl(['my/personal-page', 'uid' => $row->fuid]);
                $ta_nickname = User::getDefaultTaNickname();
                $ta_image = User::getDefaultHead_image();
                $ta_intro = User::getDefaultTaIntro();
                $concer_text = '关注';
                $is_find = false;
                foreach ($concer_data as $key2 => $row2) {
                    if ($row->fuid == $row2['uf_uid']) {
                        !empty($row2['nickname']) ? $ta_nickname = $row2['nickname'] : null;
                        !empty($row2['head_image']) ? $ta_image = $row2['head_image'] : null;
                        !empty($row2['intro']) ? $ta_intro = $row2['intro'] : null;
                        if ($row2['fans_is_concern_ta'] && $row2['ta_is_concern_fans']) {
                            $url = '';
                            $concer_text = '相互关注';
                        } else {
                            if ($row2['ta_is_concern_fans']) {
                                $url = '';
                                $concer_text = '已关注';
                            } else {
                                $url = Yii::$app->urlManager->createUrl(['my/concern', 'fuid' => $row->fuid]);
                            }
                        }
                        $is_find = true;
                        break;
                    }
                }
                if (!$is_find) {
                    $url = Yii::$app->urlManager->createUrl(['my/concern', 'fuid' => $row->fuid]);
                }
                $html .= <<<str
                <ul class="list" id="answer-view" style="margin:0;">
           <li class="diy-item"><a
\t\t\t\t\thref="{$ta_url}"
\t\t\t\t\ttarget="_blank">
\t\t\t\t\t\t<figure class="cover">
\t\t\t\t\t\t\t<img src="{$ta_image}"
\t\t\t\t\t\t\t\tclass="tuijian-img">
\t\t\t\t\t\t</figure>
\t\t\t\t\t\t<div class="diy-meta">
            \t\t\t\t<div class="title mui-ellipsis">{$ta_nickname}</div>
            \t\t\t\t<span class="iconfont icon-start-filled5"></span>
            \t\t\t\t<div class="desc mui-ellipsis">{$ta_intro}</div>
            \t\t\t</div>
\t\t\t\t</a>
            \t<a url="{$url}" class="play concern" onclick="concern(this)" data-ui="danger small icon-right">{$concer_text}<i class="iconfont icon-right"></i>
\t</a>
            \t\t\t\t    </li>
                </ul>
str;
            }
            echo $html;
            exit;
        }
        return $this->render('fans', ['uid' => $uid, 'ajax_url' => Yii::$app->urlManager->createUrl(['my/uid-concern', 'uid' => $uid, 'page' => '#page#', 'ajax' => '1'])]);
    }
Esempio n. 2
0
echo $url_logout;
?>
">退出</a>
				</div>
				<div >
					测过<sapn class="common-color"><?php 
echo UserProfile::getTestingCount(ZCommonSessionFun::get_user_id());
?>
</sapn>次
				</div>
				<div onclick="javascript:window.top.document.location='<?php 
echo Yii::$app->urlManager->createUrl(['my/uid-fans', 'uid' => $sessionUser['uid']]);
?>
'">
					粉丝<sapn class="common-color"><?php 
echo UsersFriends::get_concern_count(ZCommonSessionFun::get_user_id());
?>
</sapn>人
				</div>
			</td>
		</tr>
	</table>
</div>
<?php 
?>
<nav class="user-menu">
	<a class="<?php 
echo $header_user_name_select0;
?>
" href="<?php 
echo $url_my_test;
Esempio n. 3
0
    padding: 0 6px;
    border: 1px solid;
    border-radius: 3px;
}
</style>
<script src="./js/concern.js"></script>
<?php 
use common\z\ZCommonSessionFun;
use common\z\ZCommonFun;
use common\models\UsersFriends;
$login_uid = ZCommonSessionFun::get_user_id();
$concern_status = 0;
if ($login_uid < 1) {
    $concern_status = 0;
} else {
    $model_UsersFriends = new UsersFriends();
    $concern_status = $model_UsersFriends->get_user_each_concern($login_uid, $model_Users->uid);
}
$concer_url = '';
$concer_text = '';
switch ($concern_status) {
    case 1:
        $concer_url = Yii::$app->urlManager->createUrl(['my/concern', 'fuid' => $model_Users->uid]);
        $concer_text = '已相互关注';
        break;
    case 2:
        $concer_url = '';
        $concer_text = '已关注';
        break;
    default:
        $concer_url = Yii::$app->urlManager->createUrl(['my/concern', 'fuid' => $model_Users->uid]);
Esempio n. 4
0
 public function getList($condition, $page, $page_size)
 {
     $pagination = new Pagination();
     $model = new UsersFriends();
     $query = $model->find();
     $query->where($condition);
     $count = $query->count();
     $models = $query->all();
     isset($models[0]) ? null : ($models = []);
     $pagination->pageSize = $page_size;
     //总数量
     $pagination->totalCount = $count;
     $offset = $pagination->getOffset();
     $limit = $pagination->getLimit();
     $query->offset($offset);
     $query->limit($limit);
     $temp_data['models'] = $models;
     $temp_data['pagination'] = $pagination;
     return $temp_data;
 }