1、修复bug
2、后台栏目分模型划分 3、前台增加微信开发用户登录功能
This commit is contained in:
@@ -59,12 +59,12 @@ class Attribute extends Base{
|
||||
|
||||
public function getFieldlist($map,$index='id'){
|
||||
$list = array();
|
||||
$row = db('Attribute')->field('*,remark as help,type,extra as "option"')->where($map)->order('group_id asc, sort asc')->select();
|
||||
$row = db('Attribute')->field('*,remark as help,type,extra as "option",model_id')->where($map)->order('group_id asc, sort asc')->select();
|
||||
foreach ($row as $key => $value) {
|
||||
if (in_array($value['type'],array('checkbox','radio','select','bool'))) {
|
||||
$value['option'] = parse_field_attr($value['extra']);
|
||||
} elseif ($value['type'] == 'bind') {
|
||||
$extra = parse_field_bind($value['extra']);
|
||||
$extra = parse_field_bind($value['extra'], '', $value['model_id']);
|
||||
$option = array();
|
||||
foreach ($extra as $k => $v) {
|
||||
$option[$v['id']] = $v['title_show'];
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace app\common\model;
|
||||
class Category extends Base{
|
||||
|
||||
protected $name = "Category";
|
||||
protected $auto = array('update_time', 'icon'=>1, 'status'=>1);
|
||||
protected $auto = array('update_time', 'status'=>1);
|
||||
|
||||
protected $type = array(
|
||||
'icon' => 'integer',
|
||||
|
||||
@@ -14,4 +14,8 @@ namespace app\common\model;
|
||||
*/
|
||||
class Content extends BaseModel{
|
||||
|
||||
protected $type = array(
|
||||
'create_time' => 'integer',
|
||||
'update_time' => 'integer',
|
||||
);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class FormAttr extends Base{
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
|
||||
protected static function init(){
|
||||
self::afterInsert(function($data){
|
||||
if ($data['form_id']) {
|
||||
|
||||
@@ -79,13 +79,17 @@ class User extends Base{
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录模型
|
||||
*/
|
||||
public function login($username = '', $password = '', $type = 1){
|
||||
* 用户登录模型
|
||||
* @param string $username [description]
|
||||
* @param string $password [description]
|
||||
* @param integer $type 登录类型,1为用户名登录2为邮箱登录3为手机登录4为用户ID登录5为微信登录
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function login($username = '', $password = '', $type = 1) {
|
||||
$map = array();
|
||||
if (\think\Validate::is($username,'email')) {
|
||||
if (\think\Validate::is($username, 'email')) {
|
||||
$type = 2;
|
||||
}elseif (preg_match("/^1[34578]{1}\d{9}$/",$username)) {
|
||||
} elseif (preg_match("/^1[34578]{1}\d{9}$/", $username)) {
|
||||
$type = 3;
|
||||
}
|
||||
switch ($type) {
|
||||
@@ -102,23 +106,53 @@ class User extends Base{
|
||||
$map['uid'] = $username;
|
||||
break;
|
||||
case 5:
|
||||
$map['uid'] = $username;
|
||||
$map['openid'] = $username;
|
||||
break;
|
||||
default:
|
||||
return 0; //参数错误
|
||||
return 0; //参数错误
|
||||
}
|
||||
if (!$username) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->where($map)->find();
|
||||
if(isset($user['status']) && $user['status']){
|
||||
/* 验证用户密码 */
|
||||
if(md5($password.$user['salt']) === $user['password']){
|
||||
if (isset($user['uid']) && $user['uid'] && $user['status']) {
|
||||
if ($type == 3) {
|
||||
//手机验证手机动态密码
|
||||
if ($password == session('mobile_login_code')) {
|
||||
$this->autoLogin($user); //更新用户登录信息
|
||||
return $user['uid'];
|
||||
}else{
|
||||
return -5;
|
||||
}
|
||||
} elseif ($type == 5) {
|
||||
$this->autoLogin($user); //更新用户登录信息
|
||||
return $user['uid']; //登录成功,返回用户ID
|
||||
return $user['uid'];
|
||||
} else {
|
||||
return -2; //密码错误
|
||||
/* 验证用户密码 */
|
||||
if (md5($password . $user['salt']) === $user['password']) {
|
||||
$this->autoLogin($user); //更新用户登录信息
|
||||
return $user['uid']; //登录成功,返回用户ID
|
||||
} else {
|
||||
return -2; //密码错误
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return -1; //用户不存在或被禁用
|
||||
if ($type == 3 && preg_match("/^1[34578]{1}\d{9}$/", $username) && $password == session('mobile_login_code')) {
|
||||
$data = array(
|
||||
'username' => $username,
|
||||
'mobile' => $username,
|
||||
'salt' => rand_string(6),
|
||||
'password' => $password,
|
||||
);
|
||||
$result = $this->save($data);
|
||||
if ($result) {
|
||||
$this->autoLogin($this->data); //更新用户登录信息
|
||||
}
|
||||
return $this->data['uid'];
|
||||
} else {
|
||||
return -1; //用户不存在或被禁用
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,16 +160,19 @@ class User extends Base{
|
||||
* 用户注册
|
||||
* @param integer $user 用户信息数组
|
||||
*/
|
||||
function register($username, $password, $repassword, $email, $isautologin = true){
|
||||
function register($username, $password, $repassword, $email, $isautologin = true, $other = array()){
|
||||
$data['username'] = $username;
|
||||
$data['salt'] = rand_string(6);
|
||||
$data['password'] = $password;
|
||||
$data['repassword'] = $repassword;
|
||||
$data['email'] = $email;
|
||||
if (!empty($other)) {
|
||||
$data = array_merge($data, $other);
|
||||
}
|
||||
$result = $this->validate(true)->save($data);
|
||||
if ($result) {
|
||||
$data['uid'] = $this->data['uid'];
|
||||
$this->extend()->save($data);
|
||||
//$this->extend()->save($data);
|
||||
if ($isautologin) {
|
||||
$this->autoLogin($this->data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user