主要依赖
implementation 'com.github.binarywang:weixin-java-miniapp:4.5.9.B'
implementation 'com.github.binarywang:weixin-java-open:4.5.9.B'
public R qrcode() {
try {
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
config.setAppid("your appid");
config.setSecret("your secret");
WxMaService wxMaService = new WxMaServiceImpl();
wxMaService.setWxMaConfig(config);
File qrcode = wxMaService.getQrcodeService().createWxaCodeUnlimit("二维码中携带的参数", "扫描二维码跳转地址", false, DEFAULT_ENV_VERSION, 200, true, null, false);
return R.data(qrcode);
} catch (WxErrorException e) {
return R.error(e.getMessage());
}
}