切换导航条
此项目
正在载入...
登录
景龙
/
xingqiu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
景龙
6 years ago
提交
920a928a5c390372fc0bd8809a4d35861c50f23d
1 个父辈
d1e885c8
1 个管道 的构建
通过
耗费 3 秒
微信登录
变更
4
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
41 行增加
和
24 行删除
app/portal/controller/LoginController.php
public/themes/simpleboot3/portal/login/third_login.html
public/themes/simpleboot3/public/slide.html
public/themes/simpleboot3_mobile/portal/login/login.html
app/portal/controller/LoginController.php
查看文件 @
920a928
...
...
@@ -21,7 +21,7 @@ class LoginController extends HomeBaseController
private
$limit
=
8
;
//收藏,搜索分页
private
$appkey
=
737607150
;
//微博appkey
private
$appsecret
=
'd80b43a1e74e8ba095590b36a3459480'
;
//微博appsecret
private
$redirect_uri
=
'http://www.
starplanet
.cn/portal/login/wb_login'
;
//回调地址
private
$redirect_uri
=
'http://www.
xingqiu
.cn/portal/login/wb_login'
;
//回调地址
private
$appkey1
=
'wx9cfa880272f186bf'
;
//微信appkey
private
$appsecret1
=
'11b643393b1e54d6ef5eaa984ba4e545'
;
//微信appsecret
...
...
@@ -352,19 +352,44 @@ class LoginController extends HomeBaseController
//第三方微信登录
public
function
wx_login
(){
$code
=
$this
->
request
->
get
(
'code'
);
$code
=
'021HoCq91Re1wP1g5Eo91Vgnq91HoCqd'
;
$url
=
'https://api.weixin.qq.com/sns/oauth2/access_token?appid='
.
$this
->
appkey1
.
'&secret='
.
$this
->
appsecret1
.
'&code='
.
$code
.
'&grant_type=authorization_code'
;
$res
=
$this
->
http_get
(
$url
);
$json_arr
=
json_decode
(
$res
,
true
);
// $token = $json_arr['access_token'];
$token
=
'22_LFufsKgmxT1jCtIuDJ7CLLwAOI7mOPlmNYHRHECuScIwrNZ3-Bmxj8pOjr2NZs7qdzH7iBkPddFtBdyVoBd7zas_gkQhDw3YJgm5iYa6d5w'
;
// $openid = $json_arr['openid'];
$openid
=
'oYOYl5hbULoKimG5R8Uk-Paha0d8'
;
if
(
!
isset
(
$json_arr
[
'access_token'
])
&&
empty
(
$json_arr
[
'access_token'
])){
//用户取消登录
$this
->
redirect
(
'/portal/login/thirdLogin'
);
}
$token
=
$json_arr
[
'access_token'
];
$openid
=
$json_arr
[
'openid'
];
//通过access_token获取用户信息
$url1
=
'https://api.weixin.qq.com/sns/userinfo?access_token='
.
$token
.
'&openid='
.
$openid
;
$res1
=
$this
->
http_get
(
$url1
);
$json_arr1
=
json_decode
(
$res1
,
true
);
var_dump
(
$json_arr1
);
exit
;
$info
=
json_decode
(
$res1
,
true
);
//查询该微信用户是否存在
$where
=
[
'wb_id'
=>
$info
[
'openid'
],
'source'
=>
'微信'
];
$user
=
$this
->
findThird
(
$where
);
//获取微博id,昵称,头像
$userModel
=
new
UserModel
();
$ip
=
get_client_ip
();
$users
[
'last_login_time'
]
=
time
();
$users
[
'last_login_ip'
]
=
$ip
;
if
(
$user
){
$users
[
'user_nickname'
]
=
$info
[
'nickname'
];
$users
[
'avatar'
]
=
$info
[
'headimgurl'
];
$userModel
->
where
([
'wb_id'
=>
$info
[
'openid'
],
'source'
=>
'微信'
])
->
update
(
$users
);
}
else
{
$users
[
'wb_id'
]
=
$info
[
'openid'
];
$users
[
'user_nickname'
]
=
$info
[
'nickname'
];
$users
[
'avatar'
]
=
$info
[
'headimgurl'
];
$users
[
'source'
]
=
'微信'
;
$users
[
'user_type'
]
=
2
;
$users
[
'create_time'
]
=
time
();
$userModel
->
create
(
$users
);
}
$userInfo
=
$this
->
findThird
(
$where
);
cmf_update_current_user
(
$userInfo
);
$this
->
redirect
(
'/'
);
}
//第三方微博登录
...
...
@@ -387,15 +412,6 @@ class LoginController extends HomeBaseController
$this
->
redirect
(
'/portal/login/thirdLogin'
);
}
$token
=
$json_arr
[
'access_token'
];
$url
=
'https://api.weibo.com/2/statuses/share.json'
;
$data
=
[
'access_token'
=>
$token
,
'status'
=>
URLencode
(
'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=52'
)
];
$res
=
$this
->
http_post
(
$url
,
$data
);
$json_arr
=
json_decode
(
$res
,
true
);
var_dump
(
$json_arr
);
exit
;
//存token到session
session
(
'token'
,
$token
);
$uid
=
$json_arr
[
'uid'
];
...
...
@@ -426,8 +442,7 @@ class LoginController extends HomeBaseController
}
$userInfo
=
$this
->
findThird
(
$where
);
cmf_update_current_user
(
$userInfo
);
$this
->
wb_share
();
// $this->redirect('/');
$this
->
redirect
(
'/'
);
}
//微博分享
...
...
public/themes/simpleboot3/portal/login/third_login.html
查看文件 @
920a928
...
...
@@ -41,7 +41,7 @@
<img
src=
"__TMPL__/public/assets/starImg/aicon_90.png"
alt=
""
>
</div>
<input
type=
"hidden"
name=
"client_id"
value=
"737607150"
>
<input
type=
"hidden"
name=
"redirect_uri"
value=
"http://www.
starplanet
.cn/portal/login/wb_login"
>
<input
type=
"hidden"
name=
"redirect_uri"
value=
"http://www.
xingqiu
.cn/portal/login/wb_login"
>
</form>
</div>
</div>
...
...
public/themes/simpleboot3/public/slide.html
查看文件 @
920a928
...
...
@@ -28,7 +28,7 @@
<p>
168
</p>
</div>
<input
type=
"hidden"
name=
"client_id"
value=
"737607150"
>
<input
type=
"hidden"
name=
"redirect_uri"
value=
"http://www.
starplanet
.cn/portal/login/wb_login"
>
<input
type=
"hidden"
name=
"redirect_uri"
value=
"http://www.
xingqiu
.cn/portal/login/wb_login"
>
<input
type=
"hidden"
name=
"flag"
value=
"1"
>
</form>
...
...
public/themes/simpleboot3_mobile/portal/login/login.html
查看文件 @
920a928
...
...
@@ -44,9 +44,11 @@
<div
class=
"index_tenth_seconds"
>
<div
class=
"index_tenth_second"
>
<div
class=
"index_tenth_second_one"
>
<div
class=
"index_tenth_second_img"
>
<img
src=
"__TMPL__/public/assets/images/cicon_71@2x.png"
alt=
""
/>
</div>
<a
href=
"https://open.weixin.qq.com/connect/qrconnect?appid=wx9cfa880272f186bf&redirect_uri=http://www.starplanet.cn/portal/login/wx_login&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect"
>
<div
class=
"index_tenth_second_img"
>
<img
src=
"__TMPL__/public/assets/images/cicon_71@2x.png"
alt=
""
/>
</div>
</a>
<div
class=
"index_tenth_second_title"
>
微信登录
</div>
...
...
请
注册
或
登录
后发表评论