Logout.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\api\controller;
  3. /**
  4. *
  5. *
  6. * ----------------------------------------------------------------------------
  7. *
  8. * 登出控制器
  9. */
  10. class Logout extends MobileMember
  11. {
  12. public function initialize()
  13. {
  14. parent::initialize(); // TODO: Change the autogenerated stub
  15. }
  16. /**
  17. * @api {POST} api/Logout/index 注销
  18. * @apiVersion 1.0.0
  19. * @apiGroup Logout
  20. *
  21. * @apiHeader {String} X-DS-KEY 用户授权token
  22. *
  23. * @apiParam {String} username 用户名
  24. * @apiParam {String} client 用户端 wap手机端
  25. *
  26. * @apiSuccess {String} code 返回码,10000为成功
  27. * @apiSuccess {String} message 返回消息
  28. */
  29. public function index()
  30. {
  31. if (empty(input('post.username')) || !in_array(input('post.client'), $this->client_type_array)) {
  32. ds_json_encode(10001, lang('param_error'));
  33. }
  34. $mbusertoken_model = model('mbusertoken');
  35. if ($this->member_info['member_name'] == trim(input('post.username'))) {
  36. $condition = array();
  37. $condition[] = array('member_id', '=', $this->member_info['member_id']);
  38. $condition[] = array('member_clienttype', '=', input('post.client'));
  39. $mbusertoken_model->delMbusertoken($condition);
  40. session(null); //删除session中的member_id下,因为次登录时要整合cookie中的商品到数据库中
  41. ds_json_encode(10000, '', '', '', true);
  42. } else {
  43. ds_json_encode(10001, lang('param_error'));
  44. }
  45. }
  46. }