bug修复
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
class Index extends \app\common\controller\Api {
|
||||
class Index extends \app\common\controller\Api{
|
||||
|
||||
public $mustToken = true;
|
||||
public $mustToken = false;
|
||||
|
||||
public function usercount(){
|
||||
$this->data['data'] = array('team_num'=>100,'coustomer_num'=>10000);
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getlive(){
|
||||
$fp = fopen(ROOT_PATH . DS . 'live.txt', 'r');
|
||||
$info = fread($fp, filesize(ROOT_PATH . DS . 'live.txt'));
|
||||
fclose($fp);
|
||||
$res = explode("\n", $info);
|
||||
foreach ($res as $value) {
|
||||
$val = explode(",", $value);
|
||||
$data[] = array('name'=>$val[0],'src'=>$val[1]);
|
||||
}
|
||||
|
||||
$this->data['data'] = $data;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
39
application/api/controller/Login.php
Normal file
39
application/api/controller/Login.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
class Login extends \app\common\controller\Api{
|
||||
|
||||
|
||||
public function index(){
|
||||
$username = $this->request->param('username', '');
|
||||
$password = $this->request->param('password', '');
|
||||
|
||||
if (!$username || !$password) {
|
||||
$this->data['code'] = 1;
|
||||
$this->data['msg'] = "账号密码不能为空!";
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
$user = db('Member')->where('username', $username)->find();
|
||||
if ($user && $user['status'] == 1) {
|
||||
if ($user['password'] == md5($password . $user['salt'])) {
|
||||
|
||||
$info['access_token'] = authcode($user['uid'].'|'.$user['username'].'|'.$user['password'], 'ENCODE');
|
||||
$info['uid'] = $user['uid'];
|
||||
$info['username'] = $user['username'];
|
||||
$info['avatar'] = (isset($user['avatar_url']) && $user['avatar_url']) ? $user['avatar_url'] : avatar($user['uid']);
|
||||
|
||||
$this->data['data'] = $info;
|
||||
return $this->data;
|
||||
}else{
|
||||
$this->data['code'] = 1;
|
||||
$this->data['msg'] = "密码错误!";
|
||||
return $this->data;
|
||||
}
|
||||
}else{
|
||||
$this->data['code'] = 1;
|
||||
$this->data['msg'] = "无此账户或账户被禁用!";
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,19 +30,24 @@ class Wechat extends \app\common\controller\Api{
|
||||
|
||||
$info = $app->auth->session($param['jsCode']);
|
||||
|
||||
//查询用户是否已添加
|
||||
$user = db('Member')->where('openid', $info['openid'])->find();
|
||||
if (!$user) {
|
||||
$other = array(
|
||||
'avatar_url' => $param['avatar'],
|
||||
);
|
||||
$user = model('Member')->register($param['nickname'], $param['openid'], $param['openid'], $param['openid'].'@wx.com', false, $other);
|
||||
if (isset($info['openid']) && $info['openid']) {
|
||||
//查询用户是否已添加
|
||||
$user = db('Member')->where('openid', $info['openid'])->find();
|
||||
if (!$user) {
|
||||
$other = array(
|
||||
'avatar_url' => $param['avatar'],
|
||||
);
|
||||
$user = model('Member')->register($param['nickname'], $param['openid'], $param['openid'], $param['openid'].'@wx.com', false, $other);
|
||||
}
|
||||
|
||||
$info['access_token'] = authcode($user['uid'].'|'.$user['username'].'|'.$user['password'], 'ENCODE');
|
||||
$info['uid'] = $user['uid'];
|
||||
|
||||
$this->data['data'] = $info;
|
||||
}else{
|
||||
$this->data['code'] = 1;
|
||||
$this->data['msg'] = '非法操作!';
|
||||
}
|
||||
|
||||
$info['access_token'] = authcode($user['uid'].'|'.$user['username'].'|'.$user['password'], 'ENCODE');
|
||||
$info['uid'] = $user['uid'];
|
||||
|
||||
$this->data['data'] = $info;
|
||||
|
||||
return json($this->data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user