Logout.php 1.8 KB

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