百度360必应搜狗淘宝本站头条
当前位置:网站首页 > IT知识 > 正文

ASP.NET MVC+Bootstrap个人博客之文章打赏(六)

liuian 2024-12-30 05:16 71 浏览

看到新浪微博、百度百家等等平台上都带有文章“打赏”功能,觉得很新鲜,于是也想在自己的博客中加入“打赏”功能。

当然,加入打赏功能并非是真的想要让别人打赏。因为只有那些真正能引起共鸣,发人深思,让人受益匪浅的文章才值得打赏,值得点赞。

而我的博客站仅仅是用作记录笔记,当做自己的知识库(如果能不经意间帮助别人那是再好不过了)。

加入打赏功能纯粹是“觉得好玩”,就是这么简单,Just have a fun!(博主喜欢折腾,看见一个酷炫的功能就想去实现它)

先看一下这个打赏的Icon长什么样吧! 去站点试试打赏?=>www.zynblog.com

点击“打赏Icon”后会弹出一个二维码界面,各位老板可以选择使用是使用支付宝打赏还是微信打赏:

具体代码如下:(时间仓促,并为将其扩展为插件)

HTML:

        <!--打赏按钮-->
        <div style="margin-bottom:20px;">
         <a title="打赏,支持一下" class="dashang" onclick="dashangToggle" href="javascript:void(0)">

         </a>
        </div>

打赏遮罩层HTML:

<div class="content">
    <div class="hide_box"><!--遮罩--></div>
    <div class="shang_box">
        <a class="shang_close" href="javascript:void(0)" onclick="dashangToggle" title="关闭">
 <img src="/Content/dashangimg/close.jpg" alt="取消">
        </a>
        <div class="shang_tit">
 <p>感谢您的支持,我会继续努力的!</p>
        </div>

        <div class="shang_payimg">
 <img src="/Content/dashangimg/alipayimg.jpg" alt="扫码支持" title="扫一扫">
        </div>
        <div class="pay_explain">扫码打赏,你说多少就多少</div>

        <div class="shang_payselect">
 <div class="pay_item checked" data-id="alipay">
 <span class="radiobox"></span>
 <span class="pay_logo">
 <img src="/Content/dashangimg/alipay.jpg" alt="支付宝">
 </span>
 </div>
 <div class="pay_item" data-id="weixinpay">
 <span class="radiobox"></span>
 <span class="pay_logo">
 <img src="/Content/dashangimg/wechat.jpg" alt="微信">
 </span>
 </div>
        </div>

        <div class="shang_info">
 <p>打开<span id="shang_pay_txt">支付宝</span>扫一扫,即可进行扫码打赏哦</p>
        </div>
    </div>
</div>

主要的JS:

 //打赏
jQuery(".pay_item").click(function {
jQuery(this).addClass('checked').siblings('.pay_item').removeClass('checked');
var dataid = jQuery(this).attr('data-id');
jQuery(".shang_payimg img").attr("src", "/Content/dashangimg/" + dataid + "img.jpg");
jQuery("#shang_pay_txt").text(dataid == "alipay" ? "支付宝" : "微信");
});
function dashangToggle {
jQuery(".hide_box").fadeToggle;
jQuery(".shang_box").fadeToggle;
};

