后台
/**
* @param id
* @param chuanming
* @param host
* @param response
* @Method generateQRCode
* @Author charsming
* @Version 1.0
* @Description 生成船舶二维码
* @Return void
* @Date 2021-12-30 20:51
*/
@GetMapping("/getQRCode/{id}/{chuanming}/{host}")
@ResponseBody
public void generateQRCode(@PathVariable("id") String id, @PathVariable("chuanming") String chuanming, @PathVariable("host") String host,
HttpServletResponse response) {
String qrCodeUrl = host + "/charsming/bordingShip/mobile?id=" + id + "&chuanming=" + chuanming;
try {
QrConfig qrConfig = new QrConfig(300, 300);
QrCodeUtil.generate(qrCodeUrl, qrConfig, "png", response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
js
//二维码
function resetPwd(id,chuanming) {
var host = window.location.host
layer.open({
type: 1,
title: '船舶二维码',
maxmin: true,
shadeClose: false, // 点击遮罩关闭层
content: `<img src="/charsming/shipB/getQRCode/${id}/${chuanming}/${host}">`
});
}