当前位置:网站首页>【博主推荐】C#生成好看的二维码(附源码)
【博主推荐】C#生成好看的二维码(附源码)
2022-07-06 09:13:00 【xcLeigh】
【博主推荐】C#生成好看的二维码(附源码)
- 实现功能
1.实现二维码生成
2.实现二维码样式修改
3.实现条件下,批量生成
4.实现样式,地址等参数可配置
1.效果展示
1.1 界面效果
1.2 生成后界面效果
1.1 界面配置后生成的二维码
2.二维码页面设计
<div style="background-color:white;width:100%; text-align:center;">
<div class="layui-field-box" style="background-color:orange;">
<div>
<table style="width:100%;">
<tr>
<td style="color:black;">
xcLeigh - 二维码生成
</td>
<td style="text-align:right;font-size:13px;color:white;">
<a href="https://download.csdn.net/user/weixin_43151418/?spm=1003.2020.3001.5449">【博主推荐】相关资源</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85329413?spm=1003.2166.3001.6637.6">C#MVC后台管理系统(附源码)</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85337361?spm=1003.2166.3001.6637.1">html下拉框树形(附好看的登录界面)</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85335759">HTML5响应式手机微网站(附源码)</a> |
<a href="https://download.csdn.net/download/weixin_43151418/85336631">html操作SVG图(附源码)</a>
</td>
</tr>
</table>
</div>
</div>
<hr style="margin:0px;padding:0px;margin-bottom:5px;" />
@*<div style="text-align:center; padding:15px;color:red;">
<span id="tomessage">转换成功,位置在D:\\</span>
</div>*@
<div class="layui-upload-drag" id="zjImg" style="margin-bottom:5px;">
<img id="ewmImg" name="ewmImg" src="~/Content/xcsharp/images/lo.png" style="width:80px;height:80px;" />
<div style="padding:2px;"></div>
<p style="color:crimson;">二维码Logo</p>
</div>
<input id="ewmImgt" name="ewmImgt" hidden="hidden" type="text" value="Content\\xcsharp\\images\\lo.png">
<div class="layui-upload-drag" id="scImg" style="margin-bottom:5px;display:none;">
<img class="img1" src="@ViewBag.ImgScEwm" style="width:150px;height:150px;" />
<div style="padding:2px;"></div>
<p style="color:crimson;">生成成功</p>
<p style="color:crimson;">右键图片另存为,保存二维码</p>
</div>
<div style="text-align:left; margin:10px;">
<input id="ewmAddr" name="ewmAddr" class="layui-input" type="text" placeholder="二维码定义:可以是地址,可以是特定字符" autocomplete="off" lay-verify="required" lay-reqtext="二维码定义是必填项,岂能为空?">
</div>
<div style="text-align:left; margin:10px;">
<input id="ewmWz" name="ewmWz" class="layui-input" type="text" placeholder="底部文字可加可不加,最长8个字符" maxlength="8" autocomplete="off">
</div>
<div style="text-align:left; margin:10px;">
<table>
<tr>
<td>背景色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#ffffff" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmBgColor" name="ewmBgColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmBgColor_d"></div>
</div>
</div>
</div>
</td>
<td>二维码颜色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#1EABFC" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmColor" name="ewmColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmColor_d"></div>
</div>
</div>
</div>
</td>
<td>文字颜色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#1EABFC" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmFontColor" name="ewmFontColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmFontColor_d"></div>
</div>
</div>
</div>
</td>
<td>文字字体:</td>
<td>
<select name="ewmWzFont" lay-filter="aihao">
<option value="黑体" selected="">黑体</option>
<option value="宋体">宋体</option>
<option value="仿宋">仿宋</option>
</select>
</td>
<td style="padding-left:20px;">四个角颜色:</td>
<td>
<div style="margin-top:18px;">
<div class="layui-form-item">
<div class="layui-input-inline" style="width: 120px;">
<input type="text" value="#1EABFC" placeholder="背景颜色" readonly="readonly" class="layui-input" id="ewmSgjColor" name="ewmSgjColor">
</div>
<div class="layui-inline" style="left: -11px;">
<div id="ewmSgjColor_d"></div>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
<div style="text-align:left; margin:10px;">
<table>
<tr>
<td>是否显示四个角:</td>
<td>
<input name="ewmSgj" type="checkbox" checked="" lay-skin="switch" lay-filter="switchTest" lay-text="显示|隐藏">
</td>
<td></td>
</tr>
</table>
</div>
<div style="text-align:left; margin:10px;">
<button class="layui-btn" data-type="parseTable" type="submit" lay-filter="demo1" lay-submit="">生成二维码</button>
</div>
@*<div class="layui-upload-drag" id="wordtopdf" style="margin-bottom:5px;">
<i class="layui-icon"></i>
<p style="color:crimson;">WORD转PDF(doc格式)</p>
<p>点击上传,或将文件拖拽到此处</p>
</div>*@
</div>
3.二维码生成的后台操作
public ActionResult EwmImg() {
try
{
var file = Request.Files[0]; //获取选中文件
var filecombin = file.FileName.Split('.');
//文件名字
string filename = Path.GetFileName(file.FileName);
if (file == null || filename.IndexOf("&") != -1 || String.IsNullOrEmpty(file.FileName) || file.ContentLength == 0 || filecombin.Length < 2)
{
return Json(new
{
fileid = 0,
src = "",
name = "",
msg = "上传出错 请检查文件名 或 图片格式是否符合"
});
}
//定义本地路径位置
string local = "upload\\ewm\\img\\";
string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, local);
if (!System.IO.Directory.Exists(localPath))
System.IO.Directory.CreateDirectory(localPath);
string newPath = localPath + filename;
file.SaveAs(newPath);
//保存图片
return Json(new
{
src = newPath.Trim().Replace("\\", "|"),
name = filename,
// 获取文件名不含后缀名
msg = "上传成功"
});
}
catch { }
return Json(new
{
src = "",
name = "", // 获取文件名不含后缀名
msg = "上传出错"
});
}
4.源码下载
边栏推荐
- Advantages and disadvantages of evaluation methods
- Global and Chinese markets for aprotic solvents 2022-2028: Research Report on technology, participants, trends, market size and share
- CSDN question and answer tag skill tree (I) -- Construction of basic framework
- MySQL26-性能分析工具的使用
- API learning of OpenGL (2001) gltexgen
- MySQL25-索引的创建与设计原则
- MySQL combat optimization expert 02 in order to execute SQL statements, do you know what kind of architectural design MySQL uses?
- API learning of OpenGL (2002) smooth flat of glsl
- 第一篇博客
- MySQL21-用戶與權限管理
猜你喜欢
Just remember Balabala
Adaptive Bezier curve network for real-time end-to-end text recognition
Mysql33 multi version concurrency control
Mysql24 index data structure
Introduction tutorial of typescript (dark horse programmer of station B)
Security design verification of API interface: ticket, signature, timestamp
CSDN blog summary (I) -- a simple first edition implementation
基于Pytorch的LSTM实战160万条评论情感分类
Case identification based on pytoch pulmonary infection (using RESNET network structure)
CSDN博文摘要(一) —— 一个简单的初版实现
随机推荐
MySQL21-用户与权限管理
MySQL 20 MySQL data directory
Not registered via @enableconfigurationproperties, marked (@configurationproperties use)
API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T
Timestamp with implicit default value is deprecated error in MySQL 5.6
MySQL28-数据库的设计规范
数据库中间件_Mycat总结
MySQL31-MySQL事务日志
Win10: how to modify the priority of dual network cards?
Kubesphere - deploy the actual combat with the deployment file (3)
MySQL35-主从复制
CSDN question and answer tag skill tree (II) -- effect optimization
Time complexity (see which sentence is executed the most times)
How to change php INI file supports PDO abstraction layer
CSDN博文摘要(一) —— 一个简单的初版实现
Ueeditor internationalization configuration, supporting Chinese and English switching
windows无法启动MYSQL服务(位于本地计算机)错误1067进程意外终止
CSDN question and answer tag skill tree (I) -- Construction of basic framework
导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
Solve the problem that XML, YML and properties file configurations cannot be scanned