123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- <html>
- <head>
- <title>鲸致生活</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
- <script>
- window.onerror = e => {
- console.error(e)
- alert('发生错误' + e)
- }
- </script>
- <!-- weui 样式 -->
- <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.1/weui.min.css">
- </link>
- <!-- 调试用的移动端 console -->
- <script src="../mall/js/jquery-1.7.2.min.js"></script>
- <!-- 公众号 JSSDK -->
- <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
- <!-- 云开发 Web SDK -->
- <script src="https://res.wx.qq.com/open/js/cloudbase/1.1.0/cloud.js"></script>
- <script>
- function docReady(fn) {
- if (document.readyState === 'complete' || document.readyState === 'interactive') {
- fn()
- } else {
- document.addEventListener('DOMContentLoaded', fn);
- }
- }
- docReady(async function () {
- var ua = navigator.userAgent.toLowerCase()
- var isWXWork = ua.match(/wxwork/i) == 'wxwork'
- var isWeixin = !isWXWork && ua.match(/micromessenger/i) == 'micromessenger'
- var isMobile = false
- var isDesktop = false
- if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i)) {
- isMobile = true
- } else {
- isDesktop = true
- }
- //设置优惠券值
- setCouponValue();
- if (isWeixin) {
- console.info('微信浏览器')
- var containerEl = document.getElementById('wechat-web-container')
- containerEl.classList.remove('hidden')
- containerEl.classList.add('full', 'wechat-web-container')
- var launchBtn = document.getElementById('launch-btn')
- launchBtn.addEventListener('ready', function (e) {
- console.log('开放标签 ready')
- //alert('开放标签 ready')
- })
- launchBtn.addEventListener('launch', function (e) {
- console.log('开放标签 success')
- //alert('开放标签 success')
- })
- launchBtn.addEventListener('error', function (e) {
- console.log('开放标签 fail', e.detail)
- //alert(e.detail)
- })
- wx.config({
- //debug: true, // 调试时可开启
- appId: 'wxf0a77f9993d8b60d', // <!-- replace -->
- timestamp: 0, // 必填,填任意数字即可
- nonceStr: 'nonceStr', // 必填,填任意非空字符串即可
- signature: 'signature', // 必填,填任意非空字符串即可
- jsApiList: ['chooseImage'], // 必填,随意一个接口即可
- openTagList: ['wx-open-launch-weapp'], // 填入打开小程序的开放标签名
- })
- } else if (isDesktop) {
- // 在 pc 上则给提示引导到手机端打开
- var containerEl = document.getElementById('desktop-web-container')
- containerEl.classList.remove('hidden')
- containerEl.classList.add('full', 'desktop-web-container')
- } else {
- console.info('手机浏览器')
- var containerEl = document.getElementById('public-web-container')
- containerEl.classList.remove('hidden')
- containerEl.classList.add('full', 'public-web-container')
- var c = new cloud.Cloud({
- // 必填,表示是未登录模式
- identityless: true,
- // 资源方 AppID
- resourceAppid: 'wxf0a77f9993d8b60d', // <!-- replace -->
- // 资源方环境 ID
- resourceEnv: 'zhaijieshi-3guecm78383ca692', // <!-- replace -->
- })
- await c.init()
- window.c = c
- var buttonEl = document.getElementById('public-web-jump-button')
- var buttonLoadingEl = document.getElementById('public-web-jump-button-loading')
- try {
- // await openWeapp(() => {
- // buttonEl.classList.remove('weui-btn_loading')
- // buttonLoadingEl.classList.add('hidden')
- // })
- } catch (e) {
- buttonEl.classList.remove('weui-btn_loading')
- buttonLoadingEl.classList.add('hidden')
- throw e
- }
- }
- })
- async function openWeapp(onBeforeJump) {
- var c = window.c
- const res = await c.callFunction({
- name: 'public',
- data: {
- action: 'getUrlScheme',
- },
- })
- console.warn(res)
- if (onBeforeJump) {
- onBeforeJump()
- }
- location.href = res.result.openlink
- }
- //复制券码
- function copyCoupon() {
- var value = getQueryString("no");
- if (value == null) return;
- const input = document.createElement('input');
- document.body.appendChild(input);
- input.setAttribute('value', value);
- input.select();
- if (document.execCommand('copy')) {
- document.execCommand('copy');
- showCopySuccess('复制成功');
- }
- document.body.removeChild(input);
- }
- //显示复制成功
- function showCopySuccess(msg) {
- //赋值
- document.getElementById('spanMsg').innerHTML = msg;
- const copySuccess = document.getElementById('copySuccess');
- copySuccess.classList.remove('hidden');
- setTimeout(() => {
- const copySuccess = document.getElementById('copySuccess');
- copySuccess.classList.add('hidden', 'copySuccess')
- }, 2000);
- }
- function setCouponValue() {
- const coupon = getQueryString("no") == null ? '无效券号' : getQueryString("no");
- document.getElementById("coupon-wx").innerHTML = coupon;
- document.getElementById("coupon-web").innerHTML = coupon;
- //获取码对应的商品名称
- let url = "https://mall.zhaijieshi.cc/admin/coupon/getGoodsName?coupon=" + coupon;
- $.ajax({
- type: 'get',
- dataType: "json",
- url: url,
- cache: false,
- async: false,
- success: function (data) {
- if (data.errno == 0) {
- $('.goods').html(data.data);
- }
- else{
- $('.goods').html('无效券码');
- $("#coupon-wx").innerHTML = coupon+'(无效券码)';
- $("#coupon-web").innerHTML = coupon+'(无效券码)';
- $('.copy').hide();
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- }
- });
- }
- //获取url参数
- function getQueryString(name) {
- var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
- var r = window.location.search.substr(1).match(reg);
- if (r != null) {
- return unescape(r[2]);
- }
- return null;
- }
- </script>
- <style>
- .hidden {
- display: none;
- }
- .full {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- }
- .public-web-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- /* .public-web-container p {
- position: absolute;
- top: 40%;
- } */
- .public-web-container a {
- /*position: absolute;
- bottom: 40%; */
- margin-top: 30px;
- }
- .wechat-web-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- /* .wechat-web-container p {
- position: absolute;
- top: 40%;
- } */
- .wechat-web-container wx-open-launch-weapp {
- /* height: 45px;
- color:#fff;
- background-color: #ce3406;
- margin-top: 30px;*/
- position: absolute;
- bottom: 40%;
- left: 0;
- right: 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .desktop-web-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- /* .desktop-web-container p {
- position: absolute;
- top: 40%;
- } */
- .top {
- height: 160px;
- background-color: #09AFFF;
- text-align: center;
- width: 100%;
- }
- .coupon {
- text-align: center;
- width: 100%;
- }
- .coupon .label {
- text-align: left;
- margin-left: 5px;
- margin-top: 5px;
- position: unset;
- font-size: 12px;
- }
- .coupon .goods {
- font-size: 24px;
- font-weight: 700;
- position: unset;
- margin-top: 10px;
- margin-bottom: 10px;
- }
- .coupon-label {
- font-size: 17px;
- font-weight: 300;
- position: unset;
- }
- .coupon-value {
- font-size: 18px;
- font-weight: 500;
- position: unset;
- }
- .copy {
- color: #09AFFF;
- position: unset !important;
- }
- .read {
- padding: 0 10px;
- font-size: 13px;
- position: absolute;
- bottom: 10px;
- }
- .read .title {
- text-align: center;
- }
- .read .header {
- font-weight: 600;
- }
- .read .content {
- font-size: 11px;
- }
- .line {
- position: relative;
- width: 100px;
- top: -15px;
- text-align: center;
- background-color: #fff;
- margin: 0 auto;
- }
- .message {
- position: absolute;
- top: 40%;
- z-index: 999;
- color: #fff;
- background-color: #999;
- text-align: center;
- left: 50%;
- transform: translate(-50%, -50%);
- padding: 10px;
- border-radius: 5px;
- }
- </style>
- </head>
- <body>
- <div class="page full">
- <!-- 复制成功提醒 -->
- <div id='copySuccess' class="message hidden">
- <span id='spanMsg'>复制成功</span>
- </div>
- <!--------------------------- 手机浏览器----------------------------------------------------------->
- <div id="public-web-container" class="hidden">
- <div class="top">
- <img src="../mall/img/logo.png" width="160px" />
- </div>
- <div class="coupon">
- <p class="label">*点击领取您的专属权益</p>
- <p class="goods">鲸致生活3小时居家保洁服务</p>
- <p class="coupon-label">兑换码</p>
- <p class="coupon-value" id='coupon-web' onclick="copyCoupon()">XXX</p>
- <a class="copy" href="javascript:void(0)" onclick="copyCoupon()">(点击复制券码)</a>
- </div>
- <a id="public-web-jump-button" href="javascript:void(0)" style="background-color: #ce3406;"
- class="weui-btn weui-btn_primary weui-btn_loading" onclick="openWeapp()">
- 一键绑定兑换券
- </a>
- <!-- 使用说明 -->
- <div class="read">
- <div class="title">
- <hr />
- <div class="line">使用说明</div>
- </div>
- <p class="header">*绑定兑换券</p>
- <p class="content">复制兑换券券码——>点击“一键绑定兑换券”——>直接打开【鲸致生活小程序】——>进入“优惠券”——>黏贴兑换券券码——>完成绑定</p>
- <p class="header" style="margin-top: 10px;">*支付及预约</p>
- <p class="content">①成功绑定后,进入小程序【鲸致生活】——我的“优惠券”——选择兑换券</p>
- <p class="content">②点击“立即使用”</p>
- <p class="content">③按照提示操作预约</p>
- <p class="content">④点击“支付”,完成预约及支付</p>
- <p class="content">⑤等待服务上门</p>
- </div>
- </div>
- <!--------------------------- 微信浏览器----------------------------------------------------------->
- <div id="wechat-web-container" class="hidden">
- <div class="top">
- <img src="../auto/img/logo.png" width="160px" />
- </div>
- <div class="coupon">
- <p class="label">*点击领取您的专属权益</p>
- <p class="goods">鲸致生活3小时居家保洁服务</p>
- <p class="coupon-label">兑换码</p>
- <p class="coupon-value" id='coupon-wx' onclick="copyCoupon()">XXX</p>
- <a class="copy" href="javascript:void(0)" onclick="copyCoupon()">(点击复制券码)</a>
- </div>
- <!-- <p class="">点击以下按钮打开 “鲸致生活商城”</p> replace -->
- <!-- 跳转小程序的开放标签。文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html -->
- <wx-open-launch-weapp id="launch-btn" username="gh_e9b9499458d9" path="/pages/ucenter/couponList/couponList">
- <!-- replace -->
- <template>
- <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;">
- 一键绑定兑换券</button>
- </template>
- </wx-open-launch-weapp>
- <!-- 使用说明 -->
- <div class="read">
- <div class="title">
- <hr />
- <div class="line">使用说明</div>
- </div>
- <p class="header">*绑定兑换券</p>
- <p class="content">复制兑换券券码——>点击“一键绑定兑换券”——>直接打开【鲸致生活小程序】——>进入“优惠券”——>黏贴兑换券券码——>完成绑定</p>
- <p class="header" style="margin-top: 10px;">*支付及预约</p>
- <p class="content">①成功绑定后,进入小程序【鲸致生活】——我的“优惠券”——选择兑换券</p>
- <p class="content">②点击“立即使用”</p>
- <p class="content">③按照提示操作预约</p>
- <p class="content">④点击“支付”,完成预约及支付</p>
- <p class="content">⑤等待服务上门</p>
- </div>
- </div>
- <!-- pc端打开提醒 -->
- <div id="desktop-web-container" class="hidden">
- <div class="top">
- <img src="../auto/img/logo.png" width="160px" />
- </div>
- <p class="" style="margin-top: 30px;">请在手机打开网页链接</p>
- </div>
- </div>
- </body>
- </html>
|