| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- namespace app\index\controller;
- use think\Controller;
- class Index extends Common
- {
- /**
- * 获取敏感词
- *
- * @access public
- * @return array JsonString
- */
- public function sensitiveWords()
- {
- // 验证token.
- $tokenStatus = $this->verifyApiToken();
- $code = -2;
- $msg = '错误';
- if ($tokenStatus === false) {
- $msg = 'token错误';
- return json(['code' => $code, 'data' => [], 'msg' => $msg]);
- }
- try {
- // 获取敏感词.
- $wordsField = ['*'];
- $sysWordsWhere['sensitivewords_status'] = 1;
- $sysWordsWhere['sensitivewords_for'] = 1;
- // 查询客服敏感词.
- $userSensitive = model('sensitivewords')->selectWords($wordsField, $sysWordsWhere);
- // 获取敏感词.
- $wordsField = ['*'];
- $sysWordsWhere['sensitivewords_status'] = 1;
- $sysWordsWhere['sensitivewords_for'] = 2;
- // 查询用户敏感词.
- $serverSensitive = model('sensitivewords')->selectWords($wordsField, $sysWordsWhere);
- $data = [
- 'userSensitive' => $userSensitive,
- 'serverSensitive' => $serverSensitive,
- ];
- return json(['code' => 1, 'data' => $data, 'msg' => '成功']);
- } catch (\Exception $e) {
- return json(['code' => $code, 'data' => [], 'msg' => $msg]);
- }//end try
- }//end sensitiveWords()
- public function index()
- {
- return $this->fetch();
- }
- // pc客户端
- public function chat()
- {
- // 跳转到移动端
- if (request()->isMobile()) {
- $param = http_build_query([
- 'id' => input('param.id'),
- 'name' => input('param.name'),
- 'group' => input('param.group'),
- 'avatar' => input('param.avatar')
- ]);
- $this->redirect('/index/index/mobile?' . $param);
- }
- $this->assign([
- 'socket' => config('socket'),
- 'id' => input('param.id'),
- 'name' => input('param.name'),
- 'group' => input('param.group'),
- 'avatar' => input('param.avatar'),
- ]);
- return $this->fetch();
- }
- // 移动客户端
- public function mobile()
- {
- $this->assign([
- 'socket' => config('socket'),
- 'id' => input('param.id'),
- 'name' => input('param.name'),
- 'group' => input('param.group'),
- 'avatar' => input('param.avatar'),
- ]);
- return $this->fetch();
- }
- public function systime()
- {
- $now = time();
- $time = date('Y-m-d H:i', $now);
- $settings = db('settings')->where('id', 1)->find();
- return json(['code' => 1, 'data' => ['time' => $time, 'logo' => $settings['logo'], 'enterprise_name' => $settings['enterprise_name']], 'msg' => '成功']);
- }
- //得到公共配置信息
- public function getConfigs()
- {
- $now = time();
- $time = date('Y-m-d H:i', $now);
- $checkcode = db('platform')->where('platform_code', 'Customer-Service')->find();
- $chkcode = $checkcode ? $checkcode['platform_status'] : 1;
- $settings = db('settings')->where('id', 1)->find();
- $ret = [
- 'time' => $time,
- 'checkcodeflag' => $chkcode,
- 'logo' => $settings['logo'],
- 'enterprise_name' => $settings['enterprise_name'],
- ];
- return json(['code' => 1, 'data' => $ret, 'msg' => 'success']);
- }
- }
|