/**
  * 重载数据编码。
  * @param  mixed  $data  数据
  * @param  string $type  数据格式
  * @return string        格式化化后的字符串
  */
 protected function encodeData($data, $type = '')
 {
     if (APP_DEBUG) {
         trace('重载数据编码encodeData...');
     }
     if (empty($data)) {
         return '';
     }
     if ('json' == $type) {
         //设置内容类型
         $this->setContentType($type);
         //设置数据
         return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
     } else {
         return parent::encodeData($data, $type);
     }
 }