Commit 85a6abd0 authored by clone's avatar clone

token验证

parent b58e3f06
...@@ -85,4 +85,5 @@ class AttentionShop extends Basic ...@@ -85,4 +85,5 @@ class AttentionShop extends Basic
} }
} }
\ No newline at end of file
...@@ -167,6 +167,9 @@ class Shop extends Basic ...@@ -167,6 +167,9 @@ class Shop extends Basic
return $this->response("101", '此楼盘已下架'); return $this->response("101", '此楼盘已下架');
} }
//todo 查询关注门店 //todo 查询关注门店
/* $attention["user_id"] =
getAttentionByUserIdAndHouseId($attention);*/
return $this->response("200", 'request success', $result); return $this->response("200", 'request success', $result);
} }
......
...@@ -65,10 +65,21 @@ class Basic extends Controller ...@@ -65,10 +65,21 @@ class Basic extends Controller
} elseif (strtoupper($this->request->method()) === "POST") { } elseif (strtoupper($this->request->method()) === "POST") {
$this->params = $this->request->param() != null ? $this->request->param() : null; $this->params = $this->request->param() != null ? $this->request->param() : null;
} }
if (isset($this->params['AuthToken'])) {
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
}
$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)) {
// $this->tokenVerify(); $this->tokenVerify();
} }
} }
...@@ -81,13 +92,6 @@ class Basic extends Controller ...@@ -81,13 +92,6 @@ class Basic extends Controller
echo json_encode(array( "code" => "101", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" )); echo json_encode(array( "code" => "101", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" ));
exit; exit;
} }
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
$this->verifyUserInfo(); $this->verifyUserInfo();
$this->verifyTime(); $this->verifyTime();
} }
......
...@@ -20,7 +20,8 @@ class AttentionModel extends Model ...@@ -20,7 +20,8 @@ class AttentionModel extends Model
* @param $params * @param $params
* @return array * @return array
*/ */
public function addOrUpdateAttentionShop($params){ public function addOrUpdateAttentionShop($params)
{
$arr = array(); $arr = array();
if (isset($params['user_id'])) { if (isset($params['user_id'])) {
...@@ -66,17 +67,31 @@ class AttentionModel extends Model ...@@ -66,17 +67,31 @@ class AttentionModel extends Model
* @param $param * @param $param
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function myAttentionList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $param){ public function myAttentionList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $param)
{
$params["a.user_id"] = $param["user_id"]; $params["a.user_id"] = $param["user_id"];
$params["b.room_num_left"] = array("<>",0); //剩余数为0 的商品不显示 $params["b.room_num_left"] = array( "<>", 0 ); //剩余数为0 的商品不显示
$params["b.show_all"] = array("eq",0); //只显示公开的楼盘 $params["b.show_all"] = array( "eq", 0 ); //只显示公开的楼盘
return $this->field($field) return $this->field($field)
->alias("a") ->alias("a")
->join('houseinfos b','a.house_id = b.id','LEFT') ->join('houseinfos b', 'a.house_id = b.id', 'LEFT')
->where($params) ->where($params)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->select(); ->select();
} }
/**
*根据userId和楼盘id获取是否关注此商铺
* @param $params
* @return mixed
*/
public function getAttentionByUserIdAndHouseId($params)
{
return $this->find("id")
->where($params)
->limit(1)
->select()[0];
}
} }
define (['doT', 'text!temp/user_templete_tpl.html','ckfinder','ckfinderStart', 'css!style/user.css',"datetimepicker"], function (doT, template) { define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', 'css!style/user.css',"datetimepicker"], function (doT, template) {
var user = { var user = {
urls: '', urls: '',
init: function () { init: function () {
......
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