11
This commit is contained in:
parent
77ba817569
commit
3f8fed2dd6
|
@ -2,7 +2,6 @@ package template_switch_info
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
|
@ -60,24 +59,8 @@ type MaterialItem struct {
|
|||
}
|
||||
|
||||
// 获取模板开关信息(目前写死,以后后台做好了功能再更新变动)
|
||||
func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMaterialImg string) (resp GetTemplateSwitchInfoRsp, err error) {
|
||||
if templateJsonStr == nil || *templateJsonStr == "" {
|
||||
return GetTemplateSwitchInfoRsp{
|
||||
Id: templateId,
|
||||
Material: templateMaterialImg,
|
||||
MaterialData: MaterialData{
|
||||
Logo: Logo{
|
||||
Material: "/image/logo/aHnT1_rzubdwax_scale.png",
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
var templateJsonInfo TemplateSimpleParseInfo
|
||||
if err = json.Unmarshal([]byte(*templateJsonStr), &templateJsonInfo); err != nil {
|
||||
logx.Error(err)
|
||||
return GetTemplateSwitchInfoRsp{}, errors.New("解析模板json获取DIY开关设置失败")
|
||||
}
|
||||
mapSwitchInfo := GetTemplateSwitchInfoRsp{
|
||||
func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMaterialImg string) GetTemplateSwitchInfoRsp {
|
||||
returnData := GetTemplateSwitchInfoRsp{
|
||||
Id: templateId,
|
||||
Material: templateMaterialImg,
|
||||
MaterialData: MaterialData{
|
||||
|
@ -86,6 +69,14 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa
|
|||
},
|
||||
},
|
||||
}
|
||||
if templateJsonStr == nil || *templateJsonStr == "" {
|
||||
return returnData
|
||||
}
|
||||
var templateJsonInfo TemplateSimpleParseInfo
|
||||
if err := json.Unmarshal([]byte(*templateJsonStr), &templateJsonInfo); err != nil {
|
||||
logx.Error("解析模板json获取DIY开关设置失败", err)
|
||||
return returnData
|
||||
}
|
||||
for _, v := range templateJsonInfo.MaterialList {
|
||||
if v.Type == "combine" && !v.Visible {
|
||||
return GetTemplateSwitchInfoRsp{
|
||||
|
@ -96,40 +87,40 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa
|
|||
Material: "/image/logo/aHnT1_rzubdwax_scale.png",
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
switch v.Tag {
|
||||
case "Phone": //电话
|
||||
mapSwitchInfo.MaterialData.Phone = Phone{
|
||||
returnData.MaterialData.Phone = Phone{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "000 xxx xxx 1111",
|
||||
}
|
||||
case "Address": //地址
|
||||
mapSwitchInfo.MaterialData.Address = Address{
|
||||
returnData.MaterialData.Address = Address{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "USA",
|
||||
}
|
||||
case "Website":
|
||||
mapSwitchInfo.MaterialData.Website = Website{
|
||||
returnData.MaterialData.Website = Website{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "https://www.xxxxxx.com",
|
||||
}
|
||||
case "QRcode":
|
||||
mapSwitchInfo.MaterialData.QRcode = QRcode{
|
||||
returnData.MaterialData.QRcode = QRcode{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "qrcode xxxxxxx",
|
||||
}
|
||||
case "Slogan":
|
||||
mapSwitchInfo.MaterialData.Slogan = Slogan{
|
||||
returnData.MaterialData.Slogan = Slogan{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "slogan xxxxxxx",
|
||||
}
|
||||
}
|
||||
}
|
||||
return mapSwitchInfo, nil
|
||||
return returnData
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user