123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="x5-orientation" content="portrait" />
- <meta name="screen-orientation" content="portrait" />
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <!-- 删除苹果默认的工具栏和菜单栏 -->
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <!-- 设置苹果工具栏颜? -->
- <meta name="format-detection" content="telphone=no, email=no">
- <!-- 忽略页面中的数字识别为电话,忽略email识别 -->
- <!-- 启用360浏览器的极速模?(webkit) -->
- <meta name="renderer" content="webkit">
- <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑? -->
- <meta name="HandheldFriendly" content="true">
- <!-- 微软的老式浏览? -->
- <meta name="MobileOptimized" content="320">
- <!-- 不能旋转,问题出在这 -->
- <!-- UC强制全屏 -->
- <meta name="full-screen" content="yes">
- <!-- QQ强制全屏 -->
- <meta name="x5-fullscreen" content="true">
- <!-- UC应用模式 -->
- <meta name="browsermode" content="application">
- <!-- QQ应用模式 -->
- <meta name="x5-page-mode" content="app">
- <!-- windows phone 点击无高? -->
- <meta name="msapplication-tap-highlight" content="no">
- <link rel="stylesheet" type="text/css" href="css/WXtrialInterface.css" />
- <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css" />
- <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css" />
- <style>
- .try-use-wrap, .buy-phone-wrap, .look-wrap{
- width: 100%;
- height: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 9999;
- background: rgba(0, 0, 0, 0.5);
- display: none;
- }
- .try-use-container {
- width: 80%;
- height: 409px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: #FFFFFF;
- border-radius: 0.66em;
- }
- .time-close-wrap {
- width: 5.46em;
- height: 2em;
- line-height: 2em;
- text-align: center;
- position: absolute;
- top: 0.24em;
- right: 0.3em;
- background: rgba(0, 0, 0, 0.49);
- border-radius: 1.26em;
- font-size: 12px;
- color: #FFFFFF;
- }
- .bug-wrap {
- width: 90%;
- height: 115px;
- background: #FFFFFF;
- border-radius: 10px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- }
- .bug-title {
- text-align: center;
- margin: 25px 0;
- font-size: 18px;
- font-weight: 600;
- color: #333333;
- }
- .btn-list {
- width: 100%;
- height: 44px;
- line-height: 44px;
- border-top: 1px solid rgba(238, 238, 238, 1);
- position: absolute;
- bottom: 0;
- left: 0;
- display: flex;
- align-items: center;
- }
- .btn {
- flex: 1;
- text-align: center;
- }
- .cannel-btn {
- font-size: 18px;
- color: #666666;
- }
- .go-bug {
- font-size: 18px;
- color: #3B7FFF;
- border-left: 1px solid rgba(238, 238, 238, 1);
- }
- </style>
- </head>
- <body class="scroll h-player" style="overscroll-behavior: contain;">
- <div class="container" id="player">
- <div class="muted" id="btnMuted">
- <div class="control-right-img" data-id="1">
- <img src="../static/img/xuanfu_icon.png">
- </div>
- </div>
- <div id="wine">
- <video id="playerVideo" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
- webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false"
- style="pointer-events: none;object-fit: fill;width: 100%;height:100%"></video>
- <div id="box"></div>
- <audio preload="auto" autoplay controls poster="images/loader-thumb.jpg" id="audioPlayer"
- style="position: absolute;top: 0;width: 0;height: 0;"></audio>
- </div>
- <div class="leftmains">
- <div class="PictureQualityMain">
- <div class="PictureQuality" data-id="4">高清</div>
- <div class="PictureQuality avit" data-id="3">标清</div>
- <div class="PictureQuality" data-id="2">极速</div>
- </div>
- <div class="operation">
- <div class="upload" id="showsuss" data-text="uploads">
- <img src="../static/img/wx/shangchuan_icon.png">
- <div>上传</div>
- </div>
- <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
- <img src="../static/img/wx/jianqieban_icon.png">
- <div>剪贴板</div>
- </div>
- <div class="upload" id="upload" data-text="Signout">
- <img src="../static/img/wx/tuichu_icon.png">
- <div>退出</div>
- </div>
- </div>
- </div>
- <div class="bottommains">
- <div class="botmat1">
- <div class="botmat1img" data-text="gengduo">
- <img src="../static/img/wx/gengduo_icon.png">
- </div>
- </div>
- <div class="botmat1">
- <div class="botmat1img" data-text="home">
- <img src="../static/img/wx/home_icon.png">
- </div>
- </div>
- <div class="botmat1">
- <div class="botmat1img" data-text="return">
- <img src="../static/img/wx/fanhui_icon.png">
- </div>
- </div>
- </div>
- <img class="loading loading_sceen_pic" />
- </div>
- <div class="mask">
- <div class="box-shear-plate"></div>
- <img class="close" onclick="handleClose()" src="img/guanbi_icon@2x.png" alt="">
- </div>
- <div class="weui-mask_transparent"></div>
- <div class="weui-toast weui_loading_toast weui-toast--visible">
- <div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div>
- <p class="weui-toast_content">数据加载中</p>
- </div>
- <div class="try-use-wrap">
- <div class="try-use-container">
- <video width="100%" height="100%" id="source" muted autoplay="autoplay" loop="loop">
- 您的浏览器不支持 video 标签。
- </video>
- <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
- </div>
- </div>
- <div class="buy-phone-wrap">
- <div class="bug-wrap">
- <div class="bug-title">获得极致体验服务请购买云手机</div>
- <div class="btn-list">
- <div class="btn cannel-btn">取消</div>
- <div class="btn go-bug">去购买</div>
- </div>
- </div>
- </div>
- <div class="look-wrap">
- <div class="bug-wrap">
- <div class="bug-title">关闭广告会退出云手机是否继续观看</div>
- <div class="btn-list">
- <div class="btn cannel-btn cannel-ad-btn">放弃</div>
- <div class="btn go-bug looking">继续观看</div>
- </div>
- </div>
- </div>
- <body oncontextmenu="Back()">
- </body>
- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
- <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
- <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
- <script type="text/javascript" src="helper.js"></script>
- <script type="text/javascript" src="pcm-player.js"></script>
- <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
- <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
- <script type="text/javascript" src="WXdraw.js"></script>
- <script type="text/javascript" src="jmuxer.js"></script>
- <script type="text/javascript" src="spsParser.js"></script>
- <script type="text/javascript" src="https://unpkg.com/@dcloudio/uni-webview-js@0.0.2/index.js"></script>
- <script>
- var url = window.location.href;
- url = url.split('/');
- var baseUrl = url[0] + '//' + url[2];
- var parameters = GetRequest();
- var form = {};
- form.token = parameters['token'];
- form.userCardId = parameters['userCardId'];
- var videoTimer = null, videoTime = 0, adType = 0, sourceType = 0, disconnectionFlag = false, getDate = false;
- if (parameters['mealType'] === 'VIP') {
- $(".loading_sceen_pic").attr('src', '../static/img/home_bg_VIP.png');
- } else if (parameters['mealType'] === 'SVIP') {
- $(".loading_sceen_pic").attr('src', '../static/img/home_bg_SVIP.png');
- } else if (parameters['mealType'] === 'STAR') {
- $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STAR.png');
- } else if (parameters['mealType'] === 'STARPRO') {
- $(".loading_sceen_pic").attr('src', '../static/img/home_bg_PRO.png');
- }
- adInit();
- var isAudioPlay = false;
- if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
- var video = document.getElementById("playerVideo");
- video.play();
- setTimeout(() => { // 抖音环境需要设置延时,不然会有video默认图显示
- $.alert({
- title: '提示',
- text: '开始使用云手机',
- onOK: function () {
- setTimeout(() => {
- isAudioPlay = true;
- }, 1000);
- }
- });
- }, 1000)
- } else {
- $.alert({
- title: '提示',
- text: '开始使用云手机',
- onOK: function () {
- var video = document.getElementById("playerVideo");
- video.play();
- isAudioPlay = true;
- }
- });
- }
- //云机倒计时
- let validTime = parameters['validTime'] || 10000;
- if (validTime > 32000) {
- validTime = 32000
- }
- let detailTime = validTime * 60 * 1000;
- setTimeout(() => {
- $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
- getDate = true;
- $('.buy-phone-wrap').eq(0).show();
- }, detailTime)
- var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
- $('#wine').css({
- "width": window.screen.width,
- "height": window.screen.height - topwinHeight - 20,
- "position": "absolute"
- });
- $('.loading').css({
- "width": window.screen.width,
- "height": window.screen.height - topwinHeight - 20
- });
- var winese = document.createElement("wine");
- wine.style.top = "-" + winese + 'px';
- var isVisuable = true;
- var isFeed = true;
- var isFinish = false;
- var isWaitSps = false;
- var myVideo = document.getElementById("playerVideo");
- Module = {};
- Module.onRuntimeInitialized = function () {
- isFinish = true;
- }
- var isWSS = true;
- var ip = parameters["ip"];
- var cardToken = parameters["cardToken"];
- cardToken = cardToken && decodeURIComponent(cardToken);
- var appletPushAddress = parameters["appletPushAddress"];
- var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken + "&type=business" : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
- var jmuxer = new JMuxer({
- node: 'playerVideo',
- flushingTime: 33,
- fps: 30,
- mode: 'video',
- debug: false
- });
- window.onload = function () {
- var myPlay = document.getElementById("wine");
- myPlay.onkeydown = function (event) {
- ExexuteKeyDown(e.keyCode);
- }
- }
- var ws, errorTime = 0;
- doConnect();
- // 节流
- // 设置一个标志
- function throttle(fn, delay) {
- let flag = true;
- errorTime += delay;
- return () => {
- if (!flag) return;
- flag = false;
- timer = setTimeout(() => {
- fn();
- flag = true;
- }, delay);
- };
- }
- var intervaler;
- function doConnect() {
- ws = new WebSocket(socketURL);
- ws.binaryType = 'arraybuffer';
- intervaler = setInterval(() => {
- if (ws.readyState === 1) {
- ws.send("ping");
- } else {
- clearInterval(intervaler);
- $.toast("画面异常,请重新进入", "text");
- if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
- tt.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- } else {
- wx.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- }
- }
- }, 3000);
- ws.addEventListener('open', function (event) {
- // sn只要长度满足17位随机数,不需要从后台获取
- var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
- console.log("鉴权报文:" + PrintArry(verifyBuffer));
- ws.send(verifyBuffer);
- });
- ws.addEventListener('error', function (event) {
- ws.close();
- clearInterval(intervaler);
- throttle(doConnect, 100);
- if (errorTime > 1000) {
- $.toast("画面异常,请重新进入", "text");
- wsss.close();
- if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
- tt.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- } else {
- wx.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- }
- }
- });
- ws.addEventListener('message', function (event) {
- var data = ParseProto(event.data); //JAVA服务器转发
- if (isAudioPlay) {
- $('.weui-mask_transparent').hide();
- $('.weui-toast').hide();
- $('.loading').hide();
- }
- var input = new Uint8Array(event.data);
- if (data.audio != null && isAudioPlay) { //喂音频
- if (input[0] == 0xff) {
- if (isFinish) {
- decodeAAC(input);
- }
- }
- }
- if (data.frameType != undefined && data.frameType != 1 && data.frameType != 6) {
- if (data.frameType == 7) {
- let info = spsParser(data.video);
- if (info.width != myVideo.videoWidth && info.height != myVideo.videoHeight) {
- if (myVideo.videoWidth == 0) {
- console.log("SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d", info.width, info.height, myVideo.videoWidth, myVideo.videoHeight);
- }
- }
- }
- }
- if (data.video != null) { //喂视频
- if (data.frameType == 0x05 && isVisuable) {
- isFeed = true;
- }
- if (data.frameType == 7 || data.frameType == 8) {
- isFeed = true;
- isAudioPlay = true;
- isWaitSps = false;
- }
- if (isFeed) {
- if (!isWaitSps) {
- jmuxer.feed(data);
- }
- }
- }
- });
- }
- var hidden, visibilityChange;
- if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
- hidden = "hidden";
- visibilityChange = "visibilitychange";
- } else if (typeof document.msHidden !== "undefined") {
- hidden = "msHidden";
- visibilityChange = "msvisibilitychange";
- } else if (typeof document.webkitHidden !== "undefined") {
- hidden = "webkitHidden";
- visibilityChange = "webkitvisibilitychange";
- }
- // 处理页面可见属性的改变
- document.addEventListener("visibilitychange", function () {
- console.log(document[hidden]);
- if (document[hidden]) {
- if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
- tt.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- } else if (window.__wxjs_environment === 'miniprogram') {
- wx.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- } else {
- document.addEventListener('UniAppJSBridgeReady', function () {
- uni.navigateTo({
- url: '/pages/index/index'
- });
- })
- }
- }
- }, false);
- myVideo.addEventListener('pause', function () {
- isFeed = false;
- });
- var decodeCount = 1;
- var player = new PCMPlayer({
- encoding: '16bitInt',
- channels: 2,
- sampleRate: 44100,
- flushingTime: 22,
- debug: false
- });
- function handleClose() {
- $('.mask').hide();
- }
- function decodeAAC(data) {
- var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
- var inputPtr = Module._malloc(4 * data.length); // 输入数据
- for (var i = 0; i < data.length; i++) {
- Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
- }
- var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
- if (pcmLen >= 0) {
- var pcmData = new Uint8Array(pcmLen);
- for (var i = 0; i < pcmLen; i++) {
- pcmData[i] = Module.HEAPU8[(retPtr) + i]
- }
- player.feed(pcmData);
- }
- decodeCount++;
- Module._free(inputPtr);
- Module._free(retPtr);
- }
- //解协议
- function ParseProto(data) {
- var input = new Uint8Array(data),
- duration,
- video,
- frameType,
- audio;
- if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
- video = input;
- duration = 24;
- var nalType = input[4] & 0x1f;
- frameType = nalType;
- if (!isFeed) {
- if (nalType == 0x05 && isVisuable) {
- isFeed = true;
- }
- }
- } else if (input[0] == 0xff) {
- audio = input;
- duration = 24;
- } else if (input[0] == 0x68) {
- if (input[23] == 0x5c) {
- console.log("收到消息:" + PrintArry(input));
- if (CheckVerifyCode(input)) {
- ws.send(ConfigChannel('RK3923C1201900139'));
- var checkBuffer = GetScreenState();
- ws.send(checkBuffer);
- }
- else {
- $.toast("画面异常,请重新进入", "text");
- clearInterval(intervaler);
- ws.close();
- wsss.close();
- if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
- tt.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- } else {
- wx.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- }
- }
- }
- if (input[23] == 0x05) { //横竖屏标识
- var state = CheckScreenDirection(input.slice(24, 24 + 8));
- if (state == 1) {
- console.log("安卓卡此时竖屏");
- //竖屏处理
- resolving = 1;
- } else {
- console.log("安卓卡此时横屏");
- //横屏处理
- resolving = 0;
- }
- }
- if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
- {
- var jsonobj = checkMultiLoginInfo(input);
- }
- }
- return {
- audio: audio,
- video: video,
- duration: duration,
- frameType: frameType
- };
- }
- function GetRequest() {
- var url = location.search; // 获取url中"?"符后的字串
- var obj = new Object();
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
- }
- }
- return obj;
- }
- function Back() {
- ExexuteKeyDown(4);
- window.event.returnValue = false;
- return false;
- }
- var form = {};
- form.token = parameters['token'];
- form.userCardId = parameters['userCardId'];
- function array_unique(arr) {
- return arr.filter(function (e, i) {
- return arr.indexOf(e) === i;
- })
- }
- var cutList = [];
- let timer, isFlag = true;
- function showShearPlate() {
- if (!isControl) {
- return
- }
- stopManyClick(() => {
- $('.box-shear-plate').empty();
- $.ajax({
- url: baseUrl + "/api/public/v5/shear/content",
- headers: {
- 'Authorization': form.token
- },
- type: 'get',
- dataType: 'json',
- success: function (res) {
- if (res.status === 0) {
- if (res.data.length) {
- cutList = array_unique(res.data)
- var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
- cutList.forEach(function (item) {
- str += "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" + item.content + "\")'>" + item.content + "</div></div><div class='slide-content-button'><button onclick='handleDelete(" + item.id + ")'>删除</button></div></div></div>"
- })
- str += '</div>'
- $('.box-shear-plate').append(str);
- } else {
- $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
- }
- $('.mask').show();
- initSlider();
- } else {
- $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
- $('.mask').show();
- }
- }
- })
- })
- }
- //防止提示一秒内重复显示
- function stopManyClick(fn) {
- if (isFlag) {
- fn();
- }
- isFlag = false;
- if (timer) { clearTimeout(timer); }
- timer = setTimeout(() => { isFlag = true }, 1500);
- }
- // 清空剪贴板
- function handleClear() {
- var ids = '';
- cutList.forEach(function (item) {
- ids += 'ids=' + item.id + '&'
- });
- ids = ids.substring(0, ids.lastIndexOf('&'));
- $.confirm("确定清空剪贴板?", function () {
- $.ajax({
- url: baseUrl + "/api/public/v5/shear/content?" + ids,
- headers: {
- 'Authorization': form.token
- },
- type: 'DELETE',
- dataType: 'json',
- success: function (res) {
- if (res.status === 0) {
- showShearPlate();
- } else {
- $.toast(res.msg, "text");
- }
- }
- })
- });
- }
- function handleCopy(content) {
- var cutting = {
- "type": "cutting",
- "data": {
- "str": content
- }
- };
- wsss.send(JSON.stringify(cutting));
- }
- // 删除剪贴板
- function handleDelete(id) {
- $.ajax({
- url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
- headers: {
- 'Authorization': form.token
- },
- type: 'DELETE',
- dataType: 'json',
- success: function (res) {
- if (res.status === 0) {
- showShearPlate();
- } else {
- $.toast(res.msg, "text");
- }
- }
- })
- }
- function initSlider() {
- //手指滑动多少距离就认为是滑成功
- //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
- var diffXDistance = 50;
- //当前滑动的对象
- var currentObject;
- //上一次滑动的对象
- var lastObject;
- //是否可以左右滑动,在上下滑的时候禁止左右滑
- var canSlide = true;
- //用于记录按下的点
- var startPoint;
- $(".slide-content").css({
- width: $(".slide-wrapper").width()
- });
- document.body.removeEventListener('touchmove', function (e) {
- e.preventDefault()
- }, {
- passive: false
- })
- $(".slide-scroll").css({
- width: $(".slide-wrapper").width() + $(".slide-content-button").width()
- }).on('touchstart', function (e) {
- currentObject = this;
- startPoint = {
- x: e.originalEvent.changedTouches[0].pageX,
- y: e.originalEvent.changedTouches[0].pageY
- };
- }).on('touchmove', function (e) {
- //如果是左右滑动,就禁止上下的滑动
- //如果是上下的滑动,就禁止左右滑动
- if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
- event.preventDefault();
- } else {
- canSlide = false;
- }
- }).on('touchend', function (e) {
- //如果是上下滑动,这里就直接返回了
- if (!canSlide) {
- canSlide = true;
- return true;
- }
- //点击除当前左滑对象之外的任意其他位置
- if (lastObject && currentObject != lastObject) {
- //右滑→
- $(lastObject).removeClass("animate-slide");
- //清空上一个左滑的对象
- lastObject = undefined;
- }
- var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
- if (diffX < -diffXDistance) {
- //左滑←
- $(currentObject).addClass("animate-slide");
- if (lastObject && lastObject != currentObject) {
- //右滑→
- $(lastObject).removeClass("animate-slide");
- }
- //记录上一个左滑的对象
- lastObject = currentObject;
- } else if (diffX >= diffXDistance) {
- if (currentObject == lastObject) {
- //右滑→
- $(currentObject).removeClass("animate-slide");
- //清空上一个左滑的对象
- lastObject = undefined;
- }
- }
- });
- }
- var btnMuted = document.querySelector("#btnMuted");
- btnMuted && (function () {
- var setHistory = function (left, top) {
- try {
- localStorage.setItem("muted-btn-loc", JSON.stringify({
- left: left,
- top: top
- }));
- } catch (ex) { }
- };
- var getHistory = function () {
- try {
- var value = localStorage.getItem("muted-btn-loc");
- if (!value) return null;
- value = JSON.parse(value);
- if (!value) return null;
- return value;
- } catch (ex) {
- return null
- }
- };
- var fixLoc = function (loc) {
- var rect = btnMuted.getBoundingClientRect();
- rect = {
- top: rect.top,
- left: rect.left,
- width: rect.width,
- height: rect.height
- }; //部分低版本浏览器,该属性为只读
- if (loc) {
- rect.left = loc.left;
- rect.top = loc.top;
- }
- var minX = 0;
- var minY = 0;
- var docRect = document.documentElement.getBoundingClientRect();
- var maxY = docRect.height - rect.height;
- var maxX = docRect.width - rect.width;
- var left = rect.left;
- var top = rect.top;
- left = Math.min(left, maxX);
- left = Math.max(left, minX);
- top = Math.min(top, maxY);
- top = Math.max(top, minY);
- if (loc || top !== rect.top || left !== rect.left) {
- btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
- }
- }
- window.addEventListener("resize", function () {
- fixLoc();
- });
- var touchPoint = {
- pageY: 0,
- pageX: 0
- };
- var currentLoc = {
- top: 0,
- left: 0,
- curTop: 0,
- curLeft: 0
- };
- var toMove = false;
- var touchmove = function (e) {
- e.preventDefault();
- var point = e.changedTouches[0];
- var top = -touchPoint.pageY + point.pageY;
- var left = -touchPoint.pageX + point.pageX;
- if (toMove) {
- top += currentLoc.top;
- left += currentLoc.left;
- currentLoc.curLeft = left;
- currentLoc.curTop = top;
- btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
- } else {
- if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
- toMove = true;
- }
- }
- };
- var touchend = function () {
- window.removeEventListener("touchmove", touchmove, {
- passive: false
- });
- window.removeEventListener("touchend", touchend, {
- passive: false
- });
- if (toMove) {
- setHistory(currentLoc.curLeft, currentLoc.curTop);
- fixLoc();
- } else {
- //按点击处理
- var set = $('.control-right-img').attr("data-id")
- if (set == '1') {
- $('.control-right-img').attr({
- "data-id": "2"
- })
- $(".leftmains").css({
- "right": "0rem"
- })
- } else {
- $('.control-right-img').attr({
- "data-id": "1"
- })
- $(".leftmains").css({
- "right": "-4rem"
- })
- }
- }
- }
- btnMuted.addEventListener("touchstart", function (e) {
- e.preventDefault();
- toMove = false;
- var point = e.changedTouches[0];
- touchPoint.pageX = point.pageX;
- touchPoint.pageY = point.pageY;
- var rect = e.target.getBoundingClientRect();
- currentLoc.top = rect.top;
- currentLoc.left = rect.left;
- window.addEventListener("touchmove", touchmove, {
- passive: false
- });
- window.addEventListener("touchend", touchend, {
- passive: false
- });
- }, {
- passive: false
- });
- var history = getHistory();
- if (history) {
- fixLoc(history);
- }
- btnMuted.classList.remove("hide");
- })();
- $("#upload").on("click", function () {
- clearInterval(intervaler);
- ws.close();
- wsss.close();
- if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
- tt.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- } else {
- wx.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- }
- })
- function selectText(x) {
- if (document.selection) {
- var range = document.body.createTextRange();
- range.moveToElementText(x);
- range.select();
- } else if (window.getSelection) {
- var selection = window.getSelection();
- var range = document.createRange();
- selection.removeAllRanges();
- range.selectNodeContents(x);
- selection.addRange(range);
- }
- }
- // 激活码广告相关配置
- function getConfigByPhoneType() {
- return new Promise((resolve, reject) => {
- $.ajax({
- url: baseUrl + "/api/pay/v5/trialCodeConfig/getConfigByPhoneType",
- headers: {
- 'Authorization': form.token
- },
- data: {
- userCardId: form.userCardId,
- phoneType: form.mealType
- },
- type: 'get',
- dataType: 'json',
- success: function (res) {
- console.log(res)
- let obj = res.data;
- if (res.status === 0) {
- resolve(obj)
- } else {
- $.toast(res.msg, "text");
- }
- }
- })
- })
- }
- //列表
- function getSetmealList() {
- return new Promise((resolve, reject) => {
- $.ajax({
- url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
- headers: {
- 'Authorization': form.token
- },
- type: 'get',
- dataType: 'json',
- success: function (res) {
- if (res.status === 0) {
- let list = res.data;
- list.map((item) => {
- if (item.phoneType === parameters['mealType']) {
- resolve(item)
- }
- })
- } else {
- $.toast(res.msg, "text");
- }
- }
- })
- })
- }
- //广告信息
- function adInit() {
- sourceType = parameters['sourceType'];
- if (sourceType == 1) {
- getSetmealList().then((res) => {
- if (res.pushFlowAdvert === 1) {
- getAdList(15);
- }
- if (res.intervalSwitch === 1) {
- let time = res.intervalAdvertDuration * 60 * 1000;
- setInterval(() => {
- $('.try-use-wrap').eq(0).hide();
- getAdList(16);
- }, time);
- }
- })
- } else if (sourceType == 2) {
- getConfigByPhoneType().then((res) => {
- if (res.isDisconnectionTime === 1) {
- let time = res.disconnectionTime * 60 * 1000;
- setTimeout(() => {
- disconnectionFlag = true;
- $('.buy-phone-wrap').eq(0).show();
- }, time);
- }
- if (res.isShowAd === 1) {
- getAdList(15);
- }
- if (res.isIntervalPlayAd === 1) {
- let time = res.intervalPlayAdTime * 60 * 1000;
- setInterval(() => {
- $('.try-use-wrap').eq(0).hide();
- getAdList(16);
- }, time);
- }
- })
- }
- }
- // 广告接口
- function getAdList(type) {
- adType = type;
- $.ajax({
- url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
- headers: {
- 'Authorization': form.token
- },
- data: JSON.stringify({
- adPlace: type,
- os: 0
- }),
- type: 'POST',
- dataType: 'json',
- contentType: "application/json;charset=UTF-8",
- success: function (res) {
- if (res.status === 0) {
- let list = res.data;
- let indexs = Math.floor(Math.random() * list.length);
- videoTime = list[indexs].forcedTime;
- // $('#source').src = list[0].adVideoBase.videoUrl;
- $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
- $("#source").attr("autoplay", "true");//直接播放
- videoTimer = setInterval(() => {
- if (videoTime > 0) {
- videoTime--;
- $('.time-node').eq(0).text(videoTime + 's');
- } else {
- clearInterval(videoTimer);
- $('.time-node').eq(0).text('');
- }
- }, 1000)
- if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
- report(0);
- }
- $('.try-use-wrap').eq(0).show();
- } else {
- $.toast(res.msg, "text");
- }
- }
- })
- }
- //间隔广告上报
- function report(type) {
- $.ajax({
- url: baseUrl + "/api/resources/v1/trial/report",
- headers: {
- 'Authorization': form.token
- },
- data: JSON.stringify({
- userCardId: form.userCardId,
- reportType: type
- }),
- type: 'POST',
- dataType: 'json',
- contentType: "application/json;charset=UTF-8",
- success: function (res) { }
- })
- }
- //关闭广告
- $('.time-close-wrap')[0].addEventListener('click', () => {
- $('.buy-phone-wrap').eq(0).show();
- })
- // 点击取消
- $('.cannel-btn')[0].addEventListener('click', () => {
- $('.buy-phone-wrap').eq(0).hide();
- if (disconnectionFlag || getDate) {//设置了断线时间,取消直接退出
- systemBuriedPoint('激活码-断线-取消');
- wx.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- return
- }
- let pointName = '';
- if (sourceType == 1) {
- pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
- } else {
- pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
- }
- systemBuriedPoint(pointName);
- if (videoTime == 0) {
- if (adType === 16 && sourceType == 1) {
- report(1);
- }
- $('.try-use-wrap').eq(0).hide();
- return
- }
- $('.look-wrap').eq(0).show();
- })
- // 点击去购买
- $('.go-bug')[0].addEventListener('click', () => {
- let pointName = '';
- if (disconnectionFlag) {
- pointName = '激活码-断线-去购买';
- } else if (sourceType == 1) {
- pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
- } else {
- pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
- }
- systemBuriedPoint(pointName);
- if (getDate) {
- wx.miniProgram.navigateTo({
- url: '/packageA/order/buy/index'
- })
- } else {
- wx.miniProgram.navigateTo({
- url: '/packageA/order/renew/index?record=' + form.userCardId
- })
- }
- })
- // 放弃
- $('.cannel-ad-btn')[0].addEventListener('click', () => {
- if (sourceType == 1) {
- systemBuriedPoint('免费试用-强制关闭-放弃');
- } else {
- systemBuriedPoint('激活码-强制关闭-放弃');
- }
- wx.miniProgram.switchTab({
- url: '/pages/home/home'
- })
- })
- // 继续观看
- $('.looking')[0].addEventListener('click', () => {
- $('.look-wrap').eq(0).hide();
- if (sourceType == 1) {
- systemBuriedPoint('免费试用-强制关闭-继续观看');
- } else {
- systemBuriedPoint('激活码-强制关闭-继续观看');
- }
- })
- // 埋点
- function systemBuriedPoint(pointName) {
- $.ajax({
- url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
- headers: {
- 'Authorization': form.token
- },
- type: 'post',
- data: JSON.stringify({
- pointName: pointName
- }),
- contentType: "application/json",
- dataType: 'json',
- success: function (res) { }
- })
- }
- window.onbeforeunload = function () {
- ws.close();
- wsss.close();
- }
- </script>
- <script type="text/javascript" src="aac.js"></script>
- </body>
- </html>
|