Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
backend
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
亲子游项目
backend
Commits
cdeb74d7
Commit
cdeb74d7
authored
Jan 05, 2019
by
LiuJunYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
榜单,用户排名,没有排名返回0
parent
40f18e3a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
4 deletions
+38
-4
application/api/controller/User.php
+38
-4
No files found.
application/api/controller/User.php
View file @
cdeb74d7
...
@@ -5,6 +5,7 @@ namespace app\api\controller;
...
@@ -5,6 +5,7 @@ namespace app\api\controller;
use
app\common\model\User
as
UserModel
;
use
app\common\model\User
as
UserModel
;
use
app\admin\controller\Upload
;
use
app\admin\controller\Upload
;
use
app\common\model\VipRelation
as
VipRelationModel
;
use
app\common\model\VipRelation
as
VipRelationModel
;
use
think\Exception
;
class
User
extends
Base
class
User
extends
Base
{
{
...
@@ -122,7 +123,7 @@ class User extends Base
...
@@ -122,7 +123,7 @@ class User extends Base
// 过期时间2小时 7200s
// 过期时间2小时 7200s
$session_key
=
$response
->
session_key
;
$session_key
=
$response
->
session_key
;
if
(
$session_key
)
{
if
(
$session_key
)
{
return
[
"code"
=>
0
,
"msg"
=>
"succeed"
,
'data'
=>
$session_key
];
return
[
"code"
=>
0
,
"msg"
=>
"succeed"
,
'data'
=>
$session_key
];
}
}
return
[
"code"
=>
1
,
"msg"
=>
"获取session_key失败"
];
return
[
"code"
=>
1
,
"msg"
=>
"获取session_key失败"
];
}
}
...
@@ -167,7 +168,7 @@ class User extends Base
...
@@ -167,7 +168,7 @@ class User extends Base
if
(
$version
==
'1.1'
)
{
if
(
$version
==
'1.1'
)
{
$iv
=
urldecode
(
$iv
);
$iv
=
urldecode
(
$iv
);
$errCode
=
$pc
->
decryptData
(
$encryptedData
,
$iv
,
$data
);
$errCode
=
$pc
->
decryptData
(
$encryptedData
,
$iv
,
$data
);
}
else
{
}
else
{
$errCode
=
$pc
->
decryptData
(
$encryptedData
,
$iv
,
$data
);
$errCode
=
$pc
->
decryptData
(
$encryptedData
,
$iv
,
$data
);
}
}
if
(
$errCode
==
0
)
{
if
(
$errCode
==
0
)
{
...
@@ -188,7 +189,7 @@ class User extends Base
...
@@ -188,7 +189,7 @@ class User extends Base
$is_relation
=
$this
->
vipRelation
(
$phone
);
$is_relation
=
$this
->
vipRelation
(
$phone
);
return
[
"code"
=>
0
,
"msg"
=>
"获取成功"
,
'data'
=>
$result
,
'is_relation'
=>
$is_relation
];
return
[
"code"
=>
0
,
"msg"
=>
"获取成功"
,
'data'
=>
$result
,
'is_relation'
=>
$is_relation
];
}
else
{
}
else
{
return
[
"code"
=>
1
,
"msg"
=>
"微信授权失败:"
.
$errCode
.
' - '
.
$iv
];
return
[
"code"
=>
1
,
"msg"
=>
"微信授权失败:"
.
$errCode
.
' - '
.
$iv
];
}
}
}
}
...
@@ -240,7 +241,7 @@ class User extends Base
...
@@ -240,7 +241,7 @@ class User extends Base
$is_relation
=
$this
->
vipRelation
(
$phone
);
$is_relation
=
$this
->
vipRelation
(
$phone
);
return
[
"code"
=>
0
,
"msg"
=>
"获取成功"
,
'data'
=>
$result
,
'is_relation'
=>
$is_relation
];
return
[
"code"
=>
0
,
"msg"
=>
"获取成功"
,
'data'
=>
$result
,
'is_relation'
=>
$is_relation
];
}
else
{
}
else
{
return
[
"code"
=>
1
,
"msg"
=>
"微信授权失败:"
.
$errCode
.
' - '
.
$iv
];
return
[
"code"
=>
1
,
"msg"
=>
"微信授权失败:"
.
$errCode
.
' - '
.
$iv
];
}
}
}
}
...
@@ -307,6 +308,39 @@ class User extends Base
...
@@ -307,6 +308,39 @@ class User extends Base
}
}
}
}
public
function
savePhone
()
{
try
{
if
(
!
$this
->
userinfo
)
{
return
[
"code"
=>
1
,
"msg"
=>
"未登录"
];
}
//校验手机号
if
(
!
preg_match
(
"/^1[0-9]
{
10}$|^0[0-9]{9,10
}
$/"
,
input
(
'phone'
)))
{
return
[
'code'
=>
1
,
'请输入正确的手机号'
];
}
//查询手机号是否重复
$user
=
UserModel
::
get
([
'id'
=>
[
'neq'
,
$this
->
userinfo
[
0
]],
'phone'
=>
input
(
'phone'
)]);
if
(
$user
)
{
return
[
'code'
=>
1
,
'该手机号已经注册过'
];
}
$hidephone
=
substr_replace
(
input
(
'phone'
),
'****'
,
3
,
4
);
$user
=
UserModel
::
get
(
$this
->
userinfo
[
0
]);
$user
->
phone
=
input
(
'phone'
);
$user
->
save
();
$result
=
[
'phone'
=>
input
(
'phone'
),
'hidephone'
=>
$hidephone
];
//关联VIP
$is_relation
=
$this
->
vipRelation
(
input
(
'phone'
));
return
[
"code"
=>
0
,
"msg"
=>
"获取成功"
,
'data'
=>
$result
,
'is_relation'
=>
$is_relation
];
}
catch
(
Exception
$e
){
D
return
[
'code'
=>
1
,
'msg'
=>
'手机号保存失败'
];
}
}
public
function
vipRelation
(
$phone
)
public
function
vipRelation
(
$phone
)
{
{
//先查询最新的是否有未关联的这个手机号
//先查询最新的是否有未关联的这个手机号
...
...
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