index.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <html>
  2. <head>
  3. <title>jolijoli</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
  6. <!-- <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.1/weui.min.css">
  7. </link> -->
  8. <link rel="icon" href="./image/icon_logo.png" type="image/x-icon">
  9. <script src="./jquery.js"></script>
  10. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  11. <style>
  12. html,body,p {
  13. margin: 0;
  14. padding: 0;
  15. }
  16. img {
  17. width: 100%;
  18. }
  19. .fixed {
  20. position: fixed;
  21. bottom: 0;
  22. left: 0;
  23. width: 100%;
  24. height: 98px;
  25. background-color: #fff;
  26. }
  27. .model {
  28. position: fixed;
  29. left: 0;
  30. top: 0;
  31. width: 100%;
  32. height: 100%;
  33. background-color: rgba(0, 0, 0, 0.4);
  34. display: flex;
  35. justify-content: center;
  36. align-items: center;
  37. }
  38. .model img{
  39. width: 70%;
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. <div class="box">
  45. </div>
  46. <div style="height: 98px;"></div>
  47. <div class="fixed">
  48. <div class="btm-btn-wx" style="display: block;">
  49. <!-- <wx-open-launch-weapp id="launch-btn" username="gh_38d7446511dd" path="pages/home/home.html">
  50. <template>
  51. <style>
  52. img {
  53. width: 100%;
  54. }
  55. .img {
  56. width: 100%;
  57. }
  58. </style>
  59. <div style="padding: 20px;">
  60. <img class="img btn-img" src="https://test-m.ijolijoli.com/image/image_07.png" alt="">
  61. <img class="img btn-img" src="" alt="">
  62. </div>
  63. </template>
  64. </wx-open-launch-weapp> -->
  65. </div>
  66. <div class="btm-btn" style="display: none;">
  67. <div style="padding: 20px;">
  68. <img class="img btn-img" src="./image/image_07.png" alt="">
  69. </div>
  70. </div>
  71. </div>
  72. <div class="model" style="display: none;">
  73. <img class="wx-code" src="./image/wx_code.jpg" alt="">
  74. </div>
  75. <script type="text/javascript">
  76. $(document).ready(function () {
  77. let host = window.location.host;
  78. let api_url,data_url;
  79. if(host == "m.ijolijoli.com") {
  80. api_url = 'https://api.ijolijoli.com'
  81. data_url = "https://m.ijolijoli.com"
  82. } else if(host == "test-m.ijolijoli.com") {
  83. api_url = 'https://test-api.ijolijoli.com'
  84. data_url = "https://test-m.ijolijoli.com"
  85. } else {
  86. api_url = 'https://test-api.ijolijoli.com'
  87. data_url = "https://test-m.ijolijoli.com"
  88. }
  89. console.log(host)
  90. function dff() {
  91. $.ajax({
  92. url: `${api_url}/api/show`,
  93. type: 'GET',
  94. data:{
  95. url: data_url + '/'
  96. },
  97. success: function (res) {
  98. console.log('33333')
  99. let str = `<wx-open-launch-weapp id="launch-btn" username="gh_38d7446511dd" path="pages/home/home.html">
  100. <template>
  101. <style>
  102. img {
  103. width: 100%;
  104. }
  105. .img {
  106. width: 100%;
  107. }
  108. </style>
  109. <div style="padding: 20px;">
  110. <img class="img btn-img" src="${res.data.btn_image_url}" alt="">
  111. </div>
  112. </template>
  113. </wx-open-launch-weapp>`
  114. $('.btm-btn-wx').html(str)
  115. $('.box').html(res.data.content)
  116. $('.btn-img').attr('src',res.data.btn_image_url);
  117. $('.wx-code').attr('src',res.data.wxmini_image_url)
  118. wx.config({
  119. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  120. appId: res.data.jssdk.appId, // 必填,公众号的唯一标识
  121. timestamp: res.data.jssdk.timestamp, // 必填,生成签名的时间戳
  122. nonceStr: res.data.jssdk.nonceStr, // 必填,生成签名的随机串
  123. signature: res.data.jssdk.signature,// 必填,签名
  124. jsApiList: ['chooseImage', 'previewImage'], // 必填,需要使用的JS接口列表
  125. openTagList: ['wx-open-launch-weapp'] // 可选,需要使用的开放标签列表
  126. });
  127. // wx.config(res.data)
  128. }
  129. });
  130. }
  131. dff();
  132. var ua = window.navigator.userAgent.toLowerCase();// 不加window部分Android机会显示不了提示图,即判断不了是否是微信
  133. if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  134. $('.btm-btn').hide()
  135. $('.btm-btn-wx').show()
  136. wx.ready(function () {
  137. console.log('config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中')
  138. var btn = document.getElementById('launch-btn');
  139. btn.addEventListener('launch', function (e) {
  140. console.log('success');
  141. // alert('success')
  142. });
  143. btn.addEventListener('error', function (e) {
  144. console.log('fail', e.detail);
  145. alert('fail', e.detail)
  146. // alert('fail', e.detail)
  147. });
  148. });
  149. } else {
  150. $('.btm-btn').show()
  151. $('.btm-btn-wx').hide()
  152. }
  153. $('.btm-btn').on('click',function() {
  154. $('.model').show()
  155. })
  156. $('.model').on('click',function() {
  157. $('.model').hide()
  158. })
  159. })
  160. </script>
  161. </body>