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
fdb7c606
Commit
fdb7c606
authored
Aug 13, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
c54d990c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
6 deletions
+88
-6
Location.php
application/api/controller/Location.php
+53
-0
Shop.php
application/api/controller/Shop.php
+0
-0
Basic.php
application/api/extend/Basic.php
+26
-1
RegisterValidate.php
application/api/validate/RegisterValidate.php
+9
-5
route.php
application/route.php
+0
-0
No files found.
application/api/controller/Location.php
0 → 100644
View file @
fdb7c606
<?php
namespace
app\api\controller
;
use
app\api\extend\Basic
;
use
app\extra\RedisExt
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/13
* Time : 11:31
* Intro:
*/
class
Location
extends
Basic
{
private
$redis_
;
const
CITY_USER
=
"user_city_"
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
redis_
=
RedisExt
::
getRedis
();
}
public
function
saveSiteCity
()
{
$params
=
$this
->
params
;
/* $params = array(
"user_id" => 1,
"city" => "上海市"
);*/
$checkResult
=
$this
->
validate
(
$params
,
"RegisterValidate.saveSiteCityVerify"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$city
=
"上海市"
;
$user_id
=
$params
[
"user_id"
];
if
(
$params
[
"city"
]
==
"杭州市"
||
$params
[
"city"
]
==
"杭州"
)
{
$city
=
"杭州市"
;
}
if
(
$this
->
redis_
)
{
$this
->
redis_
->
set
(
self
::
CITY_USER
.
$user_id
,
$city
);
}
else
{
return
$this
->
response
(
"101"
,
"redis service not found"
);
}
return
$this
->
response
(
"200"
,
"success"
,
[]);
}
}
\ No newline at end of file
application/api/controller/Shop.php
View file @
fdb7c606
This diff is collapsed.
Click to expand it.
application/api/extend/Basic.php
View file @
fdb7c606
...
@@ -9,8 +9,10 @@ namespace app\api\extend;
...
@@ -9,8 +9,10 @@ namespace app\api\extend;
* Time: 9:35
* Time: 9:35
* 基类
* 基类
*/
*/
use
app\extra\RedisExt
;
use
app\model\Users
;
use
app\model\Users
;
use
think\Controller
;
use
think\Controller
;
use
think\Exception
;
use
think\Request
;
use
think\Request
;
use
think\Response
;
use
think\Response
;
use
Qiniu
;
use
Qiniu
;
...
@@ -27,6 +29,8 @@ class Basic extends Controller
...
@@ -27,6 +29,8 @@ class Basic extends Controller
public
$params
;
public
$params
;
public
$user_city
;
protected
$authToken
;
protected
$authToken
;
/**
/**
...
@@ -97,7 +101,7 @@ class Basic extends Controller
...
@@ -97,7 +101,7 @@ class Basic extends Controller
$this
->
userNick
=
isset
(
$result
->
data
->
userNick
)
?
$result
->
data
->
userNick
:
""
;
$this
->
userNick
=
isset
(
$result
->
data
->
userNick
)
?
$result
->
data
->
userNick
:
""
;
$this
->
timeStamp_
=
$result
->
timeStamp_
;
$this
->
timeStamp_
=
$result
->
timeStamp_
;
}
}
$this
->
getCity
(
$this
->
userId
);
$requestPath
=
$this
->
request
->
routeInfo
()[
"rule"
][
0
]
.
"/"
.
$this
->
request
->
routeInfo
()[
"rule"
][
1
];
$requestPath
=
$this
->
request
->
routeInfo
()[
"rule"
][
0
]
.
"/"
.
$this
->
request
->
routeInfo
()[
"rule"
][
1
];
//过滤掉不需要验证token的接口
//过滤掉不需要验证token的接口
if
(
!
in_array
(
trim
(
$requestPath
),
$this
->
filterVerify
))
{
if
(
!
in_array
(
trim
(
$requestPath
),
$this
->
filterVerify
))
{
...
@@ -105,6 +109,27 @@ class Basic extends Controller
...
@@ -105,6 +109,27 @@ class Basic extends Controller
}
}
}
}
/**
* 默认城市选择
* @param $agentId
*/
public
function
getCity
(
$userId
)
{
try
{
$redis_
=
RedisExt
::
getRedis
();
if
(
$redis_
)
{
$city
=
$redis_
->
get
(
"user_city_"
.
$userId
);
$this
->
user_city
=
empty
(
$city
)
?
"上海市"
:
$city
;
}
else
{
$this
->
user_city
=
"上海市"
;
}
}
catch
(
Exception
$exception
)
{
$this
->
user_city
=
"上海市"
;
}
}
/**
/**
* token 验证
* token 验证
*/
*/
...
...
application/api/validate/RegisterValidate.php
View file @
fdb7c606
...
@@ -20,6 +20,7 @@ class RegisterValidate extends Validate
...
@@ -20,6 +20,7 @@ class RegisterValidate extends Validate
'code'
=>
'require|number'
,
'code'
=>
'require|number'
,
'device_id'
=>
'require'
,
'device_id'
=>
'require'
,
'phone'
=>
[
'regex'
=>
'/^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(16[0-9])|(17[0-9])|(19[0-9]))\\d{8}$/i'
],
'phone'
=>
[
'regex'
=>
'/^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(16[0-9])|(17[0-9])|(19[0-9]))\\d{8}$/i'
],
'city'
=>
'require'
,
];
];
protected
$message
=
[
protected
$message
=
[
...
@@ -32,13 +33,15 @@ class RegisterValidate extends Validate
...
@@ -32,13 +33,15 @@ class RegisterValidate extends Validate
'phone.regex'
=>
'手机号格式不正确'
,
'phone.regex'
=>
'手机号格式不正确'
,
'device_id.require'
=>
'设备id不能为空'
,
'device_id.require'
=>
'设备id不能为空'
,
'code.require'
=>
'code为必填字段'
,
'code.require'
=>
'code为必填字段'
,
'code.number'
=>
'code只能为数字'
'code.number'
=>
'code只能为数字'
,
'city.require'
=>
'city为必填字段'
,
];
];
protected
$scene
=
[
protected
$scene
=
[
'verify'
=>
[
'phone'
,
'device_id'
],
'verify'
=>
[
'phone'
,
'device_id'
],
'register'
=>
[
'phone'
,
'device_id'
,
'code'
],
'register'
=>
[
'phone'
,
'device_id'
,
'code'
],
'removeBind'
=>
[
'user_id'
,
'buyer_id'
],
'removeBind'
=>
[
'user_id'
,
'buyer_id'
],
'bind'
=>
[
'wx_union_id'
,
'phone'
],
'bind'
=>
[
'wx_union_id'
,
'phone'
],
'saveSiteCityVerify'
=>
[
'user_id'
,
'city'
],
];
];
}
}
\ No newline at end of file
application/route.php
View file @
fdb7c606
This diff is collapsed.
Click to expand it.
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