User.php 3.1 KB

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