mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 19:23:25 +08:00
【新增】后端代理商列表、分销商列表增加二维码功能。
This commit is contained in:
@@ -832,6 +832,176 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 后台生成代理商小程序码============================================================
|
||||||
|
|
||||||
|
// POST: Api/Tools/GetAgentWxCode
|
||||||
|
/// <summary>
|
||||||
|
/// 后台生成代理商小程序码
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("后台生成小程序码")]
|
||||||
|
public async Task<AdminUiCallBack> GetAgentWxCode([FromBody] FMIntId entity)
|
||||||
|
{
|
||||||
|
//返回数据
|
||||||
|
var jm = new AdminUiCallBack { code = 0 };
|
||||||
|
|
||||||
|
var filesStorageOptions = await _coreCmsSettingServices.GetFilesStorageOptions();
|
||||||
|
|
||||||
|
|
||||||
|
var userModel = await _userServices.QueryByIdAsync(entity.id);
|
||||||
|
if (userModel == null)
|
||||||
|
{
|
||||||
|
jm.code = 1;
|
||||||
|
jm.msg = "不存在此信息";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userCode = UserHelper.GetShareCodeByUserId(entity.id);
|
||||||
|
|
||||||
|
var path = "pages/share/jump/jump?scene=11-" + userCode + "-" + userCode;
|
||||||
|
|
||||||
|
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||||
|
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||||
|
var request = new CgibinWxaappCreateWxaQrcodeRequest();
|
||||||
|
request.AccessToken = accessToken;
|
||||||
|
request.Path = path;
|
||||||
|
|
||||||
|
var response = await client.ExecuteCgibinWxaappCreateWxaQrcodeAsync(request);
|
||||||
|
if (response.IsSuccessful())
|
||||||
|
{
|
||||||
|
var memStream = new MemoryStream(response.RawBytes);
|
||||||
|
|
||||||
|
string url = string.Empty;
|
||||||
|
if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.LocalStorage.ToString())
|
||||||
|
{
|
||||||
|
url = _toolsServices.UpLoadBase64ForLocalStorage(filesStorageOptions, memStream);
|
||||||
|
}
|
||||||
|
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.AliYunOSS.ToString())
|
||||||
|
{
|
||||||
|
//上传到阿里云
|
||||||
|
url = await _toolsServices.UpLoadBase64ForAliYunOSS(filesStorageOptions, memStream);
|
||||||
|
}
|
||||||
|
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QCloudOSS.ToString())
|
||||||
|
{
|
||||||
|
//上传到腾讯云OSS
|
||||||
|
url = _toolsServices.UpLoadBase64ForQCloudOSS(filesStorageOptions, response.RawBytes);
|
||||||
|
}
|
||||||
|
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QiNiuKoDo.ToString())
|
||||||
|
{
|
||||||
|
//上传到七牛云kodo
|
||||||
|
url = _toolsServices.UpLoadBase64ForQiNiuKoDo(filesStorageOptions, response.RawBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
var bl = !string.IsNullOrEmpty(url);
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? "上传成功!" : "上传失败";
|
||||||
|
jm.data = new
|
||||||
|
{
|
||||||
|
fileUrl = url,
|
||||||
|
src = url,
|
||||||
|
path
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jm.code = 1;
|
||||||
|
jm.msg = response.ErrorMessage;
|
||||||
|
}
|
||||||
|
jm.otherData = response;
|
||||||
|
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 后台生成分销商小程序码============================================================
|
||||||
|
|
||||||
|
// POST: Api/Tools/GetDistributionWxCode
|
||||||
|
/// <summary>
|
||||||
|
/// 后台生成分销商小程序码
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Description("后台生成小程序码")]
|
||||||
|
public async Task<AdminUiCallBack> GetDistributionWxCode([FromBody] FMIntId entity)
|
||||||
|
{
|
||||||
|
//返回数据
|
||||||
|
var jm = new AdminUiCallBack { code = 0 };
|
||||||
|
|
||||||
|
var filesStorageOptions = await _coreCmsSettingServices.GetFilesStorageOptions();
|
||||||
|
|
||||||
|
|
||||||
|
var userModel = await _userServices.QueryByIdAsync(entity.id);
|
||||||
|
if (userModel == null)
|
||||||
|
{
|
||||||
|
jm.code = 1;
|
||||||
|
jm.msg = "不存在此信息";
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userCode = UserHelper.GetShareCodeByUserId(entity.id);
|
||||||
|
|
||||||
|
var path = "pages/share/jump/jump?scene=4-" + userCode + "-" + userCode;
|
||||||
|
|
||||||
|
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||||
|
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||||
|
var request = new CgibinWxaappCreateWxaQrcodeRequest();
|
||||||
|
request.AccessToken = accessToken;
|
||||||
|
request.Path = path;
|
||||||
|
|
||||||
|
var response = await client.ExecuteCgibinWxaappCreateWxaQrcodeAsync(request);
|
||||||
|
if (response.IsSuccessful())
|
||||||
|
{
|
||||||
|
var memStream = new MemoryStream(response.RawBytes);
|
||||||
|
|
||||||
|
string url = string.Empty;
|
||||||
|
if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.LocalStorage.ToString())
|
||||||
|
{
|
||||||
|
url = _toolsServices.UpLoadBase64ForLocalStorage(filesStorageOptions, memStream);
|
||||||
|
}
|
||||||
|
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.AliYunOSS.ToString())
|
||||||
|
{
|
||||||
|
//上传到阿里云
|
||||||
|
url = await _toolsServices.UpLoadBase64ForAliYunOSS(filesStorageOptions, memStream);
|
||||||
|
}
|
||||||
|
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QCloudOSS.ToString())
|
||||||
|
{
|
||||||
|
//上传到腾讯云OSS
|
||||||
|
url = _toolsServices.UpLoadBase64ForQCloudOSS(filesStorageOptions, response.RawBytes);
|
||||||
|
}
|
||||||
|
else if (filesStorageOptions.StorageType == GlobalEnumVars.FilesStorageOptionsType.QiNiuKoDo.ToString())
|
||||||
|
{
|
||||||
|
//上传到七牛云kodo
|
||||||
|
url = _toolsServices.UpLoadBase64ForQiNiuKoDo(filesStorageOptions, response.RawBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
var bl = !string.IsNullOrEmpty(url);
|
||||||
|
jm.code = bl ? 0 : 1;
|
||||||
|
jm.msg = bl ? "上传成功!" : "上传失败";
|
||||||
|
jm.data = new
|
||||||
|
{
|
||||||
|
fileUrl = url,
|
||||||
|
src = url
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jm.code = 1;
|
||||||
|
jm.msg = response.ErrorMessage;
|
||||||
|
}
|
||||||
|
jm.otherData = response;
|
||||||
|
|
||||||
|
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
//通用页面获取=========================================================================
|
//通用页面获取=========================================================================
|
||||||
|
|
||||||
#region 获取商品列表====================================================
|
#region 获取商品列表====================================================
|
||||||
|
|||||||
@@ -763,6 +763,18 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:CoreCms.Net.Web.Admin.Controllers.ToolsController.GetAgentWxCode(CoreCms.Net.Model.FromBody.FMIntId)">
|
||||||
|
<summary>
|
||||||
|
后台生成代理商小程序码
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:CoreCms.Net.Web.Admin.Controllers.ToolsController.GetDistributionWxCode(CoreCms.Net.Model.FromBody.FMIntId)">
|
||||||
|
<summary>
|
||||||
|
后台生成分销商小程序码
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.ToolsController.GetGoods">
|
<member name="M:CoreCms.Net.Web.Admin.Controllers.ToolsController.GetGoods">
|
||||||
<summary>
|
<summary>
|
||||||
获取商品列表
|
获取商品列表
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="LAY-app-CoreCmsAgent-tableBox-bar">
|
<script type="text/html" id="LAY-app-CoreCmsAgent-tableBox-bar">
|
||||||
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="qrcode">小程序码</a>
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
||||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs" data-dropdown="#CoreCmsAgentTbDelDrop{{d.LAY_NUM}}" no-shade="true">删除</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs" data-dropdown="#CoreCmsAgentTbDelDrop{{d.LAY_NUM}}" no-shade="true">删除</a>
|
||||||
@@ -189,7 +190,7 @@
|
|||||||
{ field: 'updateTime', title: '更新时间', width: 130, sort: false },
|
{ field: 'updateTime', title: '更新时间', width: 130, sort: false },
|
||||||
{ field: 'verifyTime', title: '审核时间', width: 130, sort: false },
|
{ field: 'verifyTime', title: '审核时间', width: 130, sort: false },
|
||||||
//{ field: 'isDelete', title: '是否删除', width: 95, templet: '#switch_isDelete', sort: false, unresize: true },
|
//{ field: 'isDelete', title: '是否删除', width: 95, templet: '#switch_isDelete', sort: false, unresize: true },
|
||||||
{ width: 142, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsAgent-tableBox-bar' }
|
{ width: 222, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsAgent-tableBox-bar' }
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -226,6 +227,8 @@
|
|||||||
doDelete(obj);
|
doDelete(obj);
|
||||||
} else if (obj.event === 'edit') {
|
} else if (obj.event === 'edit') {
|
||||||
doEdit(obj)
|
doEdit(obj)
|
||||||
|
} else if (obj.event === 'qrcode') {
|
||||||
|
doQrCode(obj)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//执行创建操作
|
//执行创建操作
|
||||||
@@ -342,6 +345,28 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取小程序码
|
||||||
|
function doQrCode(obj) {
|
||||||
|
coreHelper.Post("Api/Tools/GetAgentWxCode", { id: obj.data.userId }, function (e) {
|
||||||
|
if (e.code === 0) {
|
||||||
|
admin.popup({
|
||||||
|
shadeClose: false,
|
||||||
|
title: '查看小程序码',
|
||||||
|
area: ['380px', '480px'],
|
||||||
|
id: 'LAY-popup-CoreCmsAgent-QrCode',
|
||||||
|
success: function (layero, index) {
|
||||||
|
view(this.id).render('agent/agents/qrCode', { data: e.data }).done(function () {
|
||||||
|
form.render();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//执行单个删除
|
//执行单个删除
|
||||||
function doDelete(obj) {
|
function doDelete(obj) {
|
||||||
//console.log(obj.data.id);
|
//console.log(obj.data.id);
|
||||||
|
|||||||
25
CoreCms.Net.Web.Admin/wwwroot/views/agent/agents/qrCode.html
Normal file
25
CoreCms.Net.Web.Admin/wwwroot/views/agent/agents/qrCode.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<script type="text/html" template lay-done="layui.data.done(d);">
|
||||||
|
<div style="text-align: center" lay-filter="LAY-app-CoreCmsAgent-QrCode" id="LAY-app-CoreCmsAgent-QrCode">
|
||||||
|
<img id="cavasimg" src="{{d.params.data.fileUrl}}" width="300" height="341" style="border: 1px solid #c0c0c0" />
|
||||||
|
<div style="width: 100%;text-align:center;margin-top: 20px;">
|
||||||
|
<a class="layui-btn" href="{{d.params.data.fileUrl}}" target="_blank">下载二维码</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
var debug = layui.setter.debug;
|
||||||
|
layui.data.done = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d.params.data); }
|
||||||
|
|
||||||
|
layui.use(['admin', 'form', 'coreHelper'], function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, setter = layui.setter
|
||||||
|
, admin = layui.admin
|
||||||
|
, coreHelper = layui.coreHelper
|
||||||
|
, form = layui.form;
|
||||||
|
form.render(null, 'LAY-app-CoreCmsAgent-detailsForm');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -103,6 +103,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<script type="text/html" id="LAY-app-CoreCmsDistribution-tableBox-bar">
|
<script type="text/html" id="LAY-app-CoreCmsDistribution-tableBox-bar">
|
||||||
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="qrcode">小程序码</a>
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
||||||
<a class="layui-btn layui-btn-xs" lay-event="edit">审核</a>
|
<a class="layui-btn layui-btn-xs" lay-event="edit">审核</a>
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs" data-dropdown="#CoreCmsDistributionTbDelDrop{{d.LAY_NUM}}" no-shade="true">删除</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs" data-dropdown="#CoreCmsDistributionTbDelDrop{{d.LAY_NUM}}" no-shade="true">删除</a>
|
||||||
@@ -219,7 +220,7 @@
|
|||||||
{ field: 'updateTime', title: '更新时间', width: 130, sort: false },
|
{ field: 'updateTime', title: '更新时间', width: 130, sort: false },
|
||||||
{ field: 'verifyTime', title: '审核时间', width: 130, sort: false },
|
{ field: 'verifyTime', title: '审核时间', width: 130, sort: false },
|
||||||
//{ field: 'isDelete', title: '是否删除', width: 95, templet: '#switch_isDelete', sort: false, unresize: true },
|
//{ field: 'isDelete', title: '是否删除', width: 95, templet: '#switch_isDelete', sort: false, unresize: true },
|
||||||
{ width: 142, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsDistribution-tableBox-bar' }
|
{ width: 222, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsDistribution-tableBox-bar' }
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -256,6 +257,8 @@
|
|||||||
doDelete(obj);
|
doDelete(obj);
|
||||||
} else if (obj.event === 'edit') {
|
} else if (obj.event === 'edit') {
|
||||||
doEdit(obj)
|
doEdit(obj)
|
||||||
|
} else if (obj.event === 'qrcode') {
|
||||||
|
doQrCode(obj)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//执行创建操作
|
//执行创建操作
|
||||||
@@ -372,6 +375,28 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取小程序码
|
||||||
|
function doQrCode(obj) {
|
||||||
|
coreHelper.Post("Api/Tools/GetDistributionWxCode", { id: obj.data.userId }, function (e) {
|
||||||
|
if (e.code === 0) {
|
||||||
|
admin.popup({
|
||||||
|
shadeClose: false,
|
||||||
|
title: '查看小程序码',
|
||||||
|
area: ['380px', '480px'],
|
||||||
|
id: 'LAY-popup-CoreCmsDistributor-QrCode',
|
||||||
|
success: function (layero, index) {
|
||||||
|
view(this.id).render('distribution/distributor/qrCode', { data: e.data }).done(function () {
|
||||||
|
form.render();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//执行单个删除
|
//执行单个删除
|
||||||
function doDelete(obj) {
|
function doDelete(obj) {
|
||||||
//console.log(obj.data.id);
|
//console.log(obj.data.id);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<script type="text/html" template lay-done="layui.data.done(d);">
|
||||||
|
<div style="text-align: center" lay-filter="LAY-app-CoreCmsDistributor-QrCode" id="LAY-app-CoreCmsDistributor-QrCode">
|
||||||
|
<img id="cavasimg" src="{{d.params.data.fileUrl}}" width="300" height="341" style="border: 1px solid #c0c0c0" />
|
||||||
|
<div style="width: 100%;text-align:center;margin-top: 20px;">
|
||||||
|
<a class="layui-btn" href="{{d.params.data.fileUrl}}" target="_blank">下载二维码</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
var debug = layui.setter.debug;
|
||||||
|
layui.data.done = function (d) {
|
||||||
|
//开启调试情况下获取接口赋值数据
|
||||||
|
if (debug) { console.log(d.params.data); }
|
||||||
|
|
||||||
|
layui.use(['admin', 'form', 'coreHelper'], function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, setter = layui.setter
|
||||||
|
, admin = layui.admin
|
||||||
|
, coreHelper = layui.coreHelper
|
||||||
|
, form = layui.form;
|
||||||
|
form.render(null, 'LAY-app-CoreCmsDistributor-detailsForm');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user