| | |
| | | return openid;
|
| | | }
|
| | |
|
| | | public String generateAcode(String scene,String path,String imgName,String width){
|
| | | return generateAcode(scene, path, imgName, width, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 生成小程序码
|
| | |
| | | * @param imgName 图片唯一名称
|
| | | * @return
|
| | | */
|
| | | public String generateAcode(String scene,String path,String imgName,String width){
|
| | | public String generateAcode(String scene,String path,String imgName,String width, Integer type){
|
| | | String urlPrefix=businessUtil.getViewUrl();
|
| | | String imgPath=Constants.IMG_UPLOAD_PATH+imgName;
|
| | | if(!FileUtil.exist(imgPath)){
|
| | | //调用二维码接口
|
| | | String url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}", getAccessToken());
|
| | |
|
| | | cn.hutool.json.JSONObject obj = JSONUtil.createObj();
|
| | | //最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
|
| | | // 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
|
| | | //调用二维码接口
|
| | | String url = null;
|
| | | if (type == null) {
|
| | | // 该接口无数量限制,但是 scene 传参最大字符长度为32个字符
|
| | | url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}", getAccessToken());
|
| | | obj.put("scene", scene);
|
| | | //必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index,
|
| | | // 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
|
| | | obj.put("path", path);
|
| | | } else {
|
| | | // 该接口存在数量限制, 总共可生成10w个, 但参数是接在path后面
|
| | | url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacode?access_token={}", getAccessToken());
|
| | | obj.put("path", path + "?" + scene );
|
| | | }
|
| | |
|
| | | //最小 280px,最大 1280px
|
| | | obj.put("width", width);
|
| | | obj.put("auto_color", false);
|