chengkun
2025-05-12 b6bc92ec11e1e280185ce7682d17589cb45c20f3
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<link rel="stylesheet" href="{yun:}$wap_style{/yun}/hb/reset.css?v={yun:}$config.cachecode{/yun}" type="text/css"/>
<section class='zhongxin'>
    <div>
        <ul class="poster-list-a pdb10 overflow ">
            {yun:}foreach from=$gzHb item=v{/yun}
            <li class="">
                <div class="hb_listbox">
                    <div class="poster_pic"><img src="{yun:}$v.pic_n{/yun}"></div>
                    <div class="hb_listbox_name" style="background:#fff;">
                        <div class="hb_cz">
                            <a href="javascript:;" onclick="showHbDiv('{yun:}$v.id{/yun}')">预览</a>
                            <a href="javascript:;" onclick="downWhb('{yun:}$v.id{/yun}');">下载</a>
                        </div>
                    </div>
                </div>
            </li>
            {yun:}/foreach{/yun}
        </ul>
    </div>
</section>
 
<div style="display: none;" id="imgDiv">
    <img id="showImg" class="important" />
</div>
 
<script type="text/javascript" src="{yun:}$config.sy_weburl{/yun}/js/jquery-1.8.1.min.js?v={yun:}$config.cachecode{/yun}"></script>
<link href="{yun:}$config.sy_weburl{/yun}/js/layui/css/layui.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css"/>
<script src="{yun:}$config.sy_weburl{/yun}/js/layui/layui.js?v={yun:}$config.cachecode{/yun}"></script>
<script src="{yun:}$config.sy_weburl{/yun}/js/layui/custom_layer.js?v={yun:}$config.cachecode{/yun}"></script>
 
<script>
 
    const weburl = '{yun:}$config.sy_weburl{/yun}';
    const id = '{yun:}$gzid{/yun}';
    
    function showHbDiv(hb) {
        
        const url = weburl+'/index.php?m=ajax&c=getgongzhaoHb&id=' + id + '&hb=' + hb;
 
        layer.open({
            type: 1,
            title: false,
            content: '<div class="hb_tc"><img src="'+url+'" style="max-width: 100%;"></div>',
            area: ['360px', 'auto'],
            offset: '35px',
            closeBtn: 0,
            shadeClose: true
        });
    }
 
    function downWhb(hb) {
 
        const url = weburl+'/index.php?m=ajax&c=getgongzhaoHb&id=' + id + '&hb=' + hb;
 
        const loading = layer.load('生成中...');
 
        layer.open({
            type: 1,
            title: false,
            content: '<div class="hb_tc"><img src="'+url+'" style="max-width: 100%;"></div>',
            area: ['360px', 'auto'],
            offset: '35px',
            closeBtn: 0,
            shadeClose: true
        });
 
        layer.close(loading);
 
        const loading2 = layer.load('下载中...');
 
        setTimeout(function () {
 
            layer.close(loading2);
 
            const a = document.createElement('a');          // 创建一个a节点插入的document
            const event = new MouseEvent('click');           // 模拟鼠标click点击事件
            a.download = 'gongzhaoHb'+'_'+ id+'_'+hb;           // 设置a节点的download属性值
            a.href = url;                                 // 将图片的src赋值给a节点的href
            a.dispatchEvent(event);
 
        }, 1000);
 
 
    }
 
</script>
</html>