Commit 85a6abd0 authored by clone's avatar clone

token验证

parent b58e3f06
......@@ -85,4 +85,5 @@ class AttentionShop extends Basic
}
}
\ No newline at end of file
......@@ -167,6 +167,9 @@ class Shop extends Basic
return $this->response("101", '此楼盘已下架');
}
//todo 查询关注门店
/* $attention["user_id"] =
getAttentionByUserIdAndHouseId($attention);*/
return $this->response("200", 'request success', $result);
}
......
......@@ -65,10 +65,21 @@ class Basic extends Controller
} elseif (strtoupper($this->request->method()) === "POST") {
$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];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
// $this->tokenVerify();
$this->tokenVerify();
}
}
......@@ -81,13 +92,6 @@ class Basic extends Controller
echo json_encode(array( "code" => "101", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" ));
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->verifyTime();
}
......
......@@ -20,7 +20,8 @@ class AttentionModel extends Model
* @param $params
* @return array
*/
public function addOrUpdateAttentionShop($params){
public function addOrUpdateAttentionShop($params)
{
$arr = array();
if (isset($params['user_id'])) {
......@@ -66,17 +67,31 @@ class AttentionModel extends Model
* @param $param
* @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["b.room_num_left"] = array("<>",0); //剩余数为0 的商品不显示
$params["b.show_all"] = array("eq",0); //只显示公开的楼盘
return $this->field($field)
$params["b.room_num_left"] = array( "<>", 0 ); //剩余数为0 的商品不显示
$params["b.show_all"] = array( "eq", 0 ); //只显示公开的楼盘
return $this->field($field)
->alias("a")
->join('houseinfos b','a.house_id = b.id','LEFT')
->join('houseinfos b', 'a.house_id = b.id', 'LEFT')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->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 = {
urls: '',
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