share.htm 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  6. <title>猫王邀你“野性”吃鸡</title>
  7. <meta name="description" itemprop="description" content="<!--{echo $we_shareDesc}-->" />
  8. <script type="text/javascript" src="<!--{echo $we_staticDir}-->js/jquery-3.2.1.min.js"></script>
  9. <!-- http://res.wx.qq.com/open/js/jweixin-1.0.0.js -->
  10. <!-- http://res.wx.qq.com/open/js/jweixin-1.2.0.js -->
  11. <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  12. <style>
  13. html
  14. {color:#000;background:#FFF}
  15. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td
  16. {margin:0;padding:0}
  17. table
  18. {border-collapse:collapse;border-spacing:0}
  19. fieldset,img
  20. {border:0}
  21. address,caption,cite,code,dfn,em,strong,th,var
  22. {font-style:normal;font-weight:normal}
  23. ol,ul{list-style:none}
  24. caption,th
  25. {text-align:left}
  26. h1,h2,h3,h4,h5,h6
  27. {font-size:100%;font-weight:normal}
  28. q:before,q:after
  29. {content:''}
  30. abbr,acronym
  31. {border:0;font-variant:normal}
  32. sup{vertical-align:text-top}
  33. sub
  34. {vertical-align:text-bottom}
  35. input,textarea,select
  36. {font-family:inherit;font-size:inherit;font-weight:inherit;*font-size:100%}
  37. legend
  38. {color:#000}#yui3-css-stamp.cssreset{display:none}
  39. img
  40. { width: 100%; display: block;}
  41. /* main css */
  42. body
  43. { width: 100%; height: 100%; position: relative; left:0; top: 0; background: #000; overflow: hidden;}
  44. #wrap
  45. { height: 100%; position: absolute; left: 50%; top:50%; overflow: hidden;}
  46. .content
  47. { width: 1000px; height: 640px; color: #000; position: absolute; left:50%; top:50%;}
  48. .pageWrap
  49. { width: 100%; height: 100%; position: absolute; overflow: hidden; left: 0; top:0; -webkit-transition:all 1s; transition:all 1s; transform: translate3d(100%, 0, 0); -webkit-transform: translate3d(100%, 0, 0);}
  50. .pageWrap div
  51. {
  52. display: none;
  53. // text-align: center;
  54. }
  55. .pageWrap:nth-child(1)
  56. {
  57. // background: #42a8fe url(<!--{echo $we_staticDir}-->chji1.png) no-repeat center bottom;
  58. // background-size:cover; transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0);
  59. }
  60. .pageWrap:nth-child(1) div
  61. { display: block;}
  62. .img11
  63. {
  64. width:100%;
  65. height:100%;
  66. position: absolute;
  67. margin: 0 auto;
  68. transform: translate3d(0, 0, 0);
  69. -webkit-transform: translate3d(0, 0, 0);
  70. }
  71. #shareTip{
  72. transform: translate3d(0, 0, 0);
  73. -webkit-transform: translate3d(0, 0, 0);
  74. }
  75. #img111{
  76. // margin: auto 0 auto 0;
  77. // top: 50%;
  78. position: absolute;
  79. text-align: center ;
  80. margin: auto;
  81. top: 0; left: 0; bottom: 0; right: 0;
  82. }
  83. .invisible {
  84. opacity:0;
  85. filter:alpha(opacity=0);
  86. position:absolute;
  87. left:-320px;
  88. top:-480px;
  89. z-index:0;
  90. }
  91. // .img11{ width:97px; position: absolute; left:2%; top:10%; }
  92. </style>
  93. <script>
  94. function _htmlDecode(value){
  95. return $('<div/>').html(value).text();
  96. }
  97. var ww = window.innerWidth;
  98. var wh = window.innerHeight;
  99. function doLandscape(){
  100. ww = window.innerWidth;
  101. wh = window.innerHeight;
  102. $('body').css({
  103. 'width': ww + 'px',
  104. 'height': wh + 'px'});
  105. $('#wrap').css({
  106. 'width':wh + 'px',
  107. 'height':ww + 'px',
  108. 'transform':'translate3d(-50%,-50%,0) rotate(90deg)',
  109. '-webkit-transform':'translate3d(-50%,-50%,0) rotate(90deg)'
  110. });
  111. }
  112. function doPortrait(){
  113. ww = window.innerWidth;
  114. wh = window.innerHeight;
  115. $('body').css({
  116. 'width': ww + 'px',
  117. 'height': wh + 'px'});
  118. $('#wrap').css({
  119. 'width':ww + 'px',
  120. 'height':wh + 'px',
  121. 'transform':'translate3d(-50%,-50%,0)',
  122. '-webkit-transform':'translate3d(-50%,-50%,0)'
  123. });
  124. }
  125. // 微信横屏模式下,更改分享提示箭头
  126. function setupLandscape() {
  127. $('#arrow_left').css({'display': 'none'});
  128. $('#arrow_right').css({'display': 'inline'});
  129. $('#shareTip').css({'left': 'auto', 'right': '10px'});
  130. $('#img111').css({'height': '100%', 'width': 'auto'});
  131. }
  132. $(document).ready(function(){
  133. setTimeout(function() {
  134. $('#shareTip').css({
  135. 'display': 'inline'
  136. });
  137. setTimeout(function(){
  138. /*
  139. $('#shareTip').css({
  140. 'display': 'none'
  141. });
  142. */
  143. $('#shareTip').fadeOut(2000, function() {
  144. $('#shareTip').css({'display': 'none'});
  145. $('#shareTip').remove();
  146. });
  147. }, 3600);
  148. }, 2000);
  149. window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() {
  150. window.location.reload();
  151. if (window.orientation === 180 || window.orientation === 0) {
  152. // alert('竖屏状态!');
  153. // doLandscape();
  154. }else if (window.orientation === 90 || window.orientation === -90 ){
  155. // alert('横屏状态!');
  156. // doPortrait();
  157. }else{
  158. // alert('no');
  159. }
  160. }, false);
  161. if ( "orientation" in window ) {
  162. if (window.orientation === 180 || window.orientation === 0) {
  163. doLandscape();
  164. }else{
  165. doPortrait();
  166. setupLandscape();
  167. }
  168. }else{
  169. var width = document.documentElement.clientWidth;
  170. var height = document.documentElement.clientHeight;
  171. if ( width < height ){
  172. doLandscape();
  173. }else{
  174. doPortrait();
  175. }
  176. }
  177. });
  178. // alert('' + window.orientation);
  179. </script>
  180. </head>
  181. <body>
  182. <img src="" class="invisible" id="hideicon" />
  183. <script>
  184. var shareIconUrl = "<!--{echo $we_shareIconUrl}-->";
  185. shareIconUrl = _htmlDecode(shareIconUrl);
  186. var shareUrl = "<!--{echo $we_shareUrl}-->";
  187. shareUrl = _htmlDecode(shareUrl);
  188. var bgImageUrl = "<!--{echo $we_bgImageUrl}-->";
  189. bgImageUrl = _htmlDecode(bgImageUrl);
  190. // alert(shareIconUrl + '\n' + shareUrl + '\n' + bgImageUrl);
  191. console.log('shareIconUrl: ' + shareIconUrl);
  192. console.log('shareUrl: ' + shareUrl);
  193. console.log('bgImageUrl: ' + bgImageUrl);
  194. $('#hideicon').attr('src', shareIconUrl);
  195. wx.config({
  196. debug: false,
  197. appId: "<!--{echo $we_appid}-->",
  198. timestamp: <!--{echo $we_timestamp}-->,
  199. nonceStr: "<!--{echo $we_nonceStr}-->",
  200. signature: "<!--{echo $we_signature}-->",
  201. jsApiList: [
  202. 'checkJsApi',
  203. 'onMenuShareTimeline',
  204. 'onMenuShareAppMessage',
  205. // 'onMenuShareQQ',
  206. // 'onMenuShareWeibo',
  207. // 'chooseImage',
  208. // 'uploadImage',
  209. // 'previewImage'
  210. ]
  211. });
  212. wx.ready(function () {
  213. /*
  214. wx.checkJsApi({
  215. jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
  216. success: function(res) {
  217. // 以键值对的形式返回,可用的api值true,不可用为false
  218. // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
  219. // if(!res["checkResult"]["chooseImage"]) {
  220. // alert("当前客户端不支持上传图片");
  221. // }
  222. }
  223. });
  224. */
  225. var shareConfig = {
  226. title: '猫王邀你“野性”吃鸡',
  227. desc: '<!--{echo $we_shareDesc}-->',
  228. link: shareUrl,
  229. imgUrl: shareIconUrl,
  230. };
  231. wx.onMenuShareAppMessage(shareConfig);
  232. wx.onMenuShareTimeline(shareConfig);
  233. wx.error(function (res) {
  234. alert(res.errMsg);
  235. });
  236. // alert(JSON.stringify(shareConfig));
  237. });
  238. </script>
  239. <div id="wrap">
  240. <div class="pageWrap">
  241. <div id="shareTip" style="display: none; position:absolute; top: 10px; left: 10px; z-index: 1999;">
  242. <table>
  243. <tr>
  244. <td>
  245. <img id="arrow_left" src="<!--{echo $we_staticDir}-->bg_share_arrow.png"/>
  246. </td>
  247. <td>
  248. <p ontouchstart="return false;" style="font-size: 18px; height: auto;color: #F31918;background: url(<!--{echo $we_staticDir}-->shareTip.png) no-repeat center center;background-size: 100% 100%;padding: 12px 12px 12px 12px;">请长按保存图片分享到朋友圈</p>
  249. </td>
  250. <td>
  251. <img id="arrow_right" style="display: none;" src="<!--{echo $we_staticDir}-->bg_share_arrow_right.png"/>
  252. </td>
  253. <tr>
  254. </table>
  255. <!-- <img src="<!--{echo $we_staticDir}-->shareTip.png"/> -->
  256. </div>
  257. <div class="img11" style="z-index: 1; position: relative;"><img id="img111" src="" alt="share to wechat image"/></div>
  258. </div>
  259. <!--
  260. <div class="pageWrap">
  261. </div>
  262. -->
  263. </div>
  264. <script>
  265. $('#img111').attr('src', bgImageUrl);
  266. </script>
  267. </body>
  268. </html>