123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- namespace app\api\controller\coach;
- use app\common\controller\Apic;
- use app\common\library\Sms;
- use think\Exception;
- use think\Validate;
- use think\Db;
- class User extends Apic
- {
- protected $noNeedLogin = ['emaillogin','resetpwd'];
- protected $noNeedRight = '*';
-
- public function emaillogin()
- {
- $account = input('account');
- $password = input('password');
- if (!$account || !$password) {
- $this->error(__('Invalid parameters'));
- }
- $ret = $this->auth->login($account, $password);
- if ($ret) {
- $data = $this->auth->getUserinfo();
- $this->success(__('Logged in successful'), $data);
- } else {
- $this->error($this->auth->getError());
- }
- }
-
- public function logout()
- {
- if (!$this->request->isPost()) {
- $this->error(__('Invalid parameters'));
- }
- $this->auth->logout();
- $this->success(__('Logout successful'));
- }
-
- public function getUserinfo($type = 1){
- $info = $this->auth->getUserinfo();
- if($type == 'return'){
- return $info;
- }
- $this->success(__('success'),$info);
- }
-
-
-
- public function profile()
- {
- $field = [
- 'mobile',
-
- 'avatar',
- 'firstname',
- 'lastname',
- 'lang',
- ];
- $data = request_post_hub($field);
-
- if(isset($data['mobile'])){
- $check_mobile = Db::name('coach')->where('mobile',$data['mobile'])->where('id','neq',$this->auth->id)->find();
- if($check_mobile){
- $this->error('手机号已被其他人使用');
- }
- }
- $update_rs = Db::name('coach')->where('id',$this->auth->id)->update($data);
- $this->success('资料更新完成');
- }
- }
|