...
|
...
|
@@ -52,39 +52,25 @@ class OptController extends AbstractAction |
|
|
*/
|
|
|
public function collectArticleAction()
|
|
|
{
|
|
|
$result = array('code' => 200, 'message' => '成功!', 'data' => '');
|
|
|
$jumpUrl = '';
|
|
|
$isNoLogin = false;
|
|
|
$result = array('code' => 400, 'message' => '您未登录,无法收藏或者取消收藏。请先登录!', 'data' => '');
|
|
|
|
|
|
do {
|
|
|
/* 判断是不是AJAX请求 */
|
|
|
if (!$this->isAjax()) {
|
|
|
$result = array('code' => 400, 'message' => '不是Ajax请求!', 'data' => '');
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 判断参数是否有效 */
|
|
|
$id = $this->post('id');
|
|
|
if (!is_numeric($id)) {
|
|
|
$result = array('code' => 400, 'message' => '没有ID!', 'data' => '');
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 判断用户是否登录 */
|
|
|
$uid = $this->get('uid');
|
|
|
$isNoLogin = empty($uid) || !is_numeric($uid);
|
|
|
|
|
|
/* 如果有 yh_channel 是 app */
|
|
|
if ($yhChannel = $this->post('yh_channel')) {
|
|
|
|
|
|
/* 如果没有登录,拼接 App 登录规则 */
|
|
|
if ($isNoLogin) {
|
|
|
$playUrl = Helpers::url('/author/index', '', 'guang');
|
|
|
$playUrlEncode = strtr($playUrl, array('/' => '\\/'));
|
|
|
$jumpUrl = $playUrl . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $playUrlEncode . '","param":{"from":"app","id":"' . $id . '",""yh_channel":"' . $yhChannel . '",""uid":"' . $uid . '"}},"requesturl":{"url":"","param":{}},"priority":"N"}}&uid=' . $uid;
|
|
|
$result = array('code' => 200, 'message' => '未登录', 'data' => array('jumpUrl' => $jumpUrl, 'jump' => true));
|
|
|
$uid = $this->post('uid');
|
|
|
if (empty($uid) || !is_numeric($uid)) {
|
|
|
break;
|
|
|
} else {
|
|
|
}
|
|
|
|
|
|
/* 执行点赞或取消操作 */
|
|
|
$opt = $this->post('opt', 'ok');
|
...
|
...
|
@@ -93,10 +79,8 @@ class OptController extends AbstractAction |
|
|
$result = array('code' => 400, 'message' => '操作失败', 'data' => '');
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
} else { /* 非 app 不需要点赞*/
|
|
|
$result = array('code' => 400, 'message' => '不是App!', 'data' => '');
|
|
|
}
|
|
|
|
|
|
$result = array('code' => 200, 'message' => '成功', 'data' => '');
|
|
|
} while (false);
|
|
|
|
|
|
$this->echoJson($result);
|
...
|
...
|
|