Commit ce77f00c authored by clone's avatar clone

session

parent 13026a05
...@@ -26,20 +26,19 @@ class Sublet extends Basic ...@@ -26,20 +26,19 @@ class Sublet extends Basic
public function addSublet() public function addSublet()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( $params = array(
"user_id" => 1, "user_id" => 47,
"manage_type" => 0, "manage_type" => 美食,
"address_detail" => "shanghaishi", "address_detail" => "泗泾",
"province" => "湖南省", "province" => "上海",
"province_code" => "10001", "city" => "长沙市",
"city" => "长沙市", "district" => "芙蓉区",
"city_code" => "200001", "expected_rent" => 2000,
"district" => "芙蓉区", "appellation" => "zhangsan",
"district_code" => "300001", "tel" => 13817616162,
"expected_rent" => 2000, "AuthToken" => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7ImlkIjo0NywidXNlck5pY2siOm51bGwsInBob25lIjoiMTgyMDU2MjUwMjAifSwidGltZVN0YW1wXyI6MTUxMzU3MzMwMH0.-_tpSDeucA6_V8glS1hfoNBpZU8lRk6J8On3-_Rdf_I',
"appellation" => "zhangsan", );
"tel" => 13817616162,
);*/
if (!isset($params["manage_type"])) { if (!isset($params["manage_type"])) {
$this->response("101", "经营业态不能为空"); $this->response("101", "经营业态不能为空");
...@@ -49,8 +48,12 @@ class Sublet extends Basic ...@@ -49,8 +48,12 @@ class Sublet extends Basic
$this->response("101", "详细地址不能为空"); $this->response("101", "详细地址不能为空");
} }
if (!isset($params["province"]) || !isset($params["province_code"]) || !isset($params["city"]) || /* if (!isset($params["province"]) || !isset($params["province_code"]) || !isset($params["city"]) ||
!isset($params["city_code"]) || !isset($params["district"]) || !isset($params["district_code"])) { !isset($params["city_code"]) || !isset($params["district"]) || !isset($params["district_code"])) {
$this->response("101", "省市区不能为空");
}*/
if (!isset($params["province"]) || !isset($params["city"]) || !isset($params["district"])) {
$this->response("101", "省市区不能为空"); $this->response("101", "省市区不能为空");
} }
...@@ -62,12 +65,13 @@ class Sublet extends Basic ...@@ -62,12 +65,13 @@ class Sublet extends Basic
$this->response("101", "称呼不能为空"); $this->response("101", "称呼不能为空");
} }
if (!isset($params["tel"]) || !preg_match('/1[345678]\d{9}/', $params["phone"])) { if (!isset($params["tel"]) || !preg_match('/1[345678]\d{9}/', $params["tel"])) {
$this->response("101", "手机号检验错误"); $this->response("101", "手机号检验错误");
} }
$params["create_time"] = time(); $params["create_time"] = time();
$params["update_time"] = time(); $params["update_time"] = time();
unset($params["AuthToken"]);
$result = $this->subletMode->addSublet($params); $result = $this->subletMode->addSublet($params);
if ($result["code"] == 200) { if ($result["code"] == 200) {
return $this->response("200", "数据保存成功", $result["msg"]); return $this->response("200", "数据保存成功", $result["msg"]);
......
...@@ -76,10 +76,10 @@ class Basic extends Controller ...@@ -76,10 +76,10 @@ class Basic extends Controller
$this->timeStamp_ = $result->timeStamp_; $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();
} }
} }
...@@ -87,7 +87,8 @@ class Basic extends Controller ...@@ -87,7 +87,8 @@ class Basic extends Controller
/** /**
* token 验证 * token 验证
*/ */
public function tokenVerify(){ public function tokenVerify()
{
if (!isset($this->params['AuthToken'])) { if (!isset($this->params['AuthToken'])) {
echo json_encode(array( "code" => "300", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" )); echo json_encode(array( "code" => "300", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" ));
exit; exit;
......
...@@ -5,6 +5,7 @@ namespace app\index\controller; ...@@ -5,6 +5,7 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\AdminModel; use app\model\AdminModel;
use think\Request; use think\Request;
use think\Session;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
...@@ -42,6 +43,10 @@ class Login extends Basic ...@@ -42,6 +43,10 @@ class Login extends Basic
//todo 更新登录信息 //todo 更新登录信息
if (count($result) > 0) { if (count($result) > 0) {
Session::set("userName",$result[0]["name"]);
Session::set("userId",$result[0]["id"]);
Session::set("lastLoginTime",$result[0]["last_login_time"]);
$this->redirect('banner/banner'); $this->redirect('banner/banner');
} else { } else {
return view("login/login", [ "msg" => "用户名或密码错误" ]); return view("login/login", [ "msg" => "用户名或密码错误" ]);
......
...@@ -25,7 +25,7 @@ class AdminModel extends Model ...@@ -25,7 +25,7 @@ class AdminModel extends Model
public function verifyUser($params) public function verifyUser($params)
{ {
return $this->db->field("id") return $this->db->field("id,name,last_login_time")
->where($params) ->where($params)
->select(); ->select();
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\model; namespace app\model;
use think\Model; use think\Model;
use think\Db;
class SubletModel extends Model class SubletModel extends Model
{ {
......
...@@ -130,6 +130,10 @@ Route::group('api', [ ...@@ -130,6 +130,10 @@ Route::group('api', [
//AttentionShop //AttentionShop
'addOrUpdateAttention' => [ 'api/AttentionShop/addOrUpdateAttention', [ 'method' => 'post|get' ] ], 'addOrUpdateAttention' => [ 'api/AttentionShop/addOrUpdateAttention', [ 'method' => 'post|get' ] ],
'attentionList' => [ 'api/AttentionShop/attentionList', [ 'method' => 'post | get' ] ], 'attentionList' => [ 'api/AttentionShop/attentionList', [ 'method' => 'post | get' ] ],
'addSublet' => [ 'api/Sublet/addSublet', [ 'method' => 'post|get' ] ],
]); ]);
//Route::miss('api/index/miss');//处理错误的url //Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
/* ========================================================================
* Bootstrap: collapse.js v3.3.7
* http://getbootstrap.com/javascript/#collapse
* ========================================================================
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
/* jshint latedef: false */
+function ($) {
'use strict';
// COLLAPSE PUBLIC CLASS DEFINITION
// ================================
var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, Collapse.DEFAULTS, options)
this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
'[data-toggle="collapse"][data-target="#' + element.id + '"]')
this.transitioning = null
if (this.options.parent) {
this.$parent = this.getParent()
} else {
this.addAriaAndCollapsedClass(this.$element, this.$trigger)
}
if (this.options.toggle) this.toggle()
}
Collapse.VERSION = '3.3.7'
Collapse.TRANSITION_DURATION = 350
Collapse.DEFAULTS = {
toggle: true
}
Collapse.prototype.dimension = function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
Collapse.prototype.show = function () {
if (this.transitioning || this.$element.hasClass('in')) return
var activesData
var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
if (actives && actives.length) {
activesData = actives.data('bs.collapse')
if (activesData && activesData.transitioning) return
}
var startEvent = $.Event('show.bs.collapse')
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
if (actives && actives.length) {
Plugin.call(actives, 'hide')
activesData || actives.data('bs.collapse', null)
}
var dimension = this.dimension()
this.$element
.removeClass('collapse')
.addClass('collapsing')[dimension](0)
.attr('aria-expanded', true)
this.$trigger
.removeClass('collapsed')
.attr('aria-expanded', true)
this.transitioning = 1
var complete = function () {
this.$element
.removeClass('collapsing')
.addClass('collapse in')[dimension]('')
this.transitioning = 0
this.$element
.trigger('shown.bs.collapse')
}
if (!$.support.transition) return complete.call(this)
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
this.$element
.one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
}
Collapse.prototype.hide = function () {
if (this.transitioning || !this.$element.hasClass('in')) return
var startEvent = $.Event('hide.bs.collapse')
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
var dimension = this.dimension()
this.$element[dimension](this.$element[dimension]())[0].offsetHeight
this.$element
.addClass('collapsing')
.removeClass('collapse in')
.attr('aria-expanded', false)
this.$trigger
.addClass('collapsed')
.attr('aria-expanded', false)
this.transitioning = 1
var complete = function () {
this.transitioning = 0
this.$element
.removeClass('collapsing')
.addClass('collapse')
.trigger('hidden.bs.collapse')
}
if (!$.support.transition) return complete.call(this)
this.$element
[dimension](0)
.one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(Collapse.TRANSITION_DURATION)
}
Collapse.prototype.toggle = function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
Collapse.prototype.getParent = function () {
return $(this.options.parent)
.find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
.each($.proxy(function (i, element) {
var $element = $(element)
this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
}, this))
.end()
}
Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
var isOpen = $element.hasClass('in')
$element.attr('aria-expanded', isOpen)
$trigger
.toggleClass('collapsed', !isOpen)
.attr('aria-expanded', isOpen)
}
function getTargetFromTrigger($trigger) {
var href
var target = $trigger.attr('data-target')
|| (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
return $(target)
}
// COLLAPSE PLUGIN DEFINITION
// ==========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.collapse')
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]()
})
}
var old = $.fn.collapse
$.fn.collapse = Plugin
$.fn.collapse.Constructor = Collapse
// COLLAPSE NO CONFLICT
// ====================
$.fn.collapse.noConflict = function () {
$.fn.collapse = old
return this
}
// COLLAPSE DATA-API
// =================
$(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
var $this = $(this)
if (!$this.attr('data-target')) e.preventDefault()
var $target = getTargetFromTrigger($this)
var data = $target.data('bs.collapse')
var option = data ? 'toggle' : $this.data()
Plugin.call($target, option)
})
}(jQuery);
/* ========================================================================
* Bootstrap: transition.js v3.3.7
* http://getbootstrap.com/javascript/#transitions
* ========================================================================
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
// ============================================================
function transitionEnd() {
var el = document.createElement('bootstrap')
var transEndEventNames = {
WebkitTransition : 'webkitTransitionEnd',
MozTransition : 'transitionend',
OTransition : 'oTransitionEnd otransitionend',
transition : 'transitionend'
}
for (var name in transEndEventNames) {
if (el.style[name] !== undefined) {
return { end: transEndEventNames[name] }
}
}
return false // explicit for ie8 ( ._.)
}
// http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function (duration) {
var called = false
var $el = this
$(this).one('bsTransitionEnd', function () { called = true })
var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
setTimeout(callback, duration)
return this
}
$(function () {
$.support.transition = transitionEnd()
if (!$.support.transition) return
$.event.special.bsTransitionEnd = {
bindType: $.support.transition.end,
delegateType: $.support.transition.end,
handle: function (e) {
if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
}
}
})
}(jQuery);
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