Index.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace app\api\controller\company;
  3. use app\common\controller\Apic;
  4. use app\common\model\PcAdminLog;
  5. use fast\Random;
  6. use think\Config;
  7. use think\Validate;
  8. use think\Db;
  9. /**
  10. * 会员接口
  11. */
  12. class Index extends Apic
  13. {
  14. protected $noNeedLogin = ['login'];
  15. protected $noNeedRight = '*';
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. //员工账号+密码登录
  21. public function login()
  22. {
  23. $username = input('username');
  24. $password = input('password');
  25. if (!$username || !$password) {
  26. $this->error(__('Invalid parameters'));
  27. }
  28. PcAdminLog::setTitle(__('Login'));
  29. //找员工
  30. $ret = $this->auth->login($username, $password);
  31. if ($ret) {
  32. $data = $this->auth->getUserinfo_simple();
  33. $this->success('登录成功', $data);
  34. } else {
  35. $msg = $this->auth->getError();
  36. $msg = $msg ? $msg : __('Username or password is incorrect');
  37. $this->error($msg);
  38. }
  39. }
  40. /**
  41. * 退出登录
  42. * @ApiMethod (POST)
  43. */
  44. public function logout()
  45. {
  46. if (!$this->request->isPost()) {
  47. $this->error(__('Invalid parameters'));
  48. }
  49. $this->auth->logout();
  50. $this->success('退出成功');
  51. }
  52. //用户详细资料
  53. public function getUserinfo(){
  54. $info = $this->auth->getUserinfo();
  55. $this->success(__('success'),$info);
  56. }
  57. //用户申请资料
  58. public function getUserapplyinfo(){
  59. $field = [
  60. 'company_name',
  61. 'company_code',
  62. 'company_registerdate',
  63. 'company_address',
  64. 'company_image',
  65. 'truename',
  66. 'idcard',
  67. 'idcard_images',
  68. 'bank_name',
  69. 'bank_branchname',
  70. 'bank_account',
  71. 'bank_card',
  72. ];
  73. $info = Db::name('company')->field($field)->where('id',$this->auth->id)->find();
  74. $info = info_domain_image($info,['company_image','idcard_images']);
  75. $this->success(1,$info);
  76. }
  77. /**
  78. * 修改会员个人信息
  79. *
  80. * @ApiMethod (POST)
  81. * @param string $avatar 头像地址
  82. * @param string $username 用户名
  83. * @param string $nickname 昵称
  84. * @param string $bio 个人简介
  85. */
  86. public function profile()
  87. {
  88. //检查
  89. $check = Db::name('company')->where('id',$this->auth->id)->find();
  90. if($check['status'] == 1){
  91. $this->success('资料审核通过后需联系客服修改');
  92. }
  93. $field = [
  94. 'company_name',
  95. 'company_code',
  96. 'company_registerdate',
  97. 'company_address',
  98. 'company_image',
  99. 'truename',
  100. 'idcard',
  101. 'idcard_images',
  102. 'bank_name',
  103. 'bank_branchname',
  104. 'bank_account',
  105. 'bank_card',
  106. ];
  107. $data = request_post_hub($field);
  108. $data['status'] = 0;
  109. $update_rs = Db::name('company')->where('id',$this->auth->id)->update($data);
  110. $this->success('资料更新完成');
  111. }
  112. }