groupon.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <html>
  2. <head>
  3. <title>鲸致生活-团购券预约</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. <script>
  7. window.onerror = e => {
  8. console.error(e)
  9. alert('发生错误' + e)
  10. }
  11. </script>
  12. <!-- weui 样式 -->
  13. <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.1/weui.min.css">
  14. </link>
  15. <!-- 调试用的移动端 console -->
  16. <script src="../groupon/js/jquery-1.7.2.min.js"></script>
  17. <!-- 公众号 JSSDK -->
  18. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  19. <!-- 云开发 Web SDK -->
  20. <script src="https://res.wx.qq.com/open/js/cloudbase/1.1.0/cloud.js"></script>
  21. <script>
  22. function docReady(fn) {
  23. if (document.readyState === 'complete' || document.readyState === 'interactive') {
  24. fn()
  25. } else {
  26. document.addEventListener('DOMContentLoaded', fn);
  27. }
  28. }
  29. docReady(async function () {
  30. var ua = navigator.userAgent.toLowerCase()
  31. var isWXWork = ua.match(/wxwork/i) == 'wxwork'
  32. var isWeixin = !isWXWork && ua.match(/micromessenger/i) == 'micromessenger'
  33. var isMobile = false
  34. var isDesktop = false
  35. if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i)) {
  36. isMobile = true
  37. } else {
  38. isDesktop = true
  39. }
  40. if (isWeixin) {
  41. console.info('微信浏览器')
  42. var containerEl = document.getElementById('wechat-web-container')
  43. containerEl.classList.remove('hidden')
  44. containerEl.classList.add('full', 'wechat-web-container')
  45. var launchBtn = document.getElementById('launch-btn');
  46. var coupon = getQueryString('coupon');
  47. launchBtn.setAttribute("path", "/pages/ucenter/couponList/couponList?type=1&coupon=" + coupon);
  48. launchBtn.addEventListener('ready', function (e) {
  49. console.log('开放标签 ready')
  50. //alert('开放标签 ready')
  51. })
  52. launchBtn.addEventListener('launch', function (e) {
  53. console.log('开放标签 success')
  54. //alert('开放标签 success')
  55. })
  56. launchBtn.addEventListener('error', function (e) {
  57. console.log('开放标签 fail', e.detail)
  58. //alert(e.detail)
  59. })
  60. wx.config({
  61. //debug: true, // 调试时可开启
  62. appId: 'wxf0a77f9993d8b60d', // <!-- replace -->
  63. timestamp: 0, // 必填,填任意数字即可
  64. nonceStr: 'nonceStr', // 必填,填任意非空字符串即可
  65. signature: 'signature', // 必填,填任意非空字符串即可
  66. jsApiList: ['chooseImage', 'previewImage'], // 必填,随意一个接口即可
  67. openTagList: ['wx-open-launch-weapp'], // 填入打开小程序的开放标签名
  68. })
  69. } else if (isDesktop) {
  70. // 在 pc 上则给提示引导到手机端打开
  71. var containerEl = document.getElementById('desktop-web-container')
  72. containerEl.classList.remove('hidden')
  73. containerEl.classList.add('full', 'desktop-web-container');
  74. } else {
  75. console.info('手机浏览器')
  76. var containerEl = document.getElementById('public-web-container')
  77. containerEl.classList.remove('hidden')
  78. containerEl.classList.add('full', 'public-web-container')
  79. var c = new cloud.Cloud({
  80. // 必填,表示是未登录模式
  81. identityless: true,
  82. // 资源方 AppID
  83. resourceAppid: 'wxf0a77f9993d8b60d', // <!-- replace -->
  84. // 资源方环境 ID
  85. resourceEnv: 'zhaijieshi-3guecm78383ca692', // <!-- replace -->
  86. })
  87. await c.init()
  88. window.c = c
  89. var buttonEl = document.getElementById('public-web-jump-button')
  90. var buttonLoadingEl = document.getElementById('public-web-jump-button-loading')
  91. try {
  92. // await openWeapp(() => {
  93. // buttonEl.classList.remove('weui-btn_loading')
  94. // buttonLoadingEl.classList.add('hidden')
  95. // })
  96. } catch (e) {
  97. buttonEl.classList.remove('weui-btn_loading')
  98. buttonLoadingEl.classList.add('hidden')
  99. throw e
  100. }
  101. }
  102. })
  103. //手机浏览器
  104. async function openWeapp(onBeforeJump) {
  105. var coupon = getQueryString('coupon');
  106. if (coupon == null || coupon == '' || coupon == 'null' || coupon.length < 10) {
  107. document.getElementById('errId').classList.remove('hidden');
  108. return;
  109. }
  110. document.getElementById('errId').classList.add('hidden');
  111. var c = window.c
  112. const res = await c.callFunction({
  113. name: 'public',
  114. data: {
  115. action: 'douyinCoupon',
  116. path: '/pages/ucenter/couponList/couponList',
  117. query: 'type=1&coupon=' + coupon //不能进行encodeURIComponent编码,
  118. },
  119. })
  120. console.warn(res)
  121. if (onBeforeJump) {
  122. onBeforeJump()
  123. }
  124. location.href = res.result.openlink
  125. }
  126. //获取url参数
  127. function getQueryString(name) {
  128. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  129. var r = window.location.search.substr(1).match(reg);
  130. if (r != null) {
  131. return unescape(r[2]);
  132. }
  133. return null;
  134. }
  135. </script>
  136. <style>
  137. .hidden {
  138. display: none;
  139. }
  140. .full {
  141. margin-top: 30%;
  142. }
  143. .public-web-container {
  144. display: flex;
  145. flex-direction: column;
  146. align-items: center;
  147. margin-bottom: 30px;
  148. }
  149. .wechat-web-container {
  150. /* display: flex;
  151. flex-direction: column;
  152. align-items: center; */
  153. height: 80px;
  154. }
  155. .wechat-web-container wx-open-launch-weapp {
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. margin: 0px auto;
  160. height: 60px;
  161. }
  162. .desktop-web-container {
  163. display: flex;
  164. flex-direction: column;
  165. align-items: center;
  166. position: absolute;
  167. bottom: 20px;
  168. left: 0;
  169. right: 0;
  170. bottom: 0;
  171. margin: auto;
  172. }
  173. .top {
  174. height: -160px;
  175. background-color: white;
  176. text-align: center;
  177. width: 100%;
  178. }
  179. .btn {
  180. width: 90%;
  181. height: 50px;
  182. text-align: center;
  183. font-size: 17px;
  184. padding: 8px 24px;
  185. border-radius: 40px;
  186. border: 1px solid #c2c5c7;
  187. background-color: #c2c5c7;
  188. color: white;
  189. position: absolute;
  190. margin: auto;
  191. left: 0;
  192. right: 0;
  193. }
  194. </style>
  195. </head>
  196. <body style="background-color: #29BBEA;">
  197. <div style="margin-top:30%;text-align: center;">
  198. <img src="../douyin/img/logo.png" style="width: 120px;" />
  199. </div>
  200. <div id="copyDom"></div>
  201. <div class="page full">
  202. <!--------------------------- 手机浏览器----------------------------------------------------------->
  203. <div id="errId" class="hidden" style="font-size: 11px;color: red;text-align: center;">无效团购券号</div>
  204. <div id="public-web-container" class="hidden">
  205. <a id="public-web-jump-button" href="javascript:void(0)" style="background-color: #29BBEA;color: white;height:50px;border-radius: 40px;border: 2px solid white;line-height: 30px;
  206. width: 80%;font-weight: 600;" class="weui-btn weui-btn_primary weui-btn_loading" onclick="openWeapp()">
  207. 一键唤起小程序
  208. </a>
  209. <!-- <div style="padding:0 10px;height: 58px;font-size: 11px;color: #939393;line-height: 19px;display: flex;">
  210. <input type="checkbox" style="margin-top: 4px;margin-right: 5px;"></input>
  211. <div>预约即代表您已阅读并接受<span style="font-weight: 600;">《券码核销说明》</span>和
  212. <span style="font-weight: 600;">《服务范围覆盖 说明》</span>与
  213. <span style="font-weight: 600;">《服务日期更改规则》</span>
  214. </div>
  215. </div> -->
  216. </div>
  217. <!--------------------------- 微信浏览器----------------------------------------------------------->
  218. <div id="wechat-web-container" class="hidden">
  219. <wx-open-launch-weapp id="launch-btn" username="gh_e9b9499458d9" path="/pages/ucenter/couponList/couponList">
  220. <template>
  221. <style>
  222. .btn {
  223. width: 80%;
  224. height: 50px;
  225. text-align: center;
  226. font-size: 17px;
  227. display: block;
  228. margin: 0 auto;
  229. padding: 8px 24px;
  230. border-radius: 40px;
  231. border: 2px solid white;
  232. background-color: #29BBEA;
  233. color: white;
  234. font-weight: 600;
  235. }
  236. </style>
  237. <button class="btn">一键唤起小程序</button>
  238. </template>
  239. </wx-open-launch-weapp>
  240. <!-- <div style="padding:0 10px;height: 58px;font-size: 11px;color: #939393;line-height: 19px;display: flex;">
  241. <input type="checkbox" style="margin-top: 4px;margin-right: 5px;height: 20px;width: 20px;"></input>
  242. <div>预约即代表您已阅读并接受<span style="font-weight: 600;">《券码核销说明》</span>和
  243. <span style="font-weight: 600;">《服务范围覆盖 说明》</span>与
  244. <span style="font-weight: 600;">《服务日期更改规则》</span>
  245. </div>
  246. </div> -->
  247. </div>
  248. <!-- pc端打开提醒 -->
  249. <div id="desktop-web-container" class="hidden">
  250. <p class="" style="margin-top: 30px;">请在手机打开网页链接</p>
  251. </div>
  252. </div>
  253. </body>
  254. </html>