Browse Source

微信通过url获取配置,添加对url的处理

dev
yujintao 6 years ago
parent
commit
62bcedab80
  1. 10
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/impl/WxServiceImpl.java

10
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/impl/WxServiceImpl.java

@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 微信相关服务实现类
*
@ -28,6 +29,15 @@ public class WxServiceImpl implements WxService {
@Override
public Result<WxJsapiSignature> getWxConfig(String url) {
try {
String httpPrefix = "http://";
String httpsPrefix = "https://";
if (url.startsWith(httpPrefix)) {
url = url.replace(httpPrefix, httpsPrefix);
} else if (url.startsWith(httpsPrefix)) {
// 不做处理
} else {
url = httpsPrefix.concat(url);
}
WxJsapiSignature wxJsapiSignature = wxMpService.createJsapiSignature(url);
return new Result<WxJsapiSignature>().ok(wxJsapiSignature);
} catch (WxErrorException e) {

Loading…
Cancel
Save