QRcode.page.js
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var $ = require('yoho-jquery');
var Slide = require('../plugins/yohoui/YH.slide');
var $item = $('li', '.qrctxt');
var len = $item.length, slide;
require('../common');
// var src=/url\("([^'"]*)"\)/g.exec($(".print_qrcode").css("background"))[1];
// $(".print_qrcode").find("img").attr("src",src);
function slideDo(to) {
$item.each(function(index) {
index === to ? $(this).stop().animate({
opacity: 1,
zIndex: 1
}, 400) : $(this).stop().animate({
opacity: 0,
zIndex: 0
}, 400);
to === 0 ? $('.prev').addClass('gray') : $('.prev').removeClass('gray');
to === len - 1 ? $('.next').addClass('gray') : $('.next').removeClass('gray');
$('#qrid').html($item.eq(to).find('.bianhao').find('i').html());
});
}
slideDo(0);
slide = new Slide({
length: len,
loop: false,
auto: false,
timeout: 2,
index: 0
});
slide.on('change', function(data) {
slideDo(data.to);
});
$('.prev', '.qrcmain-switch').click(function() {
slide.prev();
});
$('.next', '.qrcmain-switch').click(function() {
slide.next();
});
$('.btn-qcode').click(function() {
var html = ['<ul>'];
$('.center', '.qrctxt').each(function() {
html.push('<li>');
var src = $(this).find('img').attr('src');
html.push('<img src=\'' + src + '\'/>');
var bianhao = $(this).find('.bianhao').text();
html.push('<p>' + bianhao + '</p>');
var zuoweihao = $(this).find('.zuoweihao').text();
if (zuoweihao) {
html.push('<p>' + zuoweihao + '</p>');
}
html.push('</li>');
});
html.push('</ul>');
$('.print_content').html(html.join(''));
document.body.innerHTML = $('#print_wrap').show().html();
setTimeout(function(argument) {
window.print();
}, 1000);
return false;
});