Commit fdb7c606 authored by clone's avatar clone

bug

parent c54d990c
<?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
This diff is collapsed.
......@@ -9,8 +9,10 @@ namespace app\api\extend;
* Time: 9:35
* 基类
*/
use app\extra\RedisExt;
use app\model\Users;
use think\Controller;
use think\Exception;
use think\Request;
use think\Response;
use Qiniu;
......@@ -27,6 +29,8 @@ class Basic extends Controller
public $params;
public $user_city;
protected $authToken;
/**
......@@ -97,7 +101,7 @@ class Basic extends Controller
$this->userNick = isset($result->data->userNick) ? $result->data->userNick : "";
$this->timeStamp_ = $result->timeStamp_;
}
$this->getCity($this->userId);
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
......@@ -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 验证
*/
......
......@@ -20,6 +20,7 @@ class RegisterValidate extends Validate
'code' => 'require|number',
'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' ],
'city' => 'require',
];
protected $message = [
......@@ -32,13 +33,15 @@ class RegisterValidate extends Validate
'phone.regex' => '手机号格式不正确',
'device_id.require' => '设备id不能为空',
'code.require' => 'code为必填字段',
'code.number' => 'code只能为数字'
'code.number' => 'code只能为数字',
'city.require' => 'city为必填字段',
];
protected $scene = [
'verify' => [ 'phone', 'device_id' ],
'register' => [ 'phone', 'device_id', 'code' ],
'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
......@@ -242,7 +242,6 @@ Route::group('index', [
'performanceInfo' => [ 'index/PerformanceInfo/performanceInfo', [ 'method' => 'post|get' ] ],//业绩明细
'getTaxesById' => [ 'index/Finance/getTaxesById', [ 'method' => 'POST|GET' ] ], //财务结单
'financeUpdateLog' => [ 'index/Finance/financeUpdateLog', [ 'method' => 'POST|GET' ] ], //财务结单
'noticeIndex' => [ 'index/notice/index', [ 'method' => 'GET' ] ], //公告列表
......@@ -273,7 +272,6 @@ Route::group('index', [
'myCollectionShopList' => [ 'index/myCollectionShop/myCollectionShopList', [ 'method' => 'POST|GET' ] ],//我收藏的客户liu
'lookShopIndex' => [ 'index/LookShop/lookShopIndex', [ 'method' => 'GET' ] ],//商铺查看日志
......@@ -282,7 +280,6 @@ Route::group('index', [
'selectIndividualPerformance' => [ 'index/Performance/selectIndividualPerformance', [ 'method' => 'POST|GET' ] ], //个人业绩排行 朱伟 2018-07-31
]);
......@@ -358,6 +355,8 @@ Route::group('api', [
'removeBind' => [ 'api/Register/removeBinding', [ 'method' => 'POST|GET' ] ],
'bindingWx' => [ 'api/Register/bindingWx', [ 'method' => 'POST' ] ], //绑定微信
'saveSiteCity' => [ 'api/Location/saveSiteCity', [ 'method' => 'POST|GET' ] ], //保存默认城市选择 c端
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment