index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta content="yes" name="apple-mobile-web-app-capable">
  7. <meta content="yes" name="apple-touch-fullscreen">
  8. <meta content="black" name="apple-mobile-web-app-status-bar-style">
  9. <meta content="telephone=no" name="format-detection">
  10. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,viewport-fit=cover" />
  11. <title>回望江南—苏州老照片展</title>
  12. <link rel="stylesheet" type="text/css" href="static/public/animate.min.css" />
  13. <link rel="stylesheet" type="text/css" href="static/public/swiper-4.3.5.min.css" />
  14. <link rel="stylesheet" type="text/css" href="static/css/app.css" />
  15. <script src="static/public/flexible.min.js" async></script>
  16. <style>
  17. .BAC {
  18. z-index: 999;
  19. background: url('./static/images/bac/06.jpg') no-repeat center;
  20. background-size: cover;
  21. width: 100vw;
  22. height: 100vh;
  23. position: absolute;
  24. top: 0;
  25. left: 0;
  26. display: none;
  27. overflow: hidden;
  28. }
  29. .BAC_son {
  30. width: 140px;
  31. max-width: 240px;
  32. min-width: 100px;
  33. position: absolute;
  34. top: 50%;
  35. left: 50%;
  36. transform: translate(-50%, -50%);
  37. }
  38. .BAC_son img {
  39. width: 100%;
  40. height: 100%;
  41. }
  42. .but {
  43. z-index: 1000;
  44. position: absolute;
  45. left: 50%;
  46. transform: translateX(-50%);
  47. bottom: 50px;
  48. display: flex;
  49. justify-content: space-between;
  50. width: 70%;
  51. height: 40px;
  52. display: none;
  53. }
  54. .but img {
  55. height: 100%;
  56. }
  57. .but img:nth-of-type(2) {
  58. float: right;
  59. }
  60. .box {
  61. position: absolute;
  62. width: 100%;
  63. height: 85%;
  64. bottom: 0;
  65. left: 0;
  66. }
  67. .BAC_son .arrows {
  68. position: absolute;
  69. right: 0;
  70. top: 0;
  71. width: 30px;
  72. height: 30px;
  73. }
  74. .watermark {
  75. position: absolute;
  76. bottom: 0;
  77. right: 0;
  78. width: 300px;
  79. z-index: 1001;
  80. }
  81. .poster-container {
  82. position: absolute;
  83. width: 100vw;
  84. height: 100vh;
  85. display: none;
  86. z-index: 1005;
  87. }
  88. #myIMG{
  89. width: 100%;
  90. height: 100%;
  91. }
  92. body {
  93. overflow: hidden;
  94. }
  95. .return {
  96. position: absolute;
  97. top: 100px;
  98. left: 50%;
  99. transform: translateX(-50%);
  100. background-color: rgba(0, 0, 0, .8);
  101. color: #fff;
  102. font-size: 18px;
  103. width: 100%;
  104. height: 80px;
  105. line-height: 80px;
  106. text-align: center;
  107. }
  108. .goBack {
  109. position: absolute;
  110. left: 10px;
  111. bottom: 10px;
  112. width: 50px;
  113. height: 30px;
  114. background-color: rgb(255, 255, 255);
  115. }
  116. .goBack img {
  117. width: 100%;
  118. height: 100%;
  119. }
  120. .mybox {
  121. display: none !important;
  122. }
  123. </style>
  124. </head>
  125. <body>
  126. <!-- 生成的图片 -->
  127. <div class="poster-container">
  128. <!-- 提示 -->
  129. <div class="return">请长按图片保存</div>
  130. <!-- 返回 -->
  131. <div class="goBack">
  132. <img src="./static/images/back.png" alt="">
  133. </div>
  134. <img id="myIMG" src="/" alt="">
  135. </div>
  136. <!-- 背景图和人像图 -->
  137. <div class="BAC" id="saveWrapX">
  138. <img class="watermark" src="./static/images/adds/watermark.png" alt="">
  139. <div class="BAC_son">
  140. <img class="arrows" src="./static/images/adds/fangda.png" alt="">
  141. <div class="box">
  142. </div>
  143. <img class="myImg" src="" alt="">
  144. </div>
  145. </div>
  146. <div class="but">
  147. <img class="cancel" src="./static/images/adds/22.png" alt="">
  148. <img class="save" src="./static/images/adds/11.png" alt="">
  149. </div>
  150. <div class="app-main">
  151. <div class="ads-swiper swiper-container">
  152. <div class="swiper-wrapper"></div>
  153. <div class="swiper-pagination"></div>
  154. </div>
  155. <nav class="nav-menu">
  156. <ul>
  157. <li><a href="javascript:;" class="btn-pic-take"></a></li>
  158. <li><a href="javascript:;" class="btn-pic-list"></a></li>
  159. </ul>
  160. </nav>
  161. </div>
  162. <div class="app-switch">
  163. <nav class="swt-style clearfix">
  164. <a href="javascript:;" data-id='1' class="switch active"></a>
  165. <div></div>
  166. </nav>
  167. <div class="stl-swiper swiper-container">
  168. <div class="swiper-wrapper">
  169. <div data-msg="1" class="swiper-slide style-1"></div>
  170. <div data-msg="2" class="swiper-slide style-2"></div>
  171. <div data-msg="3" class="swiper-slide style-3"></div>
  172. <div data-msg="4" class="swiper-slide style-4"></div>
  173. <div data-msg="5" class="swiper-slide style-5"></div>
  174. <div data-msg="6" class="swiper-slide style-6"></div>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="my-pic-list">
  179. <header>
  180. <div class="home-nav">
  181. <a class="btn-back"></a>
  182. </div>
  183. <div class="tips">
  184. 相片将于您退出后删除,请尽快保存
  185. </div>
  186. </header>
  187. <article>
  188. <div class="pic-swiper swiper-container">
  189. <div class="swiper-wrapper">
  190. <div class="swiper-slide">
  191. <!-- <div class="img">
  192. <img src="static/images/test.png">
  193. </div>
  194. <div class="info">
  195. <div class="time">
  196. 2010年10月10日 18:00:00
  197. </div>
  198. <div class="style style-1"></div>
  199. </div> -->
  200. </div>
  201. </div>
  202. <div class="swiper-scrollbar"></div>
  203. </div>
  204. </article>
  205. </div>
  206. <!-- 点击拍照之后的原显示页面 -->
  207. <div class="app-mask"></div>
  208. <div class="app-alert">
  209. <div class="tips"></div>
  210. <div class="btns">
  211. <a class="btn-use" href="javascript:;">再次使用</a>
  212. <a class="btn-link" href="javascript:;">刷新页面</a>
  213. </div>
  214. </div>
  215. <div class="app-view mybox">
  216. <div class="img"></div>
  217. <div class="tip">
  218. <div>
  219. <div>长按图片保存</div>
  220. <div>关闭后可在【我的相片】中查看</div>
  221. </div>
  222. <span class="close"></span>
  223. </div>
  224. </div>
  225. <div class="app-action-tips">
  226. <div class="content loading">
  227. <div class="lds-spinner">
  228. <div></div>
  229. <div></div>
  230. <div></div>
  231. <div></div>
  232. <div></div>
  233. <div></div>
  234. <div></div>
  235. <div></div>
  236. <div></div>
  237. <div></div>
  238. <div></div>
  239. <div></div>
  240. </div>
  241. <div class="tips"></div>
  242. </div>
  243. <div class="content loading-switch">
  244. <div class="lds-spinner">
  245. <div></div>
  246. <div></div>
  247. <div></div>
  248. <div></div>
  249. <div></div>
  250. <div></div>
  251. <div></div>
  252. <div></div>
  253. <div></div>
  254. <div></div>
  255. <div></div>
  256. <div></div>
  257. </div>
  258. <div class="tips">正在切换画风</div>
  259. </div>
  260. <div class="content face-6">
  261. <div class="tips">
  262. 将于1秒后拍摄
  263. </div>
  264. </div>
  265. <div class="content face-5">
  266. <div class="tips">
  267. 将于2秒后拍摄
  268. </div>
  269. </div>
  270. <div class="content face-4">
  271. <div class="tips">
  272. 将于3秒后拍摄
  273. </div>
  274. </div>
  275. <div class="content face-3">
  276. <div class="tips">
  277. 将于4秒后拍摄
  278. </div>
  279. </div>
  280. <div class="content face-2">
  281. <div class="tips">
  282. 将于5秒后拍摄
  283. </div>
  284. </div>
  285. <div class="content face-1">
  286. <div class="tips">
  287. 快望向你身前的艺术<br>照设备,准备拍照啦
  288. </div>
  289. </div>
  290. </div>
  291. <script src="static/public/swiper-4.3.5.min.js"></script>
  292. <script src="static/public/jquery.min.js"></script>
  293. <script src="static/js/config.js"></script>
  294. <script src="static/js/app.js"></script>
  295. <script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  296. <script src="./static/js/html2canvas.js"></script>
  297. </body>
  298. <script>
  299. // 获取最大盒子的宽高
  300. let BACwidth = $('.BAC').width()
  301. let BACheight = $('.BAC').height()
  302. // 初始盒子的位移
  303. let BACSonTop = $('.BAC_son').offset().top
  304. let BACSonLeft = $('.BAC_son').offset().left
  305. let _x_start, _y_start, _x_move, _y_move, _x_end, _y_end, left_start, top_start;
  306. $('.box').on('touchstart', function (e) {
  307. _x_start = e.touches[0].pageX;
  308. _y_start = e.touches[0].pageY;
  309. // console.log("start",_x_start)
  310. left_start = $('.BAC_son').css("left");
  311. top_start = $('.BAC_son').css("top");
  312. })
  313. $('.box').on('touchmove', function (e) {
  314. //获取当前盒子的宽高
  315. let BACSonWidth = $('.BAC_son').width()
  316. let BACSonHeight = $('.BAC_son').height()
  317. _x_move = e.touches[0].pageX;
  318. _y_move = e.touches[0].pageY;
  319. // console.log("move",_x_move)
  320. let myLeft = parseFloat(_x_move) - parseFloat(_x_start) + parseFloat(left_start)
  321. if (myLeft < BACSonWidth / 2) myLeft = BACSonWidth / 2
  322. if (myLeft > BACwidth - BACSonWidth + BACSonLeft + 100) myLeft = BACwidth - BACSonWidth / 2
  323. let myTop = parseFloat(_y_move) - parseFloat(_y_start) + parseFloat(top_start)
  324. if (myTop < BACSonHeight / 2) myTop = BACSonHeight / 2
  325. if (myTop > BACheight - BACSonHeight + BACSonTop + 200) myTop = BACheight - BACSonHeight / 2
  326. $('.BAC_son').css("left", myLeft + "px");
  327. $('.BAC_son').css("top", myTop + "px");
  328. // console.log(parseFloat(_y_move) - parseFloat(_y_start) + parseFloat(top_start));
  329. })
  330. $('.box').on('touchend', function (e) {
  331. let _x_end = e.changedTouches[0].pageX;
  332. let _y_end = e.changedTouches[0].pageY;
  333. })
  334. //阻止浏览器下拉事件
  335. $('BAC').on('touchmove', function (event) { event.preventDefault(); });
  336. //------------------------------按住箭头放大图片-------------------------
  337. let zoom_xS, zoom_yS, zoom_xE, zoom_yE
  338. $('.arrows').on('touchstart', function (e) {
  339. //获取初始的手指按下位置
  340. zoom_xS = e.touches[0].pageX;
  341. zoom_yS = e.touches[0].pageY;
  342. // console.log('按住了');
  343. })
  344. $('.arrows').on('touchmove', function (e) {
  345. //获取当前盒子的宽高
  346. let BACSonWidth = $('.BAC_son').width()
  347. let BACSonHeight = $('.BAC_son').height()
  348. //移动后的手指位置
  349. zoom_xE = e.touches[0].pageX;
  350. zoom_yE = e.touches[0].pageY;
  351. // console.log(zoom_xE-zoom_xS,zoom_yE-zoom_yS);
  352. // console.log('移动了',e.touches[0].pageX,e.touches[0].pageY);
  353. if (zoom_xE - zoom_xS > 0) $('.BAC_son').css('width', BACSonWidth + 5)
  354. else $('.BAC_son').css('width', BACSonWidth - 5)
  355. // if() $('.BAC_son').css('height',BACSonWidth-3)
  356. // else $('.BAC_son').css('height',BACSonHeight+3)
  357. })
  358. // 点击取消
  359. $('.cancel').on('click', function (e) {
  360. $('.BAC').css('display', 'none')
  361. $('.but').css('display', 'none')
  362. })
  363. // 选择背景图
  364. $('.btn-pic-take').on('click', function (e) {
  365. setTimeout(() => {
  366. let aaa = $('.swiper-wrapper .active')
  367. // console.log(11111111, aaa.attr('data-msg'));
  368. if (aaa.attr('data-msg')) {
  369. // background-image: url('./static/images/bac/0'+'1.jpg');
  370. let url = './static/images/bac/0' + aaa.attr('data-msg') + '.jpg'
  371. // console.log(6666666, url);
  372. $('.BAC').css('background', `url(${url}) no-repeat center`)
  373. }
  374. }, 100);
  375. })
  376. //点击保存
  377. $('.save').on('click', function (event) {
  378. // 先隐藏箭头
  379. $('.arrows').css('display', 'none')
  380. html2canvas(document.getElementById("saveWrapX"),{
  381. // proxy:'http://fdart-huadong.oss-cn-shanghai.aliyuncs.com',
  382. useCORS: true,
  383. scale:1}).then(function(canvas) {
  384. document.querySelector('.poster-container').appendChild(canvas);
  385. let canvas1 = $('.poster-container canvas')
  386. let posterImage = document.getElementById("myIMG")
  387. posterImage.src = canvas1[0].toDataURL("image/jpg")
  388. })
  389. $('.poster-container').css('display', 'block')
  390. $('.BAC').css('display', 'none')
  391. $('.but').css('display', 'none')
  392. });
  393. // 生成图片后点击返回
  394. $('.goBack').on('click', function (event) {
  395. $('.poster-container').css('display', 'none')
  396. window.location.reload()
  397. })
  398. </script>
  399. </html>