Nessuna descrizione

6.1-preheat.html 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="yes" name="apple-mobile-web-app-capable">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
  7. <title>6.1狂欢节</title>
  8. <link rel="stylesheet" href="./public/reset.css">
  9. <script type="text/javascript" src="public/jquery-2.1.0.js"></script>
  10. <script type="text/javascript">
  11. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  12. window.onresize = function(){
  13. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  14. }
  15. </script>
  16. <style type="text/css">
  17. .alert-info {
  18. position: absolute;
  19. top: 1.74rem;
  20. right: 0;
  21. left: 0;
  22. bottom: 0;
  23. text-align: center;
  24. background: rgba(0,0,0,0.2);
  25. }
  26. .alert-info p {
  27. display: inline-block;
  28. height: 0.38rem;
  29. color: #fff;
  30. font-size: 0.14rem;
  31. line-height: 0.38rem;
  32. padding: 0 0.10rem;
  33. background-color: rgba(0, 0, 0, 0.7);
  34. border-radius: 5px;
  35. }
  36. .loading {
  37. position: fixed;
  38. top: 0;
  39. left: 0;
  40. display: none;
  41. width: 100%;
  42. height: 100vh;
  43. z-index: 99;
  44. }
  45. .loading img {
  46. position: absolute;
  47. top: 0;
  48. bottom: 0;
  49. left: 0;
  50. right: 0;
  51. margin: auto;
  52. width: 0.3rem;
  53. height: 0.3rem;
  54. }
  55. body{
  56. width: 100%;min-height: 100vh;background: #9c3bf9;padding-bottom: 0.2rem;box-sizing: border-box;
  57. }
  58. .banner{
  59. width: 100%;
  60. }
  61. .activity_list{
  62. width: 3.55rem;background: #fff;border-radius: 0.1rem;margin: auto;
  63. display: flex;flex-wrap: wrap;padding: 0.15rem 0.05rem;box-sizing: border-box;
  64. }
  65. .activity_list li{
  66. width: 50%;margin: 0.05rem 0;;
  67. }
  68. .activity_list li div{
  69. width: 1.63rem;height: 0.75rem;background: rgba(0,0,0,0.1);border-radius: 0.1rem;margin: auto;overflow: hidden;
  70. }
  71. .activity_list li div img{
  72. width: 100%;
  73. }
  74. </style>
  75. </head>
  76. <body>
  77. <img src="./img-618/Banner.png" class="banner"/>
  78. <ul class="activity_list">
  79. </ul>
  80. <div class="alert-info" style="display: none;">
  81. <!-- tip提示,3s后消失 -->
  82. <p></p>
  83. </div>
  84. <!-- loading -->
  85. <div class="loading">
  86. <img src="../common/loading.gif" />
  87. </div>
  88. </body>
  89. </html>
  90. <script type="text/javascript">
  91. var token=''
  92. $().ready(function () {
  93. getToken()
  94. })
  95. // 获取token
  96. function getToken() {
  97. var param = {
  98. "js_callback" : "callbackLogin"
  99. };
  100. param = JSON.stringify(param)
  101. try {
  102. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  103. window.webkit.messageHandlers.app_h5_login.postMessage(param);
  104. }
  105. if (navigator.userAgent.match(/android/i)) {
  106. obj4H5.app_h5_login(param);
  107. }
  108. } catch (e) {
  109. // token='4f422467a11afa2cedaa593686f9b1d4257657'
  110. // act_pre_618_envent()
  111. }
  112. }
  113. function callbackLogin(data) {//app token 回调
  114. var data = JSON.parse(data); //上线时添加
  115. token=data.token; //上线时添加
  116. if(token) {
  117. act_pre_618_envent()
  118. }
  119. }
  120. //618预热活动
  121. function act_pre_618_envent() {
  122. if(token) {
  123. $(".loading").show()
  124. $.ajax({
  125. type: "get",
  126. url: "/api/v2/act_pre_618",
  127. typeData: 'json',
  128. headers:{
  129. token:token
  130. },
  131. success: function (res) {
  132. $(".loading").hide()
  133. if (res && res.errno == 0) {
  134. var con_html = res.rst.data.map(function (item,index) {
  135. return '<li><div data-url="' + item.m_url + '"><img src="' + item.img + '"/></div></li>'
  136. })
  137. $(".activity_list").html(con_html);
  138. $(".activity_list li div").click(function () {
  139. toTaobao($(this).attr('data-url'))
  140. })
  141. }else {
  142. showMsg(res.err)
  143. }
  144. },
  145. error: function () {
  146. $(".loading").hide()
  147. }
  148. });
  149. }else {
  150. getToken();
  151. }
  152. }
  153. // 打开淘宝
  154. function toTaobao(tbUrl) {
  155. if(token) {
  156. var param = {
  157. "taobaoUrl" : tbUrl,//淘宝链接
  158. }
  159. param = JSON.stringify(param)
  160. try {
  161. if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
  162. window.webkit.messageHandlers.app_h5_open_taobao_url.postMessage(param);
  163. }
  164. if(navigator.userAgent.match(/android/i)){
  165. obj4H5.app_h5_open_taobao_url(param);
  166. }
  167. } catch (error) {
  168. }
  169. }else {
  170. getToken()
  171. }
  172. }
  173. function showMsg(msg) {
  174. //弹框
  175. var msgBox = document.getElementsByClassName('alert-info')[0];
  176. msgBox.children[0].innerText = msg;
  177. msgBox.style.display="block";
  178. setTimeout(function() {
  179. msgBox.style.display="none";
  180. }, 1500);
  181. }
  182. </script>