|
@@ -3,7 +3,7 @@ package com.mrxu.framework.common.xcx.api;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.mrxu.framework.common.util.MrxuAssert;
|
|
import com.mrxu.framework.common.util.MrxuAssert;
|
|
|
import com.mrxu.framework.common.weixin.base.WxHttp;
|
|
import com.mrxu.framework.common.weixin.base.WxHttp;
|
|
|
-import com.mrxu.framework.common.xcx.bean.AddTemplateResponse;
|
|
|
|
|
|
|
+import com.mrxu.framework.common.xcx.WeixinUtil;
|
|
|
import com.mrxu.framework.common.xcx.bean.WxaCode;
|
|
import com.mrxu.framework.common.xcx.bean.WxaCode;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -12,9 +12,9 @@ import com.mrxu.framework.common.xcx.bean.WxaCode;
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
public class WxaCodeApi {
|
|
public class WxaCodeApi {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
private static String url = "https://api.weixin.qq.com/wxa/";
|
|
private static String url = "https://api.weixin.qq.com/wxa/";
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取小程序码,适用于需要的码数量较少的业务场景。通过该接口生成的小程序码,永久有效,有数量限制
|
|
* 获取小程序码,适用于需要的码数量较少的业务场景。通过该接口生成的小程序码,永久有效,有数量限制
|
|
|
* @param token
|
|
* @param token
|
|
@@ -23,9 +23,10 @@ public class WxaCodeApi {
|
|
|
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
|
|
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
|
|
|
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
|
|
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
|
|
|
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
|
|
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
|
|
|
|
|
+ * @param env_version 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public static WxaCode getwxacode(String token, String path, int width, boolean auto_color, JSONObject line_color, boolean is_hyaline) {
|
|
|
|
|
|
|
+ public static WxaCode getwxacode(String token, String path, int width, boolean auto_color, JSONObject line_color, boolean is_hyaline,String env_version) {
|
|
|
MrxuAssert.isTrue(width>=280, "二维码的宽度不小于280px");
|
|
MrxuAssert.isTrue(width>=280, "二维码的宽度不小于280px");
|
|
|
MrxuAssert.isTrue(width<=1280, "二维码的宽度不大于1280px");
|
|
MrxuAssert.isTrue(width<=1280, "二维码的宽度不大于1280px");
|
|
|
JSONObject queryParas = new JSONObject();
|
|
JSONObject queryParas = new JSONObject();
|
|
@@ -34,9 +35,10 @@ public class WxaCodeApi {
|
|
|
queryParas.put("auto_color", auto_color);
|
|
queryParas.put("auto_color", auto_color);
|
|
|
queryParas.put("line_color", line_color);
|
|
queryParas.put("line_color", line_color);
|
|
|
queryParas.put("is_hyaline", is_hyaline);
|
|
queryParas.put("is_hyaline", is_hyaline);
|
|
|
|
|
+ queryParas.put("env_version", WeixinUtil.getEnvVersion(env_version));
|
|
|
return WxHttp.post(WxaCode.class, url+"getwxacode"+"?access_token="+token, queryParas);
|
|
return WxHttp.post(WxaCode.class, url+"getwxacode"+"?access_token="+token, queryParas);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取小程序码,适用于需要的码数量极多的业务场景。通过该接口生成的小程序码,永久有效,数量暂无限制
|
|
* 获取小程序码,适用于需要的码数量极多的业务场景。通过该接口生成的小程序码,永久有效,数量暂无限制
|
|
|
* @param token
|
|
* @param token
|
|
@@ -60,7 +62,7 @@ public class WxaCodeApi {
|
|
|
queryParas.put("is_hyaline", is_hyaline);
|
|
queryParas.put("is_hyaline", is_hyaline);
|
|
|
return WxHttp.post(WxaCode.class, url+"getwxacodeunlimit"+"?access_token="+token, queryParas);
|
|
return WxHttp.post(WxaCode.class, url+"getwxacodeunlimit"+"?access_token="+token, queryParas);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取小程序二维码,适用于需要的码数量较少的业务场景。通过该接口生成的小程序码,永久有效,有数量限制
|
|
* 获取小程序二维码,适用于需要的码数量较少的业务场景。通过该接口生成的小程序码,永久有效,有数量限制
|
|
|
* @param token
|
|
* @param token
|
|
@@ -76,5 +78,5 @@ public class WxaCodeApi {
|
|
|
queryParas.put("width", width);
|
|
queryParas.put("width", width);
|
|
|
return WxHttp.post(WxaCode.class, url+"getwxacodeunlimit"+"https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token="+token, queryParas);
|
|
return WxHttp.post(WxaCode.class, url+"getwxacodeunlimit"+"https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token="+token, queryParas);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|