顺带提供CSS:

  1 .hide_box {
  2     z-index: 999;
  3     filter: alpha(opacity=50);
  4     background: #666;
  5     opacity: 0.5;
  6     -moz-opacity: 0.5;
  7     left: 0;
  8     top: 0;
  9     height: 99%;
 10     width: 100%;
 11     position: fixed;
 12     display: none;
 13 }
 14 
 15 .shang_box {
 16     width: 540px;
 17     height: 540px;
 18     padding: 10px;
 19     background-color: #fff;
 20     border-radius: 10px;
 21     position: fixed;
 22     z-index: 1000;
 23     left: 50%;
 24     top: 50%;
 25     margin-left: -280px;
 26     margin-top: -280px;
 27     border: 1px dotted #dedede;
 28     display: none;
 29 }
 30 
 31     .shang_box img {
 32         border: none;
 33         border-width: 0;
 34     }
 35 
 36 .dashang {
 37     display: block;
 38     margin: 5px auto;
 39     text-align: center;
 40     transition: all 0.3s;
 41     width:50px;
 42     height:50px;
 43      background: url(../dashangimg/dashang.png) no-repeat scroll 0% 0% transparent;
 44 }
 45 
 46 .dashang:hover {
 47         background: url(../dashangimg/dashanghover.png) no-repeat scroll 0% 0% transparent;
 48     }
 49 
 50 .shang_close {
 51     float: right;
 52     display: inline-block;
 53 }
 54 
 55 .shang_logo {
 56     display: block;
 57     text-align: center;
 58     margin: 20px auto;
 59 }
 60 
 61 .shang_tit {
 62     width: 100%;
 63     height: 75px;
 64     text-align: center;
 65     line-height: 66px;
 66     color: #a3a3a3;
 67     font-size: 16px;
 68     background: url('../dashangimg/cy-reward-title-bg.jpg');
 69     font-family: 'Microsoft YaHei';
 70     margin-top: 7px;
 71     margin-right: 2px;
 72 }
 73 
 74     .shang_tit p {
 75         color: #a3a3a3;
 76         text-align: center;
 77         font-size: 16px;
 78     }
 79 
 80 .shang_payimg {
 81     width: 150px;
 82     height: 150px;
 83     border: 6px solid #EA5F00;
 84     margin: 0 auto;
 85     border-radius: 3px;
 86 }
 87 
 88     .shang_payimg img {
 89         display: block;
 90         text-align: center;
 91         width: 140px;
 92         height: 140px;
 93     }
 94 
 95 .pay_explain {
 96     text-align: center;
 97     margin: 10px auto;
 98     font-size: 12px;
 99     color: #545454;
100 }
101 
102 .radiobox {
103     width: 16px;
104     height: 16px;
105     background: url('../dashangimg/radio2.jpg');
106     display: block;
107     float: left;
108     margin-top: 5px;
109     margin-right: 14px;
110 }
111 
112 .checked .radiobox {
113     background: url('../dashangimg/radio1.jpg');
114 }
115 
116 .shang_payselect {
117     text-align: center;
118     margin: 0 auto;
119     margin-top: 40px;
120     cursor: pointer;
121     height: 60px;
122     width: 280px;
123 }
124 
125     .shang_payselect .pay_item {
126         display: inline-block;
127         margin-right: 10px;
128         float: left;
129     }
130 
131 .shang_info {
132     clear: both;
133 }
134 
135     .shang_info p, .shang_info a {
136         color: #C3C3C3;
137         text-align: center;
138         font-size: 12px;
139         text-decoration: none;
140         line-height: 2em;
141     }

打赏样式

相关推荐

怎么返回原来的系统(华为手机怎么退出鸿蒙系统)

1,首先,打开Windows7系统,在“计算机”的右键菜单中选择【控制面板】,点击进入。2,在【控制面板】中点击【备份和还原】。3,在窗口中选择【恢复系统或计算机】。4,在窗口中选择【打开系统还原】。...

126邮箱登录入口手机登陆(126邮箱登录登录)
126邮箱登录入口手机登陆(126邮箱登录登录)

126邮箱登录入口手机版:打开网址输入www.126.com.126邮箱是网易的一个免费邮箱登录入口在浏览器输入:mail.126.com浏览器进入126邮箱网站之后,即可自行登录126邮箱账号。126邮箱是网易的一个免费邮箱登录入口在浏...

2025-12-20 03:55 liuian

win10打印机无法共享(win10打印机不能共享的原因)

Win10打印机无法共享的解决办法:1、按下“Win+x”组合键或在开始菜单单击右键,在打开的菜单中点击“控制面板”;2、将查看方式修改为“大图标”,点击“设备和打印机”;3、在共享的打印机上单击右键...

