f
This commit is contained in:
@@ -26,13 +26,19 @@ func NewImageService() *ImageService {
|
||||
|
||||
// ProcessImageWithQRCode 处理图片,在中间添加二维码
|
||||
func (s *ImageService) ProcessImageWithQRCode(qrcodeType, qrcodeUrl string) ([]byte, string, error) {
|
||||
// 1. 根据qrcodeType确定使用哪张背景图(与 uniapp_ycc/src/static/invitation 下海报一致,需复制到本目录 static/images)
|
||||
// 1. 根据qrcodeType确定使用哪张背景图(与 uniapp static/invitation 下海报一致,需复制到本目录 static/images)
|
||||
var backgroundImageName string
|
||||
switch qrcodeType {
|
||||
case "promote":
|
||||
backgroundImageName = "tg_qrcode_1.png"
|
||||
case "invitation":
|
||||
backgroundImageName = "invitation_01.png" // 与 uniapp static/invitation/invitation_01.png 同一张图,部署时拷贝到 static/images
|
||||
case "invitation", "invitation_01":
|
||||
backgroundImageName = "invitation_01.png"
|
||||
case "invitation_02":
|
||||
backgroundImageName = "invitation_02.png"
|
||||
case "invitation_03":
|
||||
backgroundImageName = "invitation_03.png"
|
||||
case "invitation_04":
|
||||
backgroundImageName = "invitation_04.png"
|
||||
default:
|
||||
backgroundImageName = "tg_qrcode_1.png" // 默认使用第一张图片
|
||||
}
|
||||
@@ -77,12 +83,11 @@ func (s *ImageService) ProcessImageWithQRCode(qrcodeType, qrcodeUrl string) ([]b
|
||||
qrX = 192 // 距左边180px
|
||||
qrY = imgHeight - qrSize - 190 // 距底边100px
|
||||
|
||||
case "invitation":
|
||||
// invitation类型:精确设置二维码尺寸
|
||||
qrSize = 138 // 固定尺寸320px
|
||||
// 中间偏上位置
|
||||
qrX = (imgWidth - qrSize) / 2 // 水平居中
|
||||
qrY = 140 // 垂直位置200px
|
||||
case "invitation", "invitation_01", "invitation_02", "invitation_03", "invitation_04":
|
||||
// invitation 类型(多模板):二维码尺寸与位置一致
|
||||
qrSize = 138
|
||||
qrX = (imgWidth - qrSize) / 2
|
||||
qrY = 140
|
||||
|
||||
default:
|
||||
// 默认(promote样式)
|
||||
@@ -152,7 +157,7 @@ func (s *ImageService) loadImage(path string) (image.Image, error) {
|
||||
|
||||
// GetSupportedImageTypes 获取支持的图片类型列表
|
||||
func (s *ImageService) GetSupportedImageTypes() []string {
|
||||
return []string{"promote", "invitation"}
|
||||
return []string{"promote", "invitation", "invitation_01", "invitation_02", "invitation_03", "invitation_04"}
|
||||
}
|
||||
|
||||
// CheckImageExists 检查指定类型的背景图是否存在
|
||||
@@ -161,8 +166,14 @@ func (s *ImageService) CheckImageExists(qrcodeType string) bool {
|
||||
switch qrcodeType {
|
||||
case "promote":
|
||||
backgroundImageName = "tg_qrcode_1.png"
|
||||
case "invitation":
|
||||
case "invitation", "invitation_01":
|
||||
backgroundImageName = "invitation_01.png"
|
||||
case "invitation_02":
|
||||
backgroundImageName = "invitation_02.png"
|
||||
case "invitation_03":
|
||||
backgroundImageName = "invitation_03.png"
|
||||
case "invitation_04":
|
||||
backgroundImageName = "invitation_04.png"
|
||||
default:
|
||||
backgroundImageName = "tg_qrcode_1.png"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user