Commit 69803be8 authored by 吴春's avatar 吴春

提交代码

parent 6e17e6c3
...@@ -37,15 +37,21 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -37,15 +37,21 @@ namespace Mall.WebApi.Controllers.AppletWeChat
}; };
//读取小程序的配置文件 //读取小程序的配置文件
string path = projectUrl + "/miniProject/common/vendor.js"; string path = projectUrl + "/miniProject/common/vendor.js";
string basePath = projectUrl + "/vendorbase.js";
string jsonpath = projectUrl + "/miniProject/project.config.json"; string jsonpath = projectUrl + "/miniProject/project.config.json";
string basePath = projectUrl + "/vendorbase.js";
string jsonbasePath = projectUrl + "/project.configbase.json"; string jsonbasePath = projectUrl + "/project.configbase.json";
var model = appletWeChatModule.GetTenantListModule(query).FirstOrDefault(); var model = appletWeChatModule.GetTenantListModule(query).FirstOrDefault();
if (System.IO.File.Exists(path) && System.IO.File.Exists(jsonpath)) if (System.IO.File.Exists(path) && System.IO.File.Exists(jsonpath))
{ {
try try
{ {
if (model.LivePlayerPlugin == 1)
{
path = projectUrl + "/miniProjectLive/common/vendor.js";
jsonpath = projectUrl + "/miniProjectLive/project.config.json";
}
string txtStr = System.IO.File.ReadAllText(basePath); string txtStr = System.IO.File.ReadAllText(basePath);
string newStr = txtStr.Replace("$MallBaseId$", query.MallBaseId.ToString()).Replace("$TenantId$", query.TenantId.ToString()).Replace("$MiniAppId$", model.MiniAppId); string newStr = txtStr.Replace("$MallBaseId$", query.MallBaseId.ToString()).Replace("$TenantId$", query.TenantId.ToString()).Replace("$MiniAppId$", model.MiniAppId);
System.IO.File.WriteAllText(path, newStr); System.IO.File.WriteAllText(path, newStr);
...@@ -115,9 +121,32 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -115,9 +121,32 @@ namespace Mall.WebApi.Controllers.AppletWeChat
[HttpPost] [HttpPost]
public ApiResult GetPreviewAppletWeChat() public ApiResult GetPreviewAppletWeChat()
{ {
var parms = RequestParm;
var query = new RB_MiniProgram_Extend
{
TenantId = UserInfo.TenantId,
MallBaseId = parms.MallBaseId
};
var model = appletWeChatModule.GetTenantListModule(query).FirstOrDefault();
if (model == null)
{
return ApiResult.Failed("您还未配置微信小程序基础信息");
}
try try
{ {
string URL = $"http://127.0.0.1:{developerKitsPort}/v2/preview?project={Mall.Common.Plugin.StringHelper.UrlEncode(projectUrl + "/miniProject")}&qr-format=base64"; string path = projectUrl + "/miniProject";
if (string.IsNullOrWhiteSpace(model.Version))
{
query.Version = "1.0.00";
}
if (model.LivePlayerPlugin == 1)
{
path = projectUrl + "/miniProjectLive";
}
string URL = $"http://127.0.0.1:{developerKitsPort}/v2/preview?project={Mall.Common.Plugin.StringHelper.UrlEncode(path)}&qr-format=base64";
// string URL = $"http://127.0.0.1:{developerKitsPort}/v2/preview?project={Mall.Common.Plugin.StringHelper.UrlEncode(projectUrl + "/miniProject")}&qr-format=base64";
string result = Mall.Common.Plugin.HttpHelper.HttpGet(URL, Encoding.UTF8, ""); string result = Mall.Common.Plugin.HttpHelper.HttpGet(URL, Encoding.UTF8, "");
if (result.Length > 200 && !result.Contains("data:image/png;base64,")) if (result.Length > 200 && !result.Contains("data:image/png;base64,"))
{ {
...@@ -162,16 +191,20 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -162,16 +191,20 @@ namespace Mall.WebApi.Controllers.AppletWeChat
try try
{ {
string path = projectUrl + "/miniProject";
if (string.IsNullOrWhiteSpace(model.Version)) if (string.IsNullOrWhiteSpace(model.Version))
{ {
query.Version = "1.0.00";//1111 query.Version = "1.0.00";//1111
} }
if (model.LivePlayerPlugin == 1)
{
path = projectUrl + "/miniProjectLive";
}
int version = Convert.ToInt32(model.Version.Replace(".", "")); int version = Convert.ToInt32(model.Version.Replace(".", ""));
version += 1; version += 1;
model.Version = version.ToString().Substring(0, version.ToString().Length - 3) + "." + version.ToString().Substring(version.ToString().Length - 3, 1) + "." + version.ToString().Substring(version.ToString().Length - 2, 2); model.Version = version.ToString().Substring(0, version.ToString().Length - 3) + "." + version.ToString().Substring(version.ToString().Length - 3, 1) + "." + version.ToString().Substring(version.ToString().Length - 2, 2);
string URL = $"http://127.0.0.1:{developerKitsPort}/v2/upload?project={Mall.Common.Plugin.StringHelper.UrlEncode(path)}&version=V{model.Version}&desc=微信开发者工具HTTP上传&appid={model.MiniAppId}";
string URL = $"http://127.0.0.1:{developerKitsPort}/v2/upload?project={Mall.Common.Plugin.StringHelper.UrlEncode(projectUrl + "/miniProject")}&version=V{model.Version}&desc=微信开发者工具HTTP上传&appid={model.MiniAppId}"; //string URL = $"http://127.0.0.1:{developerKitsPort}/v2/upload?project={Mall.Common.Plugin.StringHelper.UrlEncode(projectUrl + "/miniProject")}&version=V{model.Version}&desc=微信开发者工具HTTP上传&appid={model.MiniAppId}";
string result = Mall.Common.Plugin.HttpHelper.HttpGet(URL, Encoding.UTF8, ""); string result = Mall.Common.Plugin.HttpHelper.HttpGet(URL, Encoding.UTF8, "");
JObject parmsJob = JObject.Parse(result); JObject parmsJob = JObject.Parse(result);
if (parmsJob.ContainsKey("code")) if (parmsJob.ContainsKey("code"))
...@@ -576,8 +609,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -576,8 +609,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat
{ {
var parms = RequestParm; var parms = RequestParm;
var extModel = JsonConvert.DeserializeObject<RB_Live_HouseExtension_Extend>(RequestParm.msg.ToString()); var extModel = JsonConvert.DeserializeObject<RB_Live_HouseExtension_Extend>(RequestParm.msg.ToString());
bool flag = appletWeChatModule.SetLiveQrCodeModule(extModel) ; bool flag = appletWeChatModule.SetLiveQrCodeModule(extModel);
return flag?ApiResult.Success():ApiResult.Failed(); return flag ? ApiResult.Success() : ApiResult.Failed();
} }
/// <summary> /// <summary>
......
...@@ -385,6 +385,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -385,6 +385,7 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
id = miniProgram.MallBaseId, id = miniProgram.MallBaseId,
name = miniProgram.MallName, name = miniProgram.MallName,
livePlayerPlugin = miniProgram.LivePlayerPlugin,
user_id = 0, user_id = 0,
created_at = miniProgram.CreateDate.HasValue ? miniProgram.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", created_at = miniProgram.CreateDate.HasValue ? miniProgram.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
updated_at = miniProgram.CreateDate.HasValue ? miniProgram.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", updated_at = miniProgram.CreateDate.HasValue ? miniProgram.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
......
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