Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
0393c19f
Commit
0393c19f
authored
Jun 19, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信授权
parent
ec7a6d5e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
+38
-7
WxCallbackUntils.php
application/api/untils/WxCallbackUntils.php
+1
-1
Index.php
application/app_broker/controller/Index.php
+35
-6
WxAuthorization.php
application/index/controller/WxAuthorization.php
+2
-0
No files found.
application/api/untils/WxCallbackUntils.php
View file @
0393c19f
...
...
@@ -81,7 +81,7 @@ class WxCallbackUntils
'province'
=>
$user_info
->
province
,
'city'
=>
$user_info
->
city
,
'buyer_img'
=>
$user_info
->
headimgurl
,
'union_id'
=>
$user_info
->
unionid
,
'
wx_
union_id'
=>
$user_info
->
unionid
,
);
session
(
"userInfo"
,
$data
);
return
$data
;
...
...
application/app_broker/controller/Index.php
View file @
0393c19f
...
...
@@ -6,7 +6,10 @@ use app\api\untils\WxCallbackUntils;
use
app\model\AppVersion
;
use
app\model\HouseImgs
;
use
app\model\HouseInfos
;
use
app\model\Users
;
use
app\model\UWxInfo
;
use
think\Controller
;
use
think\Exception
;
use
think\Log
;
use
think\Response
;
...
...
@@ -15,29 +18,55 @@ class Index
private
$url
=
CURRENT_URL
.
"/app_broker/index"
;
private
$_wxApi
;
private
$wxInfoModel
;
private
$userModel
;
public
function
__construct
()
{
$this
->
_wxApi
=
new
WxCallbackUntils
();
$this
->
wxInfoModel
=
new
UWxInfo
();
$this
->
userModel
=
new
Users
();
}
public
function
index
()
{
$code
=
empty
(
$_GET
[
'code'
])
?
null
:
$_GET
[
'code'
];
$userInfo
=
session
(
"userInfo"
);
if
(
!
$code
)
{
$this
->
_wxApi
->
getWxCode
(
$this
->
url
);
}
else
{
$this
->
_wxApi
->
getUserInfoByAccessToken
(
$code
);
$
userInfo
=
$
this
->
_wxApi
->
getUserInfoByAccessToken
(
$code
);
Log
::
record
(
"session wx -----------------"
.
json_encode
(
$userInfo
),
"info"
);
if
(
!
$userInfo
)
{
$this
->
_wxApi
->
getWxCode
(
$this
->
url
);
}
else
{
dump
(
$userInfo
);
return
view
(
"index/index"
);
$userInfo
[
"source"
]
=
0
;
$wx_union_id
=
$userInfo
[
"wx_union_id"
];
// 验证open_id是否已经存在,存在则更新
$wxInfoObj
=
$this
->
wxInfoModel
->
getWxInfoByOpenId
(
$wx_union_id
);
try
{
if
(
$wxInfoObj
&&
count
(
$wxInfoObj
)
>
0
)
{
$userInfo
[
"id"
]
=
$wxInfoObj
[
0
][
"id"
];
$id
=
$this
->
wxInfoModel
->
updateWxInfo
(
$userInfo
);
}
else
{
$id
=
$this
->
wxInfoModel
->
addWxInfo
(
$userInfo
);
}
}
catch
(
Exception
$exception
)
{
Log
::
record
(
"wx authorization error,msg:"
.
$exception
);
}
$conditions
[
"buyer_id"
]
=
$id
;
$fields
=
"id,user_nick,user_phone,user_pic,other_pic"
;
$user_info
=
$this
->
userModel
->
getUserByWhere
(
$conditions
,
$fields
);
if
(
count
(
$user_info
)
>
0
){
//下载页
header
(
CURRENT_URL
.
"app/download_c"
);
die
();
}
else
{
//绑定页
header
(
CURRENT_URL
.
"app/dist/index.html#/inviteRegister"
);
die
();
}
}
}
...
...
application/index/controller/WxAuthorization.php
View file @
0393c19f
...
...
@@ -2,6 +2,7 @@
namespace
app\index\controller
;
use
app\api\controller\WxSdk
;
use
app\api\untils\WxCallbackUntils
;
use
app\index\extend\Basic
;
use
Think\Log
;
...
...
@@ -37,6 +38,7 @@ class WxAuthorization extends Basic
if
(
!
$userInfo
)
{
$this
->
_wxApi
->
getWxCode
(
$this
->
url
);
}
else
{
//saveWxInfo();
dump
(
$userInfo
);
return
view
(
"test"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment