123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta content="yes" name="apple-mobile-web-app-capable">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0"
- />
- <title>天猫女王节</title>
- <link rel="stylesheet" href="../common/reset.css">
- <script type="text/javascript">
- document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth / 375) + "px";
- window.onresize = function () {
- document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth / 375) + "px";
- }
- </script>
- <style>
- body {min-height: 100vh;background-image: url("https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/H5-liedou/newRedEnvelopes/queen.jpg");background-size: 100% 100%;position: relative;}
- .list {
- background-size: 100% 100%;
- width: 100%;
- padding: 0 .15rem;
- position: absolute;
- left: 50%;
- top: 85%;
- transform: translate(-50%,0);
- display: flex;
- justify-content: space-around;
- align-items: center;
- box-sizing: border-box;
- }
- .button {background-size: 100% 100%;width: 1.4rem;}
- #copy_1,#copy_2,#taokouling{position: absolute;left: -1000rem;}
- .mask {width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background: rgba(0,0,0,.6);display: none;}
- .toast {width: 3.11rem;height: 2rem;background: #fff;border-radius: .11rem;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);text-align: center;}
- .icon {display: inline-block;width: .85rem;height: .49rem;margin-top: .21rem;}
- p {font-size: .18rem;line-height: .25rem;color: #333333;margin-top: .14rem;margin-bottom: .18rem;font-weight: bold;}
- span {font-size: .14rem;line-height: .2rem;display: block;}
- .exit {width: .26rem;height: .37rem;position: absolute;right: .2rem;top: -.37rem;}
- .exit .img {width: .26rem;height: .26rem;background-image: url(./img/exit.png);background-size: 100% 100%;}
- .exit span {width: .01rem;height: .11rem;display: block;background: #fff;margin: auto;}
- .alert-info {position: fixed;top: 1.74rem;right: 0;left: 0;bottom: 0;text-align: center;z-index: 2;}
- .alert-info p {display: inline-block;height: 0.38rem;color: #fff;font-size: 0.14rem;line-height: 0.38rem;padding: 0 0.10rem;background-color: rgba(0, 0, 0, 0.7);border-radius: 5px;}
- </style>
- </head>
- <body>
- <input id="copy_1" type="text" readOnly="true" value=""/>
- <div id="copy_2"></div>
- <text id="taokouling"></text>
- <div class="list">
- <img class="button" onclick="toTaobao()" src="./img/button.png">
- <img class="button" onclick="copyPassword()" src="./img/share.png" alt="">
- </div>
- <div class="mask">
- <div class="toast">
- <div class="exit">
- <div class="img" onclick="exit()"></div>
- <span></span>
- </div>
- <img class="icon" src="./img/icon.png" alt="">
- <p>淘口令复制成功</p>
- <span>分享给好友领红包赚钱吧~</span>
- </div>
- </div>
- <div class="alert-info" style="display: none;">
- <!-- tip提示,3s后消失 -->
- <p></p>
- </div>
- <script src="../common/jquery-2.1.0.js"></script>
- <script>
- var token=''
- var tbUrl=''
- $().ready(function () {
- getToken()
- })
-
- // 获取token
- function getToken() {
- var param = {
- "js_callback" : "callbackLogin"
- };
- param = JSON.stringify(param)
- try {
- if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
- window.webkit.messageHandlers.app_h5_login.postMessage(param);
- }
- if (navigator.userAgent.match(/android/i)) {
- obj4H5.app_h5_login(param);
- }
- } catch (e) {
- // token='4f422467a11afa2cedaa593686f9b1d4257657'
- // todayTbkPassword()
- }
- }
- function callbackLogin(data) {//app token 回调
- var data = JSON.parse(data); //上线时添加
- token=data.token; //上线时添加
- if(token) {
- todayTbkPassword()
- }
- }
- //获取淘口令
- function todayTbkPassword(type) {
- if(token) {
- $.ajax({
- type: "post",
- url: "/api/v2/adzone/double12taoToken",
- typeData: 'json',
- headers:{
- token:token
- },
- success: function (res) {
- if (res && res.errno == 0) {
- var tkl=res.rst.data.wenan
- tbUrl=res.rst.data.m_url
- $("#taokouling").text(tkl);
- }else {
- showMsg(res.err)
- }
- }
- });
- }else {
- getToken();
- }
-
- }
- // 复制文字
- function copyPassword() {
- if(token) {
- var data = document.getElementById("taokouling").innerHTML;
- copy_2.innerHTML = data;
- copy_1.value = data;
- if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
- //区分iPhone设备
- window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
- var Url2 = document.getElementById("copy_2");//要复制文字的节点
- var range = document.createRange();
- // 选中需要复制的节点
- range.selectNode(Url2);
- // 执行选中元素
- window.getSelection().addRange(range);
- // 执行 copy 操作
- var successful = document.execCommand('copy');
- // 移除选中的元素
- window.getSelection().removeAllRanges();
- } else {
- var Url2 = document.getElementById("copy_1");//要复制文字的节点
- Url2.select(); // 选择对象
- document.execCommand("Copy"); // 执行浏览器复制命令
- }
- $(".mask").show()
- }else {
- getToken()
- }
- }
- // 打开淘宝
- function toTaobao() {
- if(token) {
- var param = {
- "taobaoUrl" : tbUrl,//淘宝链接
- }
- param = JSON.stringify(param)
- try {
- if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
- window.webkit.messageHandlers.app_h5_open_taobao_url.postMessage(param);
- }
- if(navigator.userAgent.match(/android/i)){
- obj4H5.app_h5_open_taobao_url(param);
- }
- } catch (error) {
- }
- }else {
- getToken()
- }
-
- }
- function exit(){
- $(".mask").hide();
- }
- function showMsg(msg) {
- //弹框
- var msgBox = document.getElementsByClassName('alert-info')[0];
- msgBox.children[0].innerText = msg;
- msgBox.style.display="block";
- setTimeout(function() {
- msgBox.style.display="none";
- }, 1500);
- }
- </script>
- </body>
- </html>
|