|
@@ -329,147 +329,76 @@ func MakeCygxMp4HtmlImg(videoDuration string) (imgUrl string, err error) {
|
|
return
|
|
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;
|
|
|
|
- }
|
|
|
|
|
|
+//func init() {
|
|
|
|
+// //MakeActivityMomentsImg(2850)
|
|
|
|
+// var condition string
|
|
|
|
+// var pars []interface{}
|
|
|
|
+// condition = " AND chart_permission_id = 31 AND publish_status = 1 ORDER BY activity_id DESC "
|
|
|
|
+// list, errList := cygx.GetActivityListAll(condition, pars, 0, 9999)
|
|
|
|
+// if errList != nil {
|
|
|
|
+// fmt.Println(errList)
|
|
|
|
+// return
|
|
|
|
+// }
|
|
|
|
+// for _, v := range list {
|
|
|
|
+// MakeActivityMomentsImg(v.ActivityId)
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//}
|
|
|
|
|
|
- .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"> 摘要: {{ Abstract }}这里是摘要这里是摘要,</div>
|
|
|
|
- </div>
|
|
|
|
- <div class="detail-report">这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容</div>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </body>
|
|
|
|
-</html>
|
|
|
|
-`
|
|
|
|
- //configValue = strings.Replace(configValue, "{{TIME}}", videoDuration, -1)
|
|
|
|
|
|
+// 生成活动分享到朋友圈的图片
|
|
|
|
+func MakeActivityMomentsImg(activityId int) {
|
|
|
|
+ var err error
|
|
|
|
+ //time.Sleep(3*time.Second) // 有时候同时添加多个活动,延迟三秒
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("err:", err)
|
|
|
|
+ go alarm_msg.SendAlarmMsg("生成活动分享到朋友圈的图片失败,MakeActivityMomentsImg Err:"+err.Error()+"活动ID"+strconv.Itoa(activityId), 3)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+ detail, e := cygx.GetAddActivityInfoById(activityId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 不是研选活动不生成图片
|
|
|
|
+ if detail.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var configCode string
|
|
|
|
+ if detail.IsResearchPoints == 1 {
|
|
|
|
+ configCode = "activity_moments_img_points_html" // 扣点活动
|
|
|
|
+ } else {
|
|
|
|
+ configCode = "activity_moments_img_html" // 非扣点活动
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ detailConfig, e := cygx.GetCygxConfigDetailByCode(configCode)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = errors.New("GetCygxConfigDetailByCode 获取生成活动分享到朋友圈的图片格式信息失败, Err: " + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ configValue := detailConfig.ConfigValue
|
|
|
|
+ configValue = strings.Replace(configValue, "{{Title}}", detail.ActivityName, -1)
|
|
|
|
+ configValue = strings.Replace(configValue, "{{ActivityTypeName}}", detail.ActivityTypeName, -1)
|
|
|
|
+ configValue = strings.Replace(configValue, "{{Label}}", detail.Label, -1)
|
|
|
|
+ configValue = strings.Replace(configValue, "{{ActivityTimeText}}", detail.ActivityTimeText, -1)
|
|
htm2ImgReq := make(map[string]interface{})
|
|
htm2ImgReq := make(map[string]interface{})
|
|
htm2ImgReq["html_content"] = configValue
|
|
htm2ImgReq["html_content"] = configValue
|
|
htm2ImgReq["width"] = 2250
|
|
htm2ImgReq["width"] = 2250
|
|
htm2ImgReq["height"] = 3813
|
|
htm2ImgReq["height"] = 3813
|
|
res, err := postHtml2Img(htm2ImgReq)
|
|
res, err := postHtml2Img(htm2ImgReq)
|
|
if err != nil || res == nil {
|
|
if err != nil || res == nil {
|
|
- //msg = "html转图片请求失败"
|
|
|
|
- fmt.Println(err)
|
|
|
|
|
|
+ err = errors.New("html转图片失败: " + res.Msg)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if res.Code != 200 {
|
|
if res.Code != 200 {
|
|
- //msg = "html转图片请求失败"
|
|
|
|
err = errors.New("html转图片失败: " + res.Msg)
|
|
err = errors.New("html转图片失败: " + res.Msg)
|
|
- fmt.Println(err)
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
imgUrl := res.Data
|
|
imgUrl := res.Data
|
|
-
|
|
|
|
- fmt.Println(imgUrl)
|
|
|
|
|
|
+ // 记录海报信息
|
|
|
|
+ err = cygx.UpdateCygxActivityMomentsImg(imgUrl, activityId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|