Commit f827f4c9 authored by 吴春's avatar 吴春
parents 0c9ee628 40d5b68b
...@@ -13,6 +13,38 @@ namespace Mall.Common ...@@ -13,6 +13,38 @@ namespace Mall.Common
public class ConvertHelper public class ConvertHelper
{ {
/// <summary>
/// json字符串将属性值中的英文双引号变成中文双引号
/// </summary>
/// <param name="strJson">json字符串</param>
/// <returns></returns>
public static string JsonReplaceSign(string strJson)
{
char[] temp = strJson.ToCharArray();
int n = temp.Length;
for (int i = 0; i < n; i++)
{
if (temp[i] == ':' && temp[i + 1] == '"')
{
for (int j = i + 2; j < n; j++)
{
if (temp[j] == '"')
{
if (temp[j + 1] != ',' && temp[j + 1] != '}')
{
temp[j] = '”';
}
else if (temp[j + 1] == ',' || temp[j + 1] == '}')
{
break;
}
}
}
}
}
return new String(temp);
}
/// <summary> /// <summary>
/// 转换字符流成字符串 /// 转换字符流成字符串
/// </summary> /// </summary>
...@@ -45,7 +77,7 @@ namespace Mall.Common ...@@ -45,7 +77,7 @@ namespace Mall.Common
return data; return data;
} }
/// <summary> /// <summary>
/// 类型转换 /// 类型转换
/// </summary> /// </summary>
...@@ -103,7 +135,7 @@ namespace Mall.Common ...@@ -103,7 +135,7 @@ namespace Mall.Common
/// <param name="obj"></param> /// <param name="obj"></param>
/// <param name="defaultValue">默认值</param> /// <param name="defaultValue">默认值</param>
/// <returns></returns> /// <returns></returns>
public static int ToInt(object obj,int defaultValue=0) public static int ToInt(object obj, int defaultValue = 0)
{ {
int result = defaultValue; int result = defaultValue;
if (obj != null) if (obj != null)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Mall.Common\Mall.Common.csproj" />
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" /> <ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
<ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" /> <ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" />
</ItemGroup> </ItemGroup>
......
...@@ -55,7 +55,7 @@ namespace Mall.Module.MarketingCenter ...@@ -55,7 +55,7 @@ namespace Mall.Module.MarketingCenter
{ {
if (item.TemplateData != null && !string.IsNullOrEmpty(item.TemplateData)) if (item.TemplateData != null && !string.IsNullOrEmpty(item.TemplateData))
{ {
item.ComponentDataList = JsonHelper.DeserializeObject<List<ComponentItem>>(item.TemplateData); item.ComponentDataList = JsonHelper.DeserializeObject<List<ComponentItem>>(Mall.Common.ConvertHelper.JsonReplaceSign(item.TemplateData));
if (item.ComponentDataList != null && item.ComponentDataList.Count > 0) if (item.ComponentDataList != null && item.ComponentDataList.Count > 0)
{ {
foreach (var subItem in item.ComponentDataList) foreach (var subItem in item.ComponentDataList)
......
...@@ -216,18 +216,18 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -216,18 +216,18 @@ namespace Mall.WebApi.Controllers.MallBase
QIds = templateIds QIds = templateIds
}, IsAnalyzePlus: true); }, IsAnalyzePlus: true);
//解析模板 //解析模板
foreach (var item in templateList) foreach (var item in selfHomePage.DetailsList)
{ {
var detailsModel = selfHomePage?.DetailsList?.Where(qitem => qitem.TemplateId == item.Id)?.FirstOrDefault();
var templateData = new var templateData = new
{ {
id = detailsModel?.Id ?? 0, id = item?.Id ?? 0,
name = detailsModel?.NavName ?? "", name = item?.NavName ?? "",
data = new List<object>() data = new List<object>()
}; };
if (item.ComponentDataList != null && item.ComponentDataList.Count() > 0) var templateModel = templateList?.Where(qitem => qitem.Id == item.TemplateId)?.FirstOrDefault();
if (templateModel!=null && templateModel.ComponentDataList != null && templateModel.ComponentDataList.Count() > 0)
{ {
foreach (var subItem in item.ComponentDataList) foreach (var subItem in templateModel.ComponentDataList)
{ {
templateData.data.Add(PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId)); templateData.data.Add(PlusDataToObject(subItem, (miniProgram?.TenantId ?? 0), miniProgram.MallBaseId));
} }
...@@ -235,7 +235,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -235,7 +235,7 @@ namespace Mall.WebApi.Controllers.MallBase
var tempObj = new var tempObj = new
{ {
id = item.Id, id = item.Id,
name = item.TemplateName, name = item.NavName,
page_id = 0, page_id = 0,
template_id = item.Id, template_id = item.Id,
template = templateData template = templateData
......
...@@ -872,9 +872,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -872,9 +872,7 @@ namespace Mall.WebApi.Controllers.User
superList.Add(firstItem); superList.Add(firstItem);
} }
} }
} }
} }
if (item.MenuLevel == 2) if (item.MenuLevel == 2)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment