<?php
namespace app\api\controller;
/**
 * ============================================================================
 * 
 * ============================================================================
 * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司，并保留所有权利。
 * 网站地址: https://www.valimart.net/
 * ----------------------------------------------------------------------------
 * 
 * ============================================================================
 * 登出控制器
 */
class Logout extends MobileMember
{
    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
    }

    /**
     * @api {POST} api/Logout/index 注销
     * @apiVersion 1.0.0
     * @apiGroup Logout
     * 
     * @apiHeader {String} X-DS-KEY 用户授权token
     * 
     * @apiParam {String} username 用户名
     * @apiParam {String} client 用户端 wap手机端
     * 
     * @apiSuccess {String} code 返回码,10000为成功
     * @apiSuccess {String} message  返回消息
     */
    public function index(){
        if(empty(input('post.username')) || !in_array(input('post.client'), $this->client_type_array)) {
            ds_json_encode(10001,lang('param_error'));
        }

        $mbusertoken_model = model('mbusertoken');

        if ($this->member_info['member_name'] == trim(input('post.username'))) {
            $condition = array();
            $condition[] = array('member_id','=',$this->member_info['member_id']);
            $condition[] = array('member_clienttype','=',input('post.client'));
            $mbusertoken_model->delMbusertoken($condition);
            session(null); //删除session中的member_id下，因为次登录时要整合cookie中的商品到数据库中
            ds_json_encode(10000, '', '', '', false);
        } else {
            ds_json_encode(10001,lang('param_error'));
        }
    }
}