Index.php 3.2 KB

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