cp.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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"></link>
  14. <!-- 调试用的移动端 console -->
  15. <!-- <script src="https://cdn.jsdelivr.net/npm/eruda"></script> -->
  16. <!-- <script>eruda.init();</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. //获取url参数
  148. function getQueryString(name) {
  149. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  150. var r = window.location.search.substr(1).match(reg);
  151. if (r != null) {
  152. return unescape(r[2]);
  153. }
  154. return null;
  155. }
  156. </script>
  157. <style>
  158. .hidden {
  159. display: none;
  160. }
  161. .full {
  162. position: absolute;
  163. top: 0;
  164. bottom: 0;
  165. left: 0;
  166. right: 0;
  167. }
  168. .public-web-container {
  169. display: flex;
  170. flex-direction: column;
  171. align-items: center;
  172. }
  173. /* .public-web-container p {
  174. position: absolute;
  175. top: 40%;
  176. } */
  177. .public-web-container a {
  178. /*position: absolute;
  179. bottom: 40%; */
  180. margin-top: 30px;
  181. }
  182. .wechat-web-container {
  183. display: flex;
  184. flex-direction: column;
  185. align-items: center;
  186. }
  187. /* .wechat-web-container p {
  188. position: absolute;
  189. top: 40%;
  190. } */
  191. .wechat-web-container wx-open-launch-weapp {
  192. /* height: 45px;
  193. color:#fff;
  194. background-color: #ce3406;
  195. margin-top: 30px;*/
  196. position: absolute;
  197. bottom: 40%;
  198. left: 0;
  199. right: 0;
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. }
  204. .desktop-web-container {
  205. display: flex;
  206. flex-direction: column;
  207. align-items: center;
  208. }
  209. /* .desktop-web-container p {
  210. position: absolute;
  211. top: 40%;
  212. } */
  213. .top{
  214. height: 160px;
  215. background-color: #09AFFF;
  216. text-align: center;
  217. width:100%;
  218. }
  219. .coupon{
  220. text-align: center;
  221. width: 100%;
  222. }
  223. .coupon .label{
  224. text-align: left;
  225. margin-left: 5px;
  226. margin-top: 5px;
  227. position: unset;
  228. font-size: 12px;
  229. }
  230. .coupon .goods{
  231. font-size: 24px;
  232. font-weight: 700;
  233. position: unset;
  234. margin-top: 10px;
  235. margin-bottom: 10px;
  236. }
  237. .coupon-label{
  238. font-size: 17px;
  239. font-weight: 300;
  240. position: unset;
  241. }
  242. .coupon-value{
  243. font-size: 18px;
  244. font-weight: 500;
  245. position: unset;
  246. }
  247. .copy{
  248. color: #09AFFF;
  249. position: unset !important;
  250. }
  251. .read{
  252. padding: 0 10px;
  253. font-size: 13px;
  254. position: absolute;
  255. bottom: 10px;
  256. }
  257. .read .title{
  258. text-align: center;
  259. }
  260. .read .header{
  261. font-weight: 600;
  262. }
  263. .read .content{
  264. font-size: 11px;
  265. }
  266. .line{
  267. position: relative;
  268. width: 100px;
  269. top: -15px;
  270. text-align: center;
  271. background-color: #fff;
  272. margin: 0 auto;
  273. }
  274. .message{
  275. position: absolute;
  276. top: 40%;
  277. z-index: 999;
  278. color: #fff;
  279. background-color: #999;
  280. text-align: center;
  281. left: 50%;
  282. transform: translate(-50%,-50%);
  283. padding: 10px;
  284. border-radius: 5px;
  285. }
  286. </style>
  287. </head>
  288. <body>
  289. <div class="page full">
  290. <!-- 复制成功提醒 -->
  291. <div id='copySuccess' class="message hidden">
  292. <span id='spanMsg'>复制成功</span>
  293. </div>
  294. <!--------------------------- 手机浏览器----------------------------------------------------------->
  295. <div id="public-web-container" class="hidden">
  296. <div class="top">
  297. <img src="../mall/img/logo.png" width="160px"/>
  298. </div>
  299. <div class="coupon">
  300. <p class="label">*点击领取您的专属权益</p>
  301. <p class="goods">鲸致生活3小时居家保洁服务</p>
  302. <p class="coupon-label">兑换码</p>
  303. <p class="coupon-value" id='coupon-web'>XXX</p>
  304. <a class="copy" href="javascript:void(0)" onclick="copyCoupon()">(点击复制券码)</a>
  305. </div>
  306. <a id="public-web-jump-button" href="javascript:void(0)" style="background-color: #ce3406;"
  307. class="weui-btn weui-btn_primary weui-btn_loading" onclick="openWeapp()">
  308. 一键绑定兑换券
  309. </a>
  310. <!-- 使用说明 -->
  311. <div class="read">
  312. <div class="title">
  313. <hr/>
  314. <div class="line">使用说明</div>
  315. </div>
  316. <p class="header">*绑定兑换券</p>
  317. <p class="content">复制兑换券券码——>点击“一键绑定兑换券”——>直接打开【鲸致生活小程序】——>进入“优惠券”——>黏贴兑换券券码——>完成绑定</p>
  318. <p class="header" style="margin-top: 10px;">*支付及预约</p>
  319. <p class="content">①成功绑定后,进入小程序【鲸致生活】——我的“优惠券”——选择“上汽乘用车员工专属产品XXX”兑换券</p>
  320. <p class="content">②点击“立即使用”</p>
  321. <p class="content">③按照提示操作预约</p>
  322. <p class="content">④点击“支付”,完成预约及支付</p>
  323. <p class="content">⑤等待服务上门</p>
  324. </div>
  325. </div>
  326. <!--------------------------- 微信浏览器----------------------------------------------------------->
  327. <div id="wechat-web-container" class="hidden">
  328. <div class="top">
  329. <img src="../mall/img/logo.png" width="160px"/>
  330. </div>
  331. <div class="coupon">
  332. <p class="label">*点击领取您的专属权益</p>
  333. <p class="goods">鲸致生活3小时居家保洁服务</p>
  334. <p class="coupon-label">兑换码</p>
  335. <p class="coupon-value" id='coupon-wx'>XXX</p>
  336. <a class="copy" href="javascript:void(0)" onclick="copyCoupon()">(点击复制券码)</a>
  337. </div>
  338. <!-- <p class="">点击以下按钮打开 “鲸致生活商城”</p> replace -->
  339. <!-- 跳转小程序的开放标签。文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html -->
  340. <wx-open-launch-weapp id="launch-btn" username="gh_e9b9499458d9" path="/pages/ucenter/couponList/couponList"> <!-- replace -->
  341. <template>
  342. <button 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;">
  343. 一键绑定兑换券</button>
  344. </template>
  345. </wx-open-launch-weapp>
  346. <!-- 使用说明 -->
  347. <div class="read">
  348. <div class="title">
  349. <hr/>
  350. <div class="line">使用说明</div>
  351. </div>
  352. <p class="header">*绑定兑换券</p>
  353. <p class="content">复制兑换券券码——>点击“一键绑定兑换券”——>直接打开【鲸致生活小程序】——>进入“优惠券”——>黏贴兑换券券码——>完成绑定</p>
  354. <p class="header" style="margin-top: 10px;">*支付及预约</p>
  355. <p class="content">①成功绑定后,进入小程序【鲸致生活】——我的“优惠券”——选择“上汽乘用车员工专属产品XXX”兑换券</p>
  356. <p class="content">②点击“立即使用”</p>
  357. <p class="content">③按照提示操作预约</p>
  358. <p class="content">④点击“支付”,完成预约及支付</p>
  359. <p class="content">⑤等待服务上门</p>
  360. </div>
  361. </div>
  362. <!-- pc端打开提醒 -->
  363. <div id="desktop-web-container" class="hidden">
  364. <div class="top">
  365. <img src="../mall/img/logo.png" width="160px"/>
  366. </div>
  367. <p class="" style="margin-top: 30px;">请在手机打开网页链接</p>
  368. </div>
  369. </div>
  370. </body>
  371. </html>