Usersys.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. *
  4. * User: anyluck
  5. * Date: 2020/6/8
  6. * Time: 13:57
  7. */
  8. namespace app\admin\controller;
  9. use app\common\controller\Backend;
  10. use think\facade\Db;
  11. use think\facade\Request;
  12. use think\facade\Session;
  13. use think\facade\View;
  14. class Usersys extends Backend
  15. {
  16. // 代理商系统管理
  17. //我的邀请码
  18. public function my()
  19. {
  20. // if (Request::isPost()){
  21. // $data = Request::post();
  22. // foreach ($data as $k=>$v){
  23. // $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
  24. // }
  25. // json_result(200,"修改成功",$data);
  26. // }
  27. $is_admin=Session::get("is_admin");
  28. if ($is_admin){
  29. $adminid=Session::get("adminid");
  30. $where["id"]=$adminid;
  31. $code=\app\common\model\User::where($where)->value("code");
  32. // var_dump($code);die();
  33. // View::assign('config',json_encode($list));
  34. // $view = [
  35. // 'info' => $list,
  36. // 'title' => lang('add'),
  37. // ];
  38. View::assign("code",$code);
  39. return View::fetch();
  40. }else{
  41. $this->error("当前登录账号不是代理商 无法查看信息");
  42. exit();
  43. }
  44. }
  45. // 账号信息管理
  46. public function account()
  47. {
  48. if (Request::isPost()) {
  49. $data = Request::post();
  50. $adminid=Session::get("adminid");
  51. $where["id"]=$adminid;
  52. $pwd=input("pwd");
  53. if (!$pwd){
  54. unset($data["pwd"]);
  55. }else{
  56. $data["pwd"] = password_hash($pwd, PASSWORD_DEFAULT);;
  57. }
  58. // var_dump($data);die();
  59. \app\common\model\User::update($data,$where);
  60. json_result(200, "修改成功", $data);
  61. }
  62. $is_admin=Session::get("is_admin");
  63. if ($is_admin){
  64. $adminid=Session::get("adminid");
  65. $where["id"]=$adminid;
  66. $code=\app\common\model\User::where($where)->find();
  67. unset($code["pwd"]);
  68. View::assign("user",$code);
  69. return View::fetch();
  70. }else{
  71. $this->error("当前登录账号不是代理商 无法查看信息");
  72. exit();
  73. }
  74. }
  75. // 代理收款信息管理
  76. public function message()
  77. {
  78. if (Request::isPost()) {
  79. $data = Request::post();
  80. $adminid=Session::get("adminid");
  81. $where["user_id"]=$adminid;
  82. \app\common\model\UserMessage::update($data,$where);
  83. json_result(200, "修改成功", $data);
  84. }
  85. $is_admin=Session::get("is_admin");
  86. if ($is_admin){
  87. $adminid=Session::get("adminid");
  88. $where["user_id"]=$adminid;
  89. $code=\app\common\model\UserMessage::where($where)->find();
  90. if (!$code){
  91. \app\common\model\UserMessage::create($where);
  92. $code=\app\common\model\UserMessage::where($where)->find();
  93. }
  94. View::assign("user",$code);
  95. return View::fetch();
  96. }else{
  97. $this->error("当前登录账号不是代理商 无法查看信息");
  98. exit();
  99. }
  100. }
  101. }