电脑总是弹出usb无法识别(电脑总是弹出usb无法识别网络)
  • 电脑总是弹出usb无法识别(电脑总是弹出usb无法识别网络)
  • 电脑总是弹出usb无法识别(电脑总是弹出usb无法识别网络)
  • 电脑总是弹出usb无法识别(电脑总是弹出usb无法识别网络)
  • 电脑总是弹出usb无法识别(电脑总是弹出usb无法识别网络)
进入三星官网(三星官网首页登录界面)

找一找我自己的输入密码,就可以登录官网去了。三星云端的官网登录入口为https://support.samsungcloud.com/登陆三星帐户后可查看三星云使用情况及三星云中的照片和文档等信息,选...

光速虚拟机怎么用(光速虚拟机怎么用流量使用)

部落冲突光速虚拟机是一款可以加速部落冲突游戏运行的工具。使用方法很简单,首先需要下载并安装光速虚拟机软件,然后打开软件并登录你的部落冲突账号。接下来,在光速虚拟机内部运行部落冲突游戏,就可以享受到游戏...

以太网无法连接到internet怎么解决
以太网无法连接到internet怎么解决

以太网不能连接到internet连接的原因,有可能是路由器的外网连接不通或者当前的主机无法获取有效IP地址导致的。这个时候需要具体问题具体分析,如果是前者的话,那么我们需要进入路由器中配置WAN上网条件。如果配置好了以后还是上不了网的话,那...

2025-12-20 01:05 liuian

cad注册表怎么彻底删除(cad2019注册表怎么彻底删除)

注:在操作注册表之前,请先备份注册表,以免操作失误造成系统故障,另外,本文中使用的操作方法适用于Windows操作系统。以下是详细的删除cad在注册表中的操作步骤:1.打开“运行”窗口,可以通过快...

内存不够用了怎么办(内存不够用了怎么办手机)

我们的手机在使用过程中,会产生各种各样的垃圾和缓存文件,这些东西占据了很大的内存空间,所以我们平时需要定期清理这些垃圾文件。安卓的手机基本都自带手机管家类型的APP,我们可以利用这类APP实现清理垃圾...

联想电脑怎么连接wifi(联想电脑怎么连接wifi步骤台式)
  • 联想电脑怎么连接wifi(联想电脑怎么连接wifi步骤台式)
  • 联想电脑怎么连接wifi(联想电脑怎么连接wifi步骤台式)
  • 联想电脑怎么连接wifi(联想电脑怎么连接wifi步骤台式)
  • 联想电脑怎么连接wifi(联想电脑怎么连接wifi步骤台式)
三星官方固件下载地址(三星官方固件下载网站)

请您参考:1.通过手机中“三星应用商店”或“Galaxy特色订制”搜索需要的软件并下载安装。2.通过手机浏览器搜索需要的软件下载安装(若是自带的浏览器,下载的安装包保存在我的文件-Download文件...

win10企业版和专业版有什么区别哪个好

就性能而言,Windows10企业版比专业版好。1.企业版的更新频率比专业版少,可以降低更新所需要的可用时间。2.如果你是企业,在管理、保护数据安全、部署和集中管理设备方面,企业版会比专业版更具优势...

51重装系统后怎么恢复原来的系统

方法/步骤分步阅读1/5在开始菜单中打开控制面板,打开控制面板之后,选择:备份和还原选项。2/5点击:打开系统还原,如果有账户控制则会有所提示,通过即可。3/5然后会开始还原文件和设置的向导,你只需要...

可能没有权限使用网络资源(可能没有权限使用网络资源 win10)

右击“我的电脑”→“属性”→“计算机名”,看该选项卡中有没有出现你的局域网工作组名称,如“workgroup”等。然后单击“网络ID”按钮,开始“网络标识向导”:单击“下一步”,选择“本机是商业网络...

怎么查看宽带账号和密码(怎么查宽带帐号和密码)
怎么查看宽带账号和密码(怎么查宽带帐号和密码)

宽带账号密码要记牢,重要的账号密码要记小本本上!下面我来具体讲讲获取方法。1.查看发票、合同、官方小卡片是否标明。以我们这个城市为例,发票上的用户号码就是宽带账号。047403100006就是宽带账号,密码是123456,密码错误就是身份证...

2025-12-19 21:05 liuian