Authored by 王水玲

新潮教室bug修改

... ... @@ -216,7 +216,9 @@ $(document).on('touchstart', '.like-ico', function() {
});
// 增加亲密度请求
$('.add-intimacy').on('click', function() {
$('.add-intimacy').on('touchstart', function() {
event.stopPropagation();
$.ajax({
type: 'GET',
url: '/guang/starclass/sign',
... ...
... ... @@ -2,4 +2,4 @@
{{#each headTab}}
<li {{#if cur}} class="cur" {{/if}}><a href="{{ url }}">{{ name }}</a></li>
{{/each}}
</ul>
</ul>
\ No newline at end of file
... ...
... ... @@ -31,11 +31,11 @@ class StarClassModel
* @param $uid
* @return array
*/
public static function getStarClass($uid, $appVersion)
public static function getStarClass($uid)
{
$result = array();
//头部导航
$result['headTab'] = self::getHeadTab('index', $appVersion);
$result['headTab'] = self::getHeadTab('index');
//组装调资源位URL(获取星潮教室首页数据)
$res['starClassIndex'] = StarClassData::getResourceDataUrl(self::CODE_FLOOR_STARCLASS_INDEX);
... ... @@ -82,7 +82,7 @@ class StarClassModel
'week' => array(
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fn', 'Sat'
),
'homeSign' => true
'homeSign' => true,
)
);
}
... ... @@ -100,11 +100,11 @@ class StarClassModel
* 星专题
* @return array
*/
public static function getspecial($appVersion)
public static function getspecial()
{
$result = array();
//头部导航
$result['headTab'] = self::getHeadTab('special', $appVersion);
$result['headTab'] = self::getHeadTab('special');
//组装资源位获取星潮教室首页数据URL
$data = StarClassData::getResourceData(self::CODE_FLOOR_STARCLASS_SPECIAL);
... ... @@ -139,11 +139,11 @@ class StarClassModel
/**
* 星搭配页面
*/
public static function getCollocation($appVersion)
public static function getCollocation()
{
$result = array();
//头部导航
$result['headTab'] = self::getHeadTab('collocation', $appVersion);
$result['headTab'] = self::getHeadTab('collocation');
return $result;
}
... ... @@ -235,6 +235,7 @@ class StarClassModel
$result['signDay'] .= !empty($value['createTime']) ? date('d', $value['createTime']) . ',' : '';
$result['todayIntimacy'] = $value['addNum'];
}
$result['topUrl'] = Helpers::url('/guang/starclass/top');
$result['intimacyNum'] = isset($data['data']['addNum']) ? $data['data']['addNum'] : '0';
foreach ($data['data']['rankList'] as $key => $value) {
//排名数据按数组顺序排列
... ... @@ -257,20 +258,20 @@ class StarClassModel
/**
* 获取headTab
*/
public static function getHeadTab($tab, $appVersion)
public static function getHeadTab($tab)
{
$result = array(
array(
'name' => '全部',
'url' => Helpers::url('/guang/starclass/index', $appVersion),
'url' => Helpers::url('/guang/starclass/index'),
),
array(
'name' => '星专题',
'url' => Helpers::url('/guang/starclass/special', $appVersion)
'url' => Helpers::url('/guang/starclass/special')
),
array(
'name' => '星搭配',
'url' => Helpers::url('/guang/starclass/collocation', $appVersion)
'url' => Helpers::url('/guang/starclass/collocation')
),
// array(
// 'name' => '星鲜事',
... ...
... ... @@ -11,8 +11,8 @@ use Plugin\Helpers;
*/
class StarClassController extends AbstractAction
{
//定义是否APP变量
protected $_isApp = false;
private $_isApp = false;
/**
* 星潮教室首页
... ... @@ -21,16 +21,30 @@ class StarClassController extends AbstractAction
{
//获取uid
$uid = $this->getLoggedUid();
$appVersion = array();
if (!$this->_isApp) {
//设置头部公共导航
$this->setNavHeader('星潮教室', true, false);
if ($uid) {
$this->setCookie('uid', $uid);
}else{
$this->setCookie('uid', '', time() - 3600);
}
}else{
$appVersion = array('app_version'=>1);
$this->setCookie('isApp',true);
if ($uid) {
$this->setCookie('uid', $uid);
}else{
$this->setCookie('uid', '', time() - 3600);
}
}
//设置头部公共导航
$isApp = $this->getCookie('isApp', false);
if (!$isApp) {
$this->setNavHeader('星潮教室', true, false);
}
$this->setTitle('星潮教室');
//调用模型获得星潮教室首页数据
$data = StarClassModel::getStarClass($uid, $appVersion);
$data = StarClassModel::getStarClass($uid);
//渲染模板
$this->_view->display('index', array(
'trendClassHome' => $data,
... ... @@ -46,18 +60,16 @@ class StarClassController extends AbstractAction
public function specialAction()
{
//获取uid
$uid = $this->getLoggedUid();
$appVersion = array();
if (!$this->_isApp) {
$isApp = $this->getCookie('isApp', false);
if (!$isApp) {
//设置头部公共导航
$this->setNavHeader('星潮教室', true, false);
}else{
$appVersion = array('app_version'=>1);
}
$this->setTitle('星潮教室');
//调用模型获得星专题数据
$data = StarClassModel::getspecial($appVersion);
$data = StarClassModel::getspecial();
//渲染模板
$this->_view->display('subject', array(
... ... @@ -73,18 +85,16 @@ class StarClassController extends AbstractAction
public function collocationAction()
{
//获取uid
$uid = $this->getLoggedUid();
$appVersion = array();
if (!$this->_isApp) {
$isApp = $this->getCookie('isApp', false);
if (!$isApp) {
//设置头部公共导航
$this->setNavHeader('星潮教室', true, false);
}else{
$appVersion = array('app_version'=>1);
}
$this->setTitle('星潮教室');
//调用模板获得星搭配数据
$data = StarClassModel::getCollocation($appVersion);
$data = StarClassModel::getCollocation();
//渲染模板
$this->_view->display('collocation', array(
... ... @@ -104,8 +114,8 @@ class StarClassController extends AbstractAction
}
//获得必要参数
$page = $this->get('page',1);
$uid = $this->getLoggedUid();
$isApp = $this->_isApp;
$isApp = $this->getCookie('isApp', false);
$uid = $this->getCookie('uid', false);
//调取模型获得星搭配文章
$data = StarClassModel::ajaxCollocation($page, $uid, $isApp, $limit = 20);
... ... @@ -125,23 +135,20 @@ class StarClassController extends AbstractAction
public function topAction()
{
//获取uid
$uid = $this->getLoggedUid();
$appVersion = array();
//设置头部公共导航(此处返回键调转星潮教室首页)
if (!$this->_isApp) {
$isApp = $this->getCookie('isApp', false);
$uid = $this->getCookie('uid', false);
if (!$isApp) {
//设置头部公共导航(此处返回键调转星潮教室首页)
$url = Helpers::url('/guang/starclass/index');
//设置头部公共导航
$this->setNavHeader('星潮粉丝榜', $url, false);
}else{
$appVersion = array('app_version'=>1);
$url = Helpers::url('/guang/starclass/index', $appVersion);
}
$this->setTitle('星潮粉丝榜');
//根据客户端类型,进行未登录跳转
if (!$uid) {
$refer = Helpers::url('/guang/starclass/top');
if (!$this->_isApp) {
if (!$isApp) {
$this->go(Helpers::url('/signin.html', array('refer' => $refer)));
} else {
$referEncode = strtr($refer, array('/' => '\\/'));
... ... @@ -171,10 +178,12 @@ class StarClassController extends AbstractAction
}
//根据客户端类型,进行未登录跳转
$uid = $this->getLoggedUid();
$isApp = $this->getCookie('isApp', false);
$uid = $this->getCookie('uid', false);
if (!$uid) {
$refer = Helpers::url('/guang/starclass/index');
if (!$this->_isApp) {
if (!$isApp) {
$this->echoJson(array('code'=>201,'data'=>Helpers::url('/signin.html', array('refer' => $refer))));
} else {
$referEncode = strtr($refer, array('/' => '\\/'));
... ... @@ -189,24 +198,6 @@ class StarClassController extends AbstractAction
$this->echoJson($res);
}
/**
* 星鲜事-点赞
*/
public function setPraiseAction()
{
if(!$this->isAjax()){
return;
}
//获得客户端ID(点赞不需要登录)
$udid = $this->getUdid();
//获得文章ID
$articleId = $this->post('articleId');
//调取接口点赞
$result = StarClassData::setPraise($articleId, $udid);
$this->echoJson($result);
}
/**
* 星搭配-文章分享
... ... @@ -219,10 +210,11 @@ class StarClassController extends AbstractAction
$result = array();
//根据客户端类型,进行未登录跳转
$uid = $this->getLoggedUid();
$isApp = $this->getCookie('isApp', false);
$uid = $this->getCookie('uid', false);
if (!$uid) {
$refer = Helpers::url('/guang/starclass/collocation');
if (!$this->_isApp) {
if (!$isApp) {
$this->echoJson(array('code'=>201,'data'=>Helpers::url('/signin.html', array('refer' => $refer))));
} else {
$referEncode = strtr($refer, array('/' => '\\/'));
... ... @@ -247,10 +239,11 @@ class StarClassController extends AbstractAction
}
//根据客户端类型,进行未登录跳转
$uid = $this->getLoggedUid();
$uid = $this->getCookie('uid', false);
$isApp = $this->getCookie('isApp', false);
if (!$uid) {
$refer = Helpers::url('/guang/starclass/collocation');;
if (!$this->_isApp) {
if (!$isApp) {
$this->echoJson(array('code'=>201,'data'=>Helpers::url('/signin.html', array('refer' => $refer))));
} else {
$referEncode = strtr($refer, array('/' => '\\/'));
... ... @@ -277,6 +270,25 @@ class StarClassController extends AbstractAction
}
/**
* 星鲜事-点赞
*/
public function setPraiseAction()
{
if(!$this->isAjax()){
return;
}
//获得客户端ID(点赞不需要登录)
$udid = $this->getUdid();
//获得文章ID
$articleId = $this->post('articleId');
//调取接口点赞
$result = StarClassData::setPraise($articleId, $udid);
$this->echoJson($result);
}
/**
* 检测登录状态
*
* @return int
... ... @@ -289,7 +301,7 @@ class StarClassController extends AbstractAction
if ($this->_isApp) {
$uid = $this->get('uid');
} else {
$uid = $this->getUid();
$uid = $this->getUid(true);
}
return $uid;
... ...