63 lines
54 KiB
Go
63 lines
54 KiB
Go
|
package controller
|
|||
|
|
|||
|
import (
|
|||
|
"fmt"
|
|||
|
"github.com/gin-gonic/gin"
|
|||
|
)
|
|||
|
|
|||
|
func GetDownloadDeloy(c *gin.Context) {
|
|||
|
entId, _ := c.Get("ent_id")
|
|||
|
kefuName, _ := c.Get("kefu_name")
|
|||
|
host := c.Request.Host
|
|||
|
config := fmt.Sprintf(`
|
|||
|
const KEFU_NAME="%s";//商户账号
|
|||
|
const ENT_ID="%s";//商户编号
|
|||
|
`, kefuName, entId)
|
|||
|
// 生成HTML内容
|
|||
|
htmlContent := `<!DOCTYPE html>
|
|||
|
<html>
|
|||
|
<head>
|
|||
|
<meta charset="UTF-8">
|
|||
|
<title>在线咨询</title>
|
|||
|
<meta name="renderer" content="webkit">
|
|||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
|||
|
<script>
|
|||
|
` + config + `
|
|||
|
</script>
|
|||
|
<style>
|
|||
|
body{margin: 0px;overflow: hidden;}
|
|||
|
</style>
|
|||
|
<script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div id="chatBox"></div>
|
|||
|
</body>
|
|||
|
<script>
|
|||
|
if (/MicroMessenger/i.test(navigator.userAgent)) {
|
|||
|
$("#chatBox").html("<img width='100%' src='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCARIAtADASIAAhEBAxEB/8QAHAABAAICAwEAAAAAAAAAA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UaI9qc2805t5p2dMpz9IHXXFw0/dq+nr7JA+GWVquq41Ztaj+zCd/XOPtKzFJLTzMlie6OVi7mOR2FaqLyVFOABOVutL/cKKSjqK7MUyIk2yJjHSY6b3NRFXl3lfwTenNNV+p66SloOCkkbN7lkdtTHzL2r3Fu9zC3PoPdFqaKqY3jUsMrXImFRHo5qLhf1gQnudWKgv+qPA7lE6ambA6XY16t3KmETKoqd/YpZdB0UFt91u60VM3EFOyZjEV2Va1HtROfabOkGNZ7s17RjWoz8YTCckb5bTnSf/jRff9f/AH2gef6z/lrev6XJ/eUk/c7VWXa5yNdh7LXUOY5OSoqImFRSP1mn/bW9f0uT+8SPuffxnd//AKVUfYgFQXm5yrzVeeV/KLxpum0tfLlSWxlkr1nkaiSS+GYa1ETLnKmOiYzj2FJLdY54LFoy5XNJ41uNd+JU8bXoro415vcqZ7cYyBmjs+m6S33O/VEFTVW9lctJR00cu
|
|||
|
|
|||
|
}else{
|
|||
|
let iframe = document.createElement("iframe")
|
|||
|
iframe.id = "iframeChatBox"
|
|||
|
iframe.src = "https://` + host + `/chatIndex?ent_id="+ENT_ID+"&kefu_name="+KEFU_NAME;
|
|||
|
iframe.style.border = "none";
|
|||
|
iframe.width = "100%";
|
|||
|
iframe.height = window.innerHeight + "px";
|
|||
|
document.getElementById('chatBox')?.appendChild(iframe) //向指定dom插入iframe
|
|||
|
// 窗口变化时改变iframe高度,解决弹出键盘遮挡输入框问题
|
|||
|
$(window).resize(function(){
|
|||
|
$('#iframeChatBox').height($(window).height());
|
|||
|
})
|
|||
|
}
|
|||
|
</script>
|
|||
|
</html>
|
|||
|
`
|
|||
|
|
|||
|
// 设置响应头,让浏览器下载
|
|||
|
c.Header("Content-Disposition", "attachment; filename=chat.html")
|
|||
|
c.Header("Content-Type", "application/octet-stream")
|
|||
|
// 将HTML内容写入响应
|
|||
|
c.String(200, htmlContent)
|
|||
|
}
|