Skip to content

Commit 474f817

Browse files
committed
添加短网址显示二维码功能
1 parent 67bc0dc commit 474f817

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/views/index.php

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<input type="button" id="expand" value="还原短址" class="am-btn am-btn-default am-btn-sm am-fr">
5252
</div>
5353
</form>
54+
<div id="qrcode" class="am-hide am-center am-img-thumbnail am-img-responsive" style="width: 206px;height: 206px"></div>
5455
<hr>
5556
<p>© <?= date('Y') ?> <a href="https://github.com/takashiki/ourls" target="_blank">Ourls</a> . Licensed under MIT license.</p>
5657
</div>
@@ -66,6 +67,7 @@
6667
<![endif]-->
6768
<script src="//cdn.bootcss.com/amazeui/2.5.2/js/amazeui.min.js"></script>
6869
<script src="//cdn.bootcss.com/validator/4.0.5/validator.min.js"></script>
70+
<script src="//cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
6971
<script src="js/index.js"></script>
7072
<?php if (!empty(Flight::get('flight.settings')['external_js'])): ?>
7173
<script src="<?= Flight::get('flight.settings')['external_js'] ?>"></script>

public/js/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ $('#shorten').click(function() {
77
function (data) {
88
if (data.status == 1) {
99
$('#url').val(data.s_url);
10+
var qrcode = $('#qrcode');
11+
qrcode.qrcode({
12+
width: 200,
13+
height: 200,
14+
text: "data.s_url"
15+
});
16+
qrcode.removeClass('am-hide');
1017
} else {
1118
alert(data.msg);
1219
}
@@ -24,6 +31,9 @@ $('#expand').click(function() {
2431
function(data) {
2532
if (data.status == 1) {
2633
$('#url').val(data.url);
34+
var qrcode = $('#qrcode');
35+
qrcode.addClass('am-hide');
36+
qrcode.html('');
2737
} else {
2838
alert(data.msg);
2939
}

0 commit comments

Comments
 (0)