spd.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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="../mall/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. //设置优惠券值
  41. setCouponValue();
  42. if (isWeixin) {
  43. console.info('微信浏览器')
  44. var containerEl = document.getElementById('wechat-web-container')
  45. containerEl.classList.remove('hidden')
  46. containerEl.classList.add('full', 'wechat-web-container')
  47. var launchBtn = document.getElementById('launch-btn')
  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'], // 必填,随意一个接口即可
  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. async function openWeapp(onBeforeJump) {
  104. var c = window.c
  105. const res = await c.callFunction({
  106. name: 'public',
  107. data: {
  108. action: 'getUrlScheme',
  109. },
  110. })
  111. console.warn(res)
  112. if (onBeforeJump) {
  113. onBeforeJump()
  114. }
  115. location.href = res.result.openlink
  116. }
  117. //复制券码
  118. function copyCoupon() {
  119. var value = getQueryString("no");
  120. if (value == null) return;
  121. const input = document.createElement('input');
  122. document.body.appendChild(input);
  123. input.setAttribute('value', value);
  124. input.select();
  125. if (document.execCommand('copy')) {
  126. document.execCommand('copy');
  127. showCopySuccess('复制成功');
  128. }
  129. document.body.removeChild(input);
  130. }
  131. //显示复制成功
  132. function showCopySuccess(msg) {
  133. //赋值
  134. document.getElementById('spanMsg').innerHTML = msg;
  135. const copySuccess = document.getElementById('copySuccess');
  136. copySuccess.classList.remove('hidden');
  137. setTimeout(() => {
  138. const copySuccess = document.getElementById('copySuccess');
  139. copySuccess.classList.add('hidden', 'copySuccess')
  140. }, 2000);
  141. }
  142. function setCouponValue() {
  143. const coupon = getQueryString("no") == null ? '无效券号' : getQueryString("no");
  144. document.getElementById("coupon-wx").innerHTML = coupon;
  145. document.getElementById("coupon-web").innerHTML = coupon;
  146. //获取码对应的商品名称
  147. let url = "https://mall.zhaijieshi.cc/admin/coupon/getGoodsName?coupon=" + coupon;
  148. $.ajax({
  149. type: 'get',
  150. dataType: "json",
  151. url: url,
  152. cache: false,
  153. async: false,
  154. success: function (data) {
  155. if (data.errno == 0) {
  156. $('.goods').html(data.data);
  157. }
  158. else{
  159. $('.goods').html('无效券码');
  160. $("#coupon-wx").innerHTML = coupon+'(无效券码)';
  161. $("#coupon-web").innerHTML = coupon+'(无效券码)';
  162. $('.copy').hide();
  163. }
  164. },
  165. error: function (XMLHttpRequest, textStatus, errorThrown) {
  166. }
  167. });
  168. }
  169. //获取url参数
  170. function getQueryString(name) {
  171. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  172. var r = window.location.search.substr(1).match(reg);
  173. if (r != null) {
  174. return unescape(r[2]);
  175. }
  176. return null;
  177. }
  178. </script>
  179. <style>
  180. .hidden {
  181. display: none;
  182. }
  183. .full {
  184. position: absolute;
  185. top: 0;
  186. bottom: 0;
  187. left: 0;
  188. right: 0;
  189. }
  190. .public-web-container {
  191. display: flex;
  192. flex-direction: column;
  193. align-items: center;
  194. }
  195. /* .public-web-container p {
  196. position: absolute;
  197. top: 40%;
  198. } */
  199. .public-web-container a {
  200. /*position: absolute;
  201. bottom: 40%; */
  202. margin-top: 30px;
  203. }
  204. .wechat-web-container {
  205. display: flex;
  206. flex-direction: column;
  207. align-items: center;
  208. }
  209. /* .wechat-web-container p {
  210. position: absolute;
  211. top: 40%;
  212. } */
  213. .wechat-web-container wx-open-launch-weapp {
  214. /* height: 45px;
  215. color:#fff;
  216. background-color: #ce3406;
  217. margin-top: 30px;*/
  218. position: absolute;
  219. bottom: 40%;
  220. left: 0;
  221. right: 0;
  222. display: flex;
  223. flex-direction: column;
  224. align-items: center;
  225. }
  226. .desktop-web-container {
  227. display: flex;
  228. flex-direction: column;
  229. align-items: center;
  230. }
  231. /* .desktop-web-container p {
  232. position: absolute;
  233. top: 40%;
  234. } */
  235. .top {
  236. height: 160px;
  237. background-color: #09AFFF;
  238. text-align: center;
  239. width: 100%;
  240. }
  241. .coupon {
  242. text-align: center;
  243. width: 100%;
  244. }
  245. .coupon .label {
  246. text-align: left;
  247. margin-left: 5px;
  248. margin-top: 5px;
  249. position: unset;
  250. font-size: 12px;
  251. }
  252. .coupon .goods {
  253. font-size: 24px;
  254. font-weight: 700;
  255. position: unset;
  256. margin-top: 10px;
  257. margin-bottom: 10px;
  258. }
  259. .coupon-label {
  260. font-size: 17px;
  261. font-weight: 300;
  262. position: unset;
  263. }
  264. .coupon-value {
  265. font-size: 18px;
  266. font-weight: 500;
  267. position: unset;
  268. }
  269. .copy {
  270. color: #09AFFF;
  271. position: unset !important;
  272. }
  273. .read {
  274. padding: 0 10px;
  275. font-size: 13px;
  276. position: absolute;
  277. bottom: 10px;
  278. }
  279. .read .title {
  280. text-align: center;
  281. }
  282. .read .header {
  283. font-weight: 600;
  284. }
  285. .read .content {
  286. font-size: 11px;
  287. }
  288. .line {
  289. position: relative;
  290. width: 100px;
  291. top: -15px;
  292. text-align: center;
  293. background-color: #fff;
  294. margin: 0 auto;
  295. }
  296. .message {
  297. position: absolute;
  298. top: 40%;
  299. z-index: 999;
  300. color: #fff;
  301. background-color: #999;
  302. text-align: center;
  303. left: 50%;
  304. transform: translate(-50%, -50%);
  305. padding: 10px;
  306. border-radius: 5px;
  307. }
  308. </style>
  309. </head>
  310. <body>
  311. <div class="page full">
  312. <!-- 复制成功提醒 -->
  313. <div id='copySuccess' class="message hidden">
  314. <span id='spanMsg'>复制成功</span>
  315. </div>
  316. <!--------------------------- 手机浏览器----------------------------------------------------------->
  317. <div id="public-web-container" class="hidden">
  318. <div class="top">
  319. <img src="../mall/img/logo.png" width="160px" />
  320. </div>
  321. <div class="coupon">
  322. <p class="label">*点击领取您的专属权益</p>
  323. <p class="goods">鲸致生活3小时居家保洁服务</p>
  324. <p class="coupon-label">兑换码</p>
  325. <p class="coupon-value" id='coupon-web' onclick="copyCoupon()">XXX</p>
  326. <a class="copy" href="javascript:void(0)" onclick="copyCoupon()">(点击复制券码)</a>
  327. </div>
  328. <a id="public-web-jump-button" href="javascript:void(0)" style="background-color: #ce3406;"
  329. class="weui-btn weui-btn_primary weui-btn_loading" onclick="openWeapp()">
  330. 一键绑定兑换券
  331. </a>
  332. <!-- 使用说明 -->
  333. <div class="read">
  334. <div class="title">
  335. <hr />
  336. <div class="line">使用说明</div>
  337. </div>
  338. <p class="header">*绑定兑换券</p>
  339. <p class="content">复制兑换券券码——>点击“一键绑定兑换券”——>直接打开【鲸致生活小程序】——>进入“优惠券”——>黏贴兑换券券码——>完成绑定</p>
  340. <p class="header" style="margin-top: 10px;">*支付及预约</p>
  341. <p class="content">①成功绑定后,进入小程序【鲸致生活】——我的“优惠券”——选择兑换券</p>
  342. <p class="content">②点击“立即使用”</p>
  343. <p class="content">③按照提示操作预约</p>
  344. <p class="content">④点击“支付”,完成预约及支付</p>
  345. <p class="content">⑤等待服务上门</p>
  346. </div>
  347. </div>
  348. <!--------------------------- 微信浏览器----------------------------------------------------------->
  349. <div id="wechat-web-container" class="hidden">
  350. <div class="top">
  351. <img src="../auto/img/logo.png" width="160px" />
  352. </div>
  353. <div class="coupon">
  354. <p class="label">*点击领取您的专属权益</p>
  355. <p class="goods">鲸致生活3小时居家保洁服务</p>
  356. <p class="coupon-label">兑换码</p>
  357. <p class="coupon-value" id='coupon-wx' onclick="copyCoupon()">XXX</p>
  358. <a class="copy" href="javascript:void(0)" onclick="copyCoupon()">(点击复制券码)</a>
  359. </div>
  360. <!-- <p class="">点击以下按钮打开 “鲸致生活商城”</p> replace -->
  361. <!-- 跳转小程序的开放标签。文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html -->
  362. <wx-open-launch-weapp id="launch-btn" username="gh_e9b9499458d9" path="/pages/ucenter/couponList/couponList">
  363. <!-- replace -->
  364. <template>
  365. <button
  366. style="width: 200px; height: 45px; text-align: center; font-size: 17px; display: block; margin: 0 auto; padding: 8px 24px; border: none; border-radius: 4px; background-color: #ce3406; color:#fff;">
  367. 一键绑定兑换券</button>
  368. </template>
  369. </wx-open-launch-weapp>
  370. <!-- 使用说明 -->
  371. <div class="read">
  372. <div class="title">
  373. <hr />
  374. <div class="line">使用说明</div>
  375. </div>
  376. <p class="header">*绑定兑换券</p>
  377. <p class="content">复制兑换券券码——>点击“一键绑定兑换券”——>直接打开【鲸致生活小程序】——>进入“优惠券”——>黏贴兑换券券码——>完成绑定</p>
  378. <p class="header" style="margin-top: 10px;">*支付及预约</p>
  379. <p class="content">①成功绑定后,进入小程序【鲸致生活】——我的“优惠券”——选择兑换券</p>
  380. <p class="content">②点击“立即使用”</p>
  381. <p class="content">③按照提示操作预约</p>
  382. <p class="content">④点击“支付”,完成预约及支付</p>
  383. <p class="content">⑤等待服务上门</p>
  384. </div>
  385. </div>
  386. <!-- pc端打开提醒 -->
  387. <div id="desktop-web-container" class="hidden">
  388. <div class="top">
  389. <img src="../auto/img/logo.png" width="160px" />
  390. </div>
  391. <p class="" style="margin-top: 30px;">请在手机打开网页链接</p>
  392. </div>
  393. </div>
  394. </body>
  395. </html>