xingzai 1 سال پیش
والد
کامیت
b6105b1e9e
1فایلهای تغییر یافته به همراه145 افزوده شده و 0 حذف شده
  1. 145 0
      services/cygx/activity_poster.go

+ 145 - 0
services/cygx/activity_poster.go

@@ -328,3 +328,148 @@ func MakeCygxMp4HtmlImg(videoDuration string) (imgUrl string, err error) {
 	imgUrl = res.Data
 	return
 }
+
+func init() {
+	configValue := `<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+    <style>
+      body,
+      html {
+        margin: 0;
+        padding: 0;
+        font-family: PingFang SC;
+        color: #333;
+      }
+      * {
+        padding: 0;
+        margin: 0;
+      }
+      div {
+        box-sizing: border-box;
+      }
+      .box {
+        position: relative;
+        width: 2250px;
+        height: 3813px;
+      }
+      .img-responsive {
+        width: 100%;
+        height: 100%;
+        object-fit: cover;
+      }
+      .content-box {
+        position: absolute;
+        left: 162px;
+        top: 1290px;
+        width: 1926px;
+        height: 1170px;
+        padding: 30px;
+        background-color: #fff;
+        overflow: hidden;
+      }
+      .content-top .report-title {
+        font-weight: 500;
+        font-size: 108px;
+        line-height: 162px;
+        margin-bottom: 90px;
+      }
+      .content-top .report-research {
+        height: 250px;
+        overflow: hidden;
+      }
+
+      .content-top .report-research .research-author {
+        font-weight: 600;
+        font-size: 96px;
+        margin-left: 30px;
+      }
+      .content-top .report-research .research-author .time {
+        color: #999;
+        margin-top: 10px;
+        font-weight: 400;
+        font-size: 84px;
+      }
+      .content-top .report-research img {
+        width: 243px;
+        height: 243px;
+        float: left;
+        object-fit: cover;
+        margin-right: 30px;
+      }
+      .abstract-content {
+        position: relative;
+        margin-top: 90px;
+        font-size: 96px;
+        line-height: 150px;
+        padding-bottom: 126px;
+        border-bottom: 6px dashed #dcdfe6;
+      }
+      .abstract-content:after {
+        content: "";
+        position: absolute;
+        width: 12px;
+        height: 84px;
+        left: 0;
+        top: 25px;
+        background-color: #3385ff;
+      }
+      .detail-report {
+        margin-top: 90px;
+        font-size: 96px;
+        line-height: 150px;
+      }
+      .text-two {
+        -webkit-line-clamp: 2;
+        -webkit-box-orient: vertical;
+        display: -webkit-box;
+        overflow: hidden;
+        text-overflow: ellipsis;
+      }
+    </style>
+  </head>
+  <body>
+    <div class="box">
+      <img class="img-responsive" src="https://hzstatic.hzinsights.com/yx_xcx/share_bg.jpg" alt="" />
+      <div class="content-box">
+        <div class="content-top">
+          <div class="report-title">{{Title}} 这里是标题</div>
+          <div class="report-research">
+            <img class="user-imh" src="https://hzstatic.hzinsights.com/cygx/config/ico_mp3.png" alt="这里是作者头像" />
+            <div class="research-author">
+              <p class="text-two">{{ SellerAndMobile }} 这里名称</p>
+              <p class="time">{{ PublishDate }}这里是发布时间</p>
+            </div>
+          </div>
+          <div class="abstract-content">&nbsp;&nbsp;摘要:&nbsp;{{ Abstract }}这里是摘要这里是摘要,</div>
+        </div>
+        <div class="detail-report">这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容</div>
+      </div>
+    </div>
+  </body>
+</html>
+`
+	//configValue = strings.Replace(configValue, "{{TIME}}", videoDuration, -1)
+	htm2ImgReq := make(map[string]interface{})
+	htm2ImgReq["html_content"] = configValue
+	htm2ImgReq["width"] = 2250
+	htm2ImgReq["height"] = 3813
+	res, err := postHtml2Img(htm2ImgReq)
+	if err != nil || res == nil {
+		//msg = "html转图片请求失败"
+		fmt.Println(err)
+		return
+	}
+	if res.Code != 200 {
+		//msg = "html转图片请求失败"
+		err = errors.New("html转图片失败: " + res.Msg)
+		fmt.Println(err)
+		return
+	}
+	imgUrl := res.Data
+
+	fmt.Println(imgUrl)
+}