Userset.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 用户设置,从user拿出来
  7. */
  8. class Userset extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = '*';
  12. //用户详细资料
  13. public function userinfo(){
  14. $field = [
  15. 'id','real_status','idcard_status','open_match_video','open_match_audio','open_match_typing','free_video','free_audio','free_typing'
  16. ];
  17. $info = Db::name('user')->field($field)->where('id',$this->auth->id)->find();
  18. $rs['userinfo'] = $info;
  19. $rs['video_min_price'] = config('site.video_min_price');
  20. $rs['audio_min_price'] = config('site.audio_min_price');
  21. $rs['typing_min_price'] = config('site.typing_min_price');
  22. $this->success('success',$rs);
  23. }
  24. /**
  25. * 修改会员状态信息
  26. */
  27. public function set_status_switch()
  28. {
  29. if($this->auth->idcard_status != 1){
  30. $this->error('未通过实名认证');
  31. }
  32. if($this->auth->real_status != 1){
  33. $this->error('未通过真人认证');
  34. }
  35. //开始
  36. $field_array = ['open_match_video','open_match_audio','open_match_typing','free_video','free_audio','free_typing'];
  37. $data = [];
  38. $field = input_post('switch','default');
  39. $value = input_post('switch_value',0);
  40. if(!in_array($field,$field_array)){
  41. $this->error();
  42. }
  43. if(!empty($field)){
  44. $data[$field] = $value;
  45. }
  46. if(empty($data)){
  47. $this->error('没有任何改变');
  48. }
  49. Db::name('user')->where('id',$this->auth->id)->update($data);
  50. $this->success();
  51. }
  52. }