material.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <!doctype html>
  2. <html class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="description" content="">
  7. <meta name="keywords" content="">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  9. <title>推广素材</title>
  10. <!-- Set render engine for 360 browser -->
  11. <meta name="renderer" content="webkit">
  12. <link rel="stylesheet" href="__CDN__/assets/shop/css/amazeui.css">
  13. <link rel="stylesheet" href="__CDN__/assets/shop/css/app.css">
  14. <style>
  15. .app {
  16. font-size: 14px;
  17. text-align: left;
  18. padding: 64px 15px;
  19. }
  20. .lists {
  21. margin-top: 15px;
  22. }
  23. .lists .list-item {
  24. border: 1px solid #ccc;
  25. border-radius: 2px;
  26. background-color: #fff;
  27. margin-bottom: 15px;
  28. }
  29. .list-item .title {
  30. padding: 10px 15px;
  31. }
  32. .action {
  33. border-top: 1px solid #ccc;
  34. padding: 10px 0;
  35. text-align: center;
  36. overflow: hidden;
  37. }
  38. .action button {
  39. background-color: #666;
  40. color: #fff;
  41. border-radius: 10px;
  42. text-align: center;
  43. padding: 4px 8px;
  44. margin-right: 10px;
  45. border: none;
  46. float: right;
  47. }
  48. .albums {
  49. display: flex;
  50. text-align: center;
  51. margin-bottom: 10px;
  52. }
  53. .albums img {
  54. width: calc((100% - 60px)/3);
  55. margin-right: 15px;
  56. text-align: center;
  57. justify-content: center;
  58. }
  59. .albums img:first-child {
  60. margin-left: 15px;
  61. }
  62. #preview {
  63. width: 100%;
  64. height: 100%;
  65. background-color: rgba(97, 94, 92, 0.85);
  66. position: fixed;
  67. z-index: 99;
  68. top: 0;
  69. left: 0;
  70. display: none;
  71. /*overflow-y: scroll;*/
  72. }
  73. #preview .close {
  74. position: fixed;
  75. font-size: 14px;
  76. font-style: normal;
  77. /*padding: 4px;*/
  78. text-align: center;
  79. right: 30px;
  80. top: 80px;
  81. z-index: 9;
  82. width: 36px;
  83. height: 36px;
  84. line-height: 36px;
  85. background-color: #333;
  86. color: #fff;
  87. border-radius: 100%;
  88. }
  89. #preview-img {
  90. width: 100%;
  91. position: absolute;
  92. z-index: 1;
  93. top: 0;
  94. right: 0;
  95. bottom: 0;
  96. left: 0;
  97. margin: auto;
  98. /*margin-top: 48px;*/
  99. max-height: 65%;
  100. }
  101. #download {
  102. max-width: 120px;
  103. z-index: 9;
  104. position: fixed;
  105. right: 0;
  106. bottom: 30px;
  107. left: 0;
  108. margin: auto;
  109. background-color: #666;
  110. color: #fff;
  111. border: none;
  112. padding: 8px 10px;
  113. border-radius: 4px;
  114. }
  115. </style>
  116. </head>
  117. <body>
  118. <!-- Header -->
  119. <header data-am-widget="header" class="am-header am-header-default">
  120. <div class="am-header-left am-header-nav">
  121. <a href="javascript:void(0);" onclick="javascript:history.back(-1);return false;"><i class="am-header-icon am-icon-angle-left"></i></a>
  122. </div>
  123. <h1 class="am-header-title">
  124. <a href="#title-link">推广素材</a>
  125. </h1>
  126. </header>
  127. <div class="wapper app">
  128. <div class="lists">
  129. {volist name="lists" id="v"}
  130. <div class="list-item">
  131. <div class="title">{$v.title}</div>
  132. <div class="albums" id="albums-{$v.id}">
  133. {assign name="images" value="$v.images" /}
  134. {volist name="images" id="vv"}
  135. <img src="{$vv}" alt="" onclick="showPic('{$vv}')">
  136. {/volist}
  137. </div>
  138. <div class="action">
  139. <button onclick="copy('{$v.title}')">复制文案</button>
  140. <!-- <button onclick="savePics('{$v.id}')">保存图片</button>-->
  141. </div>
  142. </div>
  143. {/volist}
  144. </div>
  145. <div id="preview">
  146. <p><span class="close" onclick="closePic()">x</span></p>
  147. <p><img id="preview-img" src="" alt=""></p>
  148. <p><button id="download" onclick="downloadPic()">保存素材</button></p>
  149. </div>
  150. </div>
  151. </body>
  152. <script src="__CDN__/assets/shop/js/jquery.min.js"></script>
  153. <script src="__CDN__/assets/shop/js/amazeui.min.js"></script>
  154. <script src="__CDN__/assets/shop/js/app.js"></script>
  155. <script src="__CDN__/assets/libs/layer/layer.js"></script>
  156. <script src="__CDN__/assets/shop/js/jweixin.js"></script>
  157. <script>
  158. /**
  159. * 批量
  160. */
  161. function savePics(k){
  162. var $urls = $("#albums-"+k).find('img');
  163. if($urls.length <= 0){
  164. layer.msg('暂无素材图片');
  165. return false;
  166. }
  167. $urls.each(function(item,k){
  168. var url = $(this).attr('src');
  169. if(url){
  170. downloadPic(url);
  171. }
  172. })
  173. }
  174. function showPic(url){
  175. if(url){
  176. $("#preview-img").attr('src', url);
  177. $("#preview").show();
  178. }
  179. }
  180. function closePic(){
  181. console.log(666)
  182. $("#preview").hide();
  183. }
  184. function copy(message) {
  185. var input = document.createElement("input");
  186. input.value = message;
  187. document.body.appendChild(input);
  188. input.select();
  189. input.setSelectionRange(0, input.value.length), document.execCommand('Copy');
  190. document.body.removeChild(input);
  191. layer.msg("{:__('复制成功')}");
  192. }
  193. /**
  194. * 下载
  195. * @param imgUrl
  196. */
  197. function downloadPic(){
  198. var imgUrl = $("#preview-img").attr('src');
  199. let triggerEvent = "touchstart"; //指定下载方式
  200. let blob=new Blob([''], {type:'application/octet-stream'});
  201. let url = URL.createObjectURL(blob); //创建一个字符串路径空位
  202. let a = document.createElement('a');
  203. a.href = imgUrl; //把路径赋到a标签的href上
  204. a.download = imgUrl.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0];
  205. let e = new MouseEvent('click', ( true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null));
  206. a.dispatchEvent(e);
  207. //释放一个已经存在的路径(有创建createObjectURL就要释放revokeObjectURL)
  208. URL.revokeObjectURL(url);
  209. }
  210. </script>
  211. </html>