1 Star 0 Fork 13

shock1974 / 春松客服小程序版

forked from SHIH / 春松客服小程序版 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

春松客服小程序版

原生微信小程序客服对接页面

原生page版 webview版

用法

  1. 实现接口

    • 找到后台项目中接口IMController接口/text/{appid},位于contact-center/app/src/main/java/com/chatopera/cc/controller/apps/IMController.java 983行左右,将RequestMapping改为GetMapping;

    • 复制此接口放其后,将GetMapping改为PostMapping,在其上添加@ResponseBody注解,将ModelAndView替换为Map<String,Object>,修改接口第一行内容为Map<String,Object> params = new HashMap<>(); ,将view.addObject全部替换为params.put,最后一行改为return params; 即将原来传入模板引擎的参数全部放入map返回给前端如下所示

      查看示例接口代码
      @ResponseBody
      @PostMapping("/text/{appid}")
      @Menu(type = "im", subtype = "index", access = true)
      public Map<String,Object> postText(
              HttpServletRequest request,
              @PathVariable String appid,
              @Valid String traceid,
              @Valid String aiid,
              @Valid String exchange,
              @Valid String title,
              @Valid String url,
              @Valid String skill,
              @Valid String id,
              @Valid String userid,
              @Valid String agent,
              @Valid String name,
              @Valid String email,
              @Valid String phone,
              @Valid String ai,
              @Valid String orgi,
              @Valid String product,
              @Valid String description,
              @Valid String imgurl,
              @Valid String pid,
              @Valid String purl) throws Exception {
          Map<String,Object> params = new HashMap<>();
          CousultInvite invite = OnlineUserProxy.consult(
                  appid, StringUtils.isBlank(orgi) ? Constants.SYSTEM_ORGI : orgi);
      
          params.put("hostname", request.getServerName());
          params.put("port", request.getServerPort());
          params.put("schema", request.getScheme());
          params.put("appid", appid);
          params.put("channelVisitorSeparate", channelWebIMVisitorSeparate);
          params.put("ip", MainUtils.md5(request.getRemoteAddr()));
      
          if (invite.isSkill() && invite.isConsult_skill_fixed()) { 
              // 添加技能组ID
              // 忽略前端传入的技能组ID
              params.put("skill", invite.getConsult_skill_fixed_id());
          } else if (StringUtils.isNotBlank(skill)) {
              params.put("skill", skill);
          }
      
          if (StringUtils.isNotBlank(agent)) {
              params.put("agent", agent);
          }
      
          params.put("client", MainUtils.getUUID());
          params.put("sessionid", request.getSession().getId());
      
          params.put("id", id);
          if (StringUtils.isNotBlank(ai)) {
              params.put("ai", ai);
          }
          if (StringUtils.isNotBlank(exchange)) {
              params.put("exchange", exchange);
          }
      
          params.put("name", name);
          params.put("email", email);
          params.put("phone", phone);
          params.put("userid", userid);
      
          params.put("product", product);
          params.put("description", description);
          params.put("imgurl", imgurl);
          params.put("pid", pid);
          params.put("purl", purl);
      
          if (StringUtils.isNotBlank(traceid)) {
              params.put("traceid", traceid);
          }
          if (StringUtils.isNotBlank(title)) {
              params.put("title", title);
          }
          if (StringUtils.isNotBlank(traceid)) {
              params.put("url", url);
          }
      
          if (invite != null) {
              params.put("inviteData", invite);
              params.put("orgi", invite.getOrgi());
              params.put("appid", appid);
      
              if (StringUtils.isNotBlank(aiid)) {
                  params.put("aiid", aiid);
              } else if (StringUtils.isNotBlank(invite.getAiid())) {
                  params.put("aiid", invite.getAiid());
              }
          }
      
          return params;
      }
  2. 升级netty-socketio版本,因低版本会导致weapp.socket.io无法连接

    <dependency>
        <groupId>com.corundumstudio.socketio</groupId>
        <artifactId>netty-socketio</artifactId>
        <version>1.7.19</version>
    </dependency>
  3. 配置index页面js文件中参数 配置部署项目的协议、域名、端口等。

鸣谢

MIT License Copyright (c) 2021 SHIH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

🌲春松客服小程序对接页面 展开 收起
微信
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
微信
1
https://gitee.com/jenkin-han/cskefu-wxapp.git
git@gitee.com:jenkin-han/cskefu-wxapp.git
jenkin-han
cskefu-wxapp
春松客服小程序版
master

搜索帮助