Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
郭成尧
9 years ago
Commit
5a98bda6e7ca544d4e685cff2aab78294e9b7bca
2 parents
d169c335
49d64ca5
Merge branch 'hotfix/guangFav' into release/4.8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
45 deletions
library/Plugin/Helpers.php
static/js/guang/info.js
template/m.yohobuy.com/partials/guang/tvls.phtml
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Opt.php
library/Plugin/Helpers.php
View file @
5a98bda
...
...
@@ -372,7 +372,14 @@ class Helpers
if
(
$isApp
)
{
$result
[
'collect'
]
=
array
();
$result
[
'collect'
][
'isCollected'
]
=
isset
(
$articleData
[
'isFavor'
])
&&
$articleData
[
'isFavor'
]
===
'Y'
;
$result
[
'collect'
][
'url'
]
=
!
empty
(
$uid
)
?
'javascript:;'
:
strtr
(
$articleData
[
'url'
],
array
(
'"islogin":"N"'
=>
'"islogin":"Y"'
));
// $originUrl = 'http:' . Helpers::url('/author/index',null,'guang') . $_SERVER["QUERY_STRING"]; // 跳转回的链接 https
$originUrl
=
Helpers
::
url
(
'/author/index'
,
null
,
'guang'
)
.
$_SERVER
[
"QUERY_STRING"
];
// 跳转回的链接
$collectUrl
=
'javascript:;'
;
// 根据用户是否登录做处理的链接
if
(
empty
(
$uid
))
{
$playUrlEncode
=
strtr
(
$originUrl
,
array
(
'/'
=>
'\\/'
));
$collectUrl
=
$originUrl
.
'?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"'
.
$playUrlEncode
.
'","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}'
;
}
$result
[
'collect'
][
'url'
]
=
$collectUrl
;
}
// 点赞
else
{
$result
[
'like'
]
=
array
();
...
...
static/js/guang/info.js
View file @
5a98bda
...
...
@@ -160,26 +160,16 @@ function initInfosEvt($container) {
type
:
'POST'
,
url
:
'/guang/opt/collectArticle'
,
data
:
{
id
:
getUrlParam
(
'id'
),
id
:
$info
.
data
(
'id'
),
opt
:
opt
,
yh_channel
:
yhChannel
,
uid
:
getUrlParam
(
'uid'
)
},
success
:
function
(
data
)
{
if
(
data
.
code
&&
data
.
code
===
200
)
{
if
(
data
.
data
.
jump
)
{
if
(
$
(
'#intimacy-link'
).
length
<=
0
)
{
$
(
'body'
).
append
(
'<a href=\''
+
data
.
data
.
jumpUrl
+
'\' style="display:none;" id="intimacy-link">'
+
'<span class="intimacy-link"></span></a>'
);
}
$
(
'.intimacy-link'
).
click
();
}
else
{
//切换收藏状态
$btn
.
toggleClass
(
'collected'
);
}
//切换收藏状态
$btn
.
toggleClass
(
'collected'
);
}
},
error
:
function
()
{
...
...
template/m.yohobuy.com/partials/guang/tvls.phtml
View file @
5a98bda
...
...
@@ -9,7 +9,9 @@
<span class="like-count">{{count}}</span>
{{/ like}}
{{# collect}}
<a href={{url}}>
<i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}"></i>
</a>
{{/ collect}}
{{# share}}
<a href="{{.}}" class="iconfont share-btn"></a>
...
...
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Opt.php
View file @
5a98bda
...
...
@@ -52,51 +52,35 @@ 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
));
break
;
}
else
{
/* 执行点赞或取消操作 */
$opt
=
$this
->
post
(
'opt'
,
'ok'
);
$data
=
OptData
::
collectArticle
(
$uid
,
$id
,
$opt
);
if
(
!
$data
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'操作失败'
,
'data'
=>
''
);
break
;
}
}
}
else
{
/* 非 app 不需要点赞*/
$result
=
array
(
'code'
=>
400
,
'message'
=>
'不是App!'
,
'data'
=>
''
);
$uid
=
$this
->
post
(
'uid'
);
if
(
empty
(
$uid
)
||
!
is_numeric
(
$uid
))
{
break
;
}
/* 执行点赞或取消操作 */
$opt
=
$this
->
post
(
'opt'
,
'ok'
);
$data
=
OptData
::
collectArticle
(
$uid
,
$id
,
$opt
);
if
(
!
$data
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'操作失败'
,
'data'
=>
''
);
break
;
}
$result
=
array
(
'code'
=>
200
,
'message'
=>
'成功'
,
'data'
=>
''
);
}
while
(
false
);
$this
->
echoJson
(
$result
);
...
...
Please
register
or
login
to post a comment