1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>双子星云手机</title>
- <meta name="x5-orientation" content="portrait" />
- <meta name="screen-orientation" content="portrait" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta
- name="viewport"
- content="width=device-width, initial-scale=1, user-scalable=no"
- />
- <!-- 删除苹果默认的工具栏和菜单栏 -->
- <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" />
- <!-- 避免IE使用兼容模式 -->
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <!-- 针对手持设备优化,主要是针对一些老的不识别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"
- />
- <!-- <link rel="stylesheet" href="../static/lib/swiper/swiper-bundle.min.css" />
- <script src="../static/lib/swiper/swiper-bundle.js"></script> -->
- <script src="../static/lib/doT-1.1.3/doT.min.js"></script>
- </head>
- <body class="scroll h-player" style="overscroll-behavior: contain">
- <template id="template-phone-size-item">
- {{~ it.list :value:index }}
- <div
- class="phone-size-item {{? value.width === it.active.width && value.height === it.active.height }}active{{?}}"
- data-width="{{= value.width }}"
- data-height="{{= value.height }}"
- data-id="{{= value.id }}"
- >
- <span>{{= value.width }}x{{= value.height }}</span>
- </div>
- {{~}}
- </template>
- <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">
- <div id="box">
- <canvas id="playCanvas" width="450" height="800"></canvas>
- </div>
- </div>
- <div class="leftmains">
- <div class="PictureQualityMain">
- <div class="menu-btn PictureQuality" data-id="4">高清</div>
- <div class="menu-btn PictureQuality avit" data-id="3">标清</div>
- <div class="menu-btn PictureQuality" data-id="2">极速</div>
- </div>
- <div class="">
- <div class="menu-btn" id="open-set-phone-size-dialog-btn">
- <span>分辨率</span>
- </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" id="open-set-phone-size-dialog-btn">
- <img src="../static/img/wx/jianqieban_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"
- autoplay="autoplay"
- loop="loop"
- webkit-playsinline="true"
- playsinline="true"
- x5-video-player-type="h5-page"
- >
- 您的浏览器不支持 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>
- <div id="set-phone-size-dialog" class="dialog">
- <div class="dialog-mask"></div>
- <!-- 设置分辨率的弹窗 -->
- <div class="dialog-content-border">
- <div class="dialog-content">
- <div class="dialog-header">
- <div class="dialog-btn cancel">
- <span>取消</span>
- </div>
- <div class="dialog-btn confirm">
- <span>确定</span>
- </div>
- </div>
- <div class="dialog-main">
- <div id="phone-size-list"></div>
- </div>
- </div>
- </div>
- </div>
- <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="jquery-1.11.0.min.js"></script>
- <!-- ffm软解 -->
- <script type="text/javascript" src="helper.js"></script>
- <script type="text/javascript" src="jquery-weui.min.js"></script>
- <script type="text/javascript" src="pcm-player.js"></script>
- <script type="text/javascript" src="webgl.js"></script>
- <script
- type="text/javascript"
- src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"
- ></script>
- <script
- type="text/javascript"
- src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"
- ></script>
- <script type="text/javascript">
- $(function () {
- //手指滑动多少距离就认为是滑成功
- //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
- var diffXDistance = 50;
- //当前滑动的对象
- var currentObject;
- //上一次滑动的对象
- var lastObject;
- //是否可以左右滑动,在上下滑的时候禁止左右滑
- var canSlide = true;
- //用于记录按下的点
- var startPoint;
- $('.slide-content').css({
- width: $('.slide-wrapper').width(),
- });
- $('.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;
- }
- }
- });
- });
- </script>
- <script>
- // 开发环境
- var isDev =
- /^192\.168\./.test(location.host) || /^localhost/.test(location.host);
- // if (isDev) {
- // baseUrl = 'http://gntest.phone.androidscloud.com:1280';
- // sourceType = 2;
- // }
- var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
- var url = window.location.href;
- url = url.split('/');
- var baseUrl = url[0] + '//' + url[2];
- console.log(baseUrl);
- var parameters = GetRequest();
- var token = parameters['token'];
- var mealType = parameters['mealType'];
- var userCardId = parameters['userCardId'];
- var videoTimer = null,
- videoTime = 0,
- adType = 0,
- sourceType = isNaN(parameters['sourceType'])
- ? sourceType
- : +parameters['sourceType'],
- disconnectionFlag = false,
- getDate = false;
- if (mealType === 'VIP') {
- $('.loading_sceen_pic').attr('src', '../static/img/home_bg_VIP.png');
- } else if (mealType === 'SVIP') {
- $('.loading_sceen_pic').attr('src', '../static/img/home_bg_SVIP.png');
- } else if (mealType === 'STAR') {
- $('.loading_sceen_pic').attr('src', '../static/img/home_bg_STAR.png');
- } else if (mealType === 'STARPRO') {
- $('.loading_sceen_pic').attr('src', '../static/img/home_bg_PRO.png');
- }
- $('#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 isAudioPlay = false;
- let dbName = parameters['username'],
- version = 1,
- storeName = 'usercard';
- let indexedDB = window.indexedDB;
- let db;
- var socketURL;
- var cUrl;
- var cardToken, resolvingPower;
- const request = indexedDB.open(dbName, version);
- request.onsuccess = function (event) {
- db = event.target.result; // 数据库对象
- console.log('数据库打开成功');
- };
- request.onerror = function (event) {
- console.log('数据库打开报错');
- };
- request.onupgradeneeded = function (event) {
- // 数据库创建或升级的时候会触发
- console.log('onupgradeneeded');
- db = event.target.result; // 数据库对象
- let objectStore;
- if (!db.objectStoreNames.contains(storeName)) {
- objectStore = db.createObjectStore(storeName, { keyPath: 'id' }); // 创建表
- }
- };
- // 添加数据
- function addData(db, storeName, data) {
- let request = db
- .transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写")
- .objectStore(storeName) // 仓库对象
- .add(data);
- request.onsuccess = function (event) {
- console.log('数据写入成功');
- };
- request.onerror = function (event) {
- console.log('数据写入失败');
- throw new Error(event.target.error);
- };
- }
- // 根据id获取数据
- function getDataByKey(db, storeName, key) {
- let transaction = db.transaction([storeName]); // 事务
- let objectStore = transaction.objectStore(storeName); // 仓库对象
- let request = objectStore.get(key);
- request.onerror = function (event) {
- connect('add');
- };
- request.onsuccess = function (event) {
- console.log('主键查询结果: ', request.result);
- if (request.result) {
- socketURL = request.result.socketURL;
- cUrl = request.result.cUrl;
- cardToken = request.result.cardToken;
- resolvingPower = request.result.resolvingPower;
- doConnectBusiness();
- doConnectDirectives();
- } else {
- connect('add');
- }
- };
- }
- // 根据id修改数
- function updateDB(db, storeName, data) {
- let request = db
- .transaction([storeName], 'readwrite') // 事务对象
- .objectStore(storeName) // 仓库对象
- .put(data);
- request.onsuccess = function () {
- console.log('数据更新成功');
- };
- request.onerror = function () {
- console.log('数据更新失败');
- };
- }
- // 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错
- setTimeout(() => {
- getDataByKey(db, storeName, userCardId);
- }, 1000);
- var timerInterval = null,
- timeInterval = 0;
- function connect(type) {
- $.ajax({
- url: baseUrl + '/api/resources/user/cloud/connect',
- type: 'post',
- data: JSON.stringify({
- userCardId: Number(userCardId),
- }),
- headers: {
- 'content-Type': 'application/json',
- Authorization: token,
- },
- dataType: 'json',
- async: false,
- success: function (res) {
- if (res.status === 0) {
- if (timerInterval) {
- timerInterval = clearTimeout();
- }
- if (res.data.internetHttps) {
- socketURL =
- 'wss://' +
- res.data.internetHttps +
- '/plugflow?cardIp=' +
- res.data.localIp +
- '&token=' +
- res.data.cardToken +
- '&type=business';
- cUrl =
- 'wss://' +
- res.data.internetHttps +
- '/businessChannel?cardIp=' +
- res.data.localIp +
- '&token=' +
- res.data.cardToken +
- '&type=directives';
- cardToken = res.data.cardToken;
- resolvingPower = res.data.resolvingPower;
- doConnectBusiness();
- doConnectDirectives();
- if (type === 'add') {
- addData(db, storeName, {
- id: userCardId,
- socketURL: socketURL,
- cUrl: cUrl,
- cardToken: res.data.cardToken,
- resolvingPower: res.data.resolvingPower,
- });
- } else {
- updateDB(db, storeName, {
- id: userCardId,
- socketURL: socketURL,
- cUrl: cUrl,
- cardToken: res.data.cardToken,
- resolvingPower: res.data.resolvingPower,
- });
- }
- } else {
- $.toast('网络异常,请稍后重试', 'text');
- setTimeout(() => {
- clearInterval(intervaler);
- quit();
- }, 3000);
- }
- } else if (res.status === 5200) {
- if (timeInterval > 7) {
- $.toast('网络异常,请稍后重试', 'text');
- timerInterval = clearTimeout();
- setTimeout(() => {
- quit();
- }, 3000);
- return;
- }
- timerInterval = setTimeout(() => {
- connect(type);
- timeInterval += 1;
- }, 3000);
- } else {
- $.toast('画面异常,请重新进入', 'text');
- setTimeout(() => {
- quit();
- }, 3000);
- }
- },
- });
- }
- initAD();
- $.alert({
- title: '提示',
- text: '开始使用云手机',
- onOK: function () {
- 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 orientation = 0; //0 竖屏,1横屏
- function array_unique(arr) {
- return arr.filter(function (e, i) {
- return arr.indexOf(e) === i;
- });
- }
- var cutList = [];
- let timer,
- isFlag = true;
- function showShearPlate() {
- stopManyClick(function () {
- new Promise((resolve, reject) => {
- if (window.navigator.clipboard) {
- window.navigator.clipboard
- .readText()
- .then(
- function (content) {
- return $.ajax({
- url: baseUrl + '/api/public/v5/shear/content',
- type: 'post',
- dataType: 'json',
- data: JSON.stringify({
- content: content,
- }),
- headers: {
- 'content-Type': 'application/json',
- Authorization: token,
- },
- });
- },
- function (err) {
- $.toast('读取剪贴板失败', 'text');
- },
- )
- .finally(resolve);
- } else {
- resolve();
- }
- }).then(function () {
- $('.box-shear-plate').empty();
- return $.ajax({
- url: baseUrl + '/api/public/v5/shear/content',
- headers: {
- Authorization: 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: 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: 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 () {
- decodeWoker.postMessage('close');
- decodeWoker.terminate();
- quit();
- });
- function handleClose() {
- $('.mask').hide();
- }
- var decodeCount = 1;
- var isFinish = false;
- var player = new PCMPlayer({
- encoding: '16bitInt',
- channels: 2,
- sampleRate: 44100,
- flushingTime: 22,
- debug: false,
- });
- Module = {};
- Module.onRuntimeInitialized = function () {
- isFinish = true;
- };
- 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);
- }
- var decodeWoker = new Worker('decoder.js');
- var myVideo = document.getElementById('playCanvas');
- var logicWidth = 720;
- var logicHeight = 1280;
- decodeWoker.onmessage = function (event) {
- var objData = event.data;
- // console.log("🚀 ~ file: WXtrialInterface.html ~ line 806 ~ objData", objData)
- switch (objData.cmd) {
- case 0:
- break;
- case 1:
- // console.log(objData);
- if (logicWidth != objData.width || logicHeight != objData.height) {
- logicWidth = objData.width;
- logicHeight = objData.height;
- }
- // logicWidth = 375
- // logicHeight = 812
- webglPlayer.renderFrame(
- objData.data,
- logicWidth,
- logicHeight,
- logicWidth * logicHeight,
- (logicWidth / 2) * (logicHeight / 2),
- );
- $('.weui-mask_transparent').hide();
- $('.weui-toast').hide();
- $('.loading').hide();
- break;
- case 5:
- var buffer = RequestIFrame();
- webSocketWorker.postMessage(buffer);
- }
- };
- var isFinish = false;
- var webglPlayer = new WebGLPlayer(myVideo, {
- preserveDrawingBuffer: false,
- });
- 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 doConnectBusiness() {
- var webSocketWorker = new Worker(
- 'websocket.js?socketURL=' +
- encodeURIComponent(socketURL) +
- '&cardToken=' +
- encodeURIComponent(cardToken),
- );
- window.webSocketWorker = webSocketWorker;
- webSocketWorker.onmessage = function (event) {
- var input = event.data;
- if (input[0] == 0xff && isAudioPlay) {
- decodeAAC(input);
- }
- if (
- input[0] == 0 &&
- input[1] == 0 &&
- input[2] == 0 &&
- input[3] == 1
- ) {
- var cmd = {
- type: 'rawData',
- data: event.data,
- };
- decodeWoker.postMessage(cmd);
- }
- if (input[0] == 0x68) {
- if (input[23] == 0x5c) {
- if (CheckVerifyCode(input)) {
- webSocketWorker.postMessage(ConfigChannel('RK3923C1201900139'));
- var checkBuffer = GetScreenState();
- webSocketWorker.postMessage(checkBuffer);
- } else {
- connect('update');
- }
- }
- if (input[23] == 0x05) {
- //横竖屏标识
- var state = CheckScreenDirection(input.slice(24, 24 + 8));
- if (state == 1) {
- console.log('安卓卡此时竖屏');
- //竖屏处理
- resolving = 1;
- $('#playCanvas').removeClass('horizontal').addClass('vertical');
- } else {
- console.log('安卓卡此时横屏');
- //横屏处理
- resolving = 0;
- $('#playCanvas').removeClass('vertical').addClass('horizontal');
- }
- }
- if (input[23] == 0x0b) {
- console.log('多端登陆');
- }
- }
- if (event.data === 'close') {
- $.toast('画面异常,请重新进入', 'text');
- setTimeout(() => {
- decodeWoker.postMessage('close');
- decodeWoker.terminate();
- quit();
- }, 3000);
- }
- };
- }
- // 激活码广告相关配置
- function getConfigByPhoneType() {
- return new Promise((resolve, reject) => {
- $.ajax({
- url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
- headers: {
- Authorization: token,
- },
- data: {
- userCardId: userCardId,
- phoneType: 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: token,
- },
- type: 'get',
- dataType: 'json',
- success: function (res) {
- if (res.status === 0) {
- let list = res.data;
- list.map((item) => {
- if (item.phoneType === mealType) {
- resolve(item);
- }
- });
- } else {
- $.toast(res.msg, 'text');
- }
- },
- });
- });
- }
- //广告信息
- var adData = null; // 广告数据
- var adLastTime = 0; // 广告时间
- var intervalTime = 0; // 间隔时间
- // let adType = 0;
- console.log(
- '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
- sourceType,
- );
- // 拉取广告数据
- function getAD() {
- return $.ajax({
- url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
- headers: {
- Authorization: token,
- },
- data: JSON.stringify({
- adPlace: adType,
- os: 0,
- }),
- type: 'POST',
- dataType: 'json',
- contentType: 'application/json;charset=UTF-8',
- }).then(function (res) {
- if (res.status === 0) {
- var list = res.data.filter(
- (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
- );
- adData = list[Math.floor(Math.random() * list.length)];
- console.log(
- '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
- adData,
- );
- return adData;
- } else {
- return Promise.reject(new Error(res.msg));
- }
- });
- }
- // 播放广告
- function playAD() {
- var nowTime = Date.now();
- if (
- adData &&
- // [1, 2].includes(sourceType) &&
- $('.try-use-wrap').eq(0).is(':hidden') &&
- nowTime > adLastTime + intervalTime
- ) {
- $('#source').attr('src', adData.adVideoBase.videoUrl);
- $('.try-use-wrap').eq(0).show();
- $('#source')[0].play();
- videoTime = adData.forcedTime;
- adData = null;
- adLastTime = nowTime;
- videoTimer = setInterval(() => {
- if (videoTime > 0) {
- videoTime--;
- $('.time-node')
- .eq(0)
- .text(videoTime + 's');
- } else {
- clearInterval(videoTimer);
- $('.time-node').eq(0).text('');
- }
- }, 1000);
- if (intervalTime > 0) {
- // 间隔广告拉取下一次广告数据
- adType = 16;
- getAD();
- }
- if (adType === 16 && sourceType == 1) {
- // 间隔广告和试用才上报
- report(0);
- }
- }
- }
- /**
- * 初始化广告
- * 因移动端video无法自动播放,play()方法不能异步调用。
- * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
- */
- function initAD() {
- console.log(
- '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
- sourceType,
- );
- (function () {
- switch (sourceType) {
- case 1: {
- return getSetmealList().then(function (res) {
- intervalTime =
- res.intervalSwitch === 1
- ? res.intervalAdvertDuration * 1000 * 60
- : 0;
- if (res.pushFlowAdvert === 1) {
- adType = 15;
- adTime = 0;
- } else if (intervalTime > 0) {
- adType = 16;
- adTime = date.now();
- }
- });
- }
- case 2: {
- return getConfigByPhoneType().then(function (res) {
- if (res.isDisconnectionTime === 1) {
- var time = res.disconnectionTime * 60 * 1000;
- setTimeout(() => {
- disconnectionFlag = true;
- $('.buy-phone-wrap').eq(0).show();
- }, time);
- }
- intervalTime =
- res.isIntervalPlayAd === 1
- ? res.intervalPlayAdTime * 1000 * 60
- : 0;
- if (res.isShowAd === 1) {
- adType = 15;
- adTime = 0;
- } else if (intervalTime > 0) {
- adType = 16;
- adTime = date.now();
- }
- });
- }
- default: {
- return Promise.reject();
- }
- }
- })().then(function () {
- console.log(adType);
- this.$('#playCanvas').on('touchstart', playAD);
- // this.$('#playCanvas').on('touchmove', playAD);
- getAD();
- });
- }
- // 观看广告次数上报1
- function reportFrequency() {
- $.ajax({
- url:
- baseUrl +
- '/api/resoures/v1/trial/reportFrequency/' +
- form.userCardId,
- headers: {
- Authorization: form.token,
- },
- type: 'post',
- contentType: 'application/json',
- dataType: 'json',
- success: function (res) {},
- });
- }
- //间隔广告上报
- function report(type) {
- $.ajax({
- url: baseUrl + '/api/resources/v1/trial/report',
- headers: {
- Authorization: token,
- },
- data: JSON.stringify({
- userCardId: userCardId,
- reportType: type,
- }),
- type: 'POST',
- dataType: 'json',
- contentType: 'application/json;charset=UTF-8',
- success: function (res) {},
- });
- }
- //关闭广告
- $('.time-close-wrap')[0].addEventListener('click', () => {
- if (videoTime == 0) {
- reportFrequency();
- }
- $('.buy-phone-wrap').eq(0).show();
- });
- // 点击取消
- $('.cannel-btn')[0].addEventListener('click', () => {
- $('.buy-phone-wrap').eq(0).hide();
- if (disconnectionFlag || getDate) {
- //设置了断线时间,取消直接退出
- systemBuriedPoint('激活码-断线-取消');
- quit();
- 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();
- $('#source')[0].pause();
- 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) {
- if (window.__wxjs_environment === 'miniprogram') {
- wx.miniProgram.navigateTo({
- url: '/packageA/order/buy/index?buyType=试用界面购买',
- });
- } else {
- uni.webView.navigateTo({
- url: '/pages/order/order',
- });
- }
- } else {
- if (window.__wxjs_environment === 'miniprogram') {
- wx.miniProgram.navigateTo({
- url:
- `/packageA/order/renew/index?buyType=${
- sourceType == 1
- ? '试用弹窗购买按钮进入-普通试用'
- : '试用弹窗购买按钮进入-激活码试用'
- }&record=` + userCardId,
- });
- } else {
- uni.webView.navigateTo({
- url: '/pages/order/order',
- });
- }
- }
- });
- window.onbeforeunload = function () {
- wsss.close();
- decodeWoker.postMessage('close');
- decodeWoker.terminate();
- };
- function quit() {
- 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 {
- uni.webView.navigateBack({
- delta: 1,
- });
- }
- }
- function updatePhoneSizeListHtml() {
- const templatePhoneSizeItem = doT.template(
- $('#template-phone-size-item').html().replace(/&/g, '&'),
- );
- const phoneSizeListItemsHtml = templatePhoneSizeItem({
- list: window.phoneSizeList,
- active: window.activePhoneSize,
- });
- $('#phone-size-list').html(phoneSizeListItemsHtml);
- }
- $('#open-set-phone-size-dialog-btn').on('click', function (e) {
- window.activePhoneSize = window.currentPhoneSize;
- updatePhoneSizeListHtml();
- $('#set-phone-size-dialog').addClass('show');
- });
- // $('#set-phone-size-dialog').addClass('show');
- $('.dialog .dialog-mask')
- .add('.dialog .dialog-btn.cancel')
- .on('click', function (e) {
- $(e.currentTarget).parents('.dialog').removeClass('show');
- });
- // 分辨率列表
- window.phoneSizeList = [];
- // 当前生效的分辨率
- window.currentPhoneSize = {
- // id: 1,
- width: 720,
- height: 1280,
- };
- // 选中的分辨率
- window.activePhoneSize = window.currentPhoneSize;
- function getPhoneSizeList() {
- return $.ajax({
- url:
- baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
- headers: {
- Authorization: token,
- },
- type: 'get',
- dataType: 'json',
- data: {
- userCardId,
- },
- }).then(function (response) {
- return response.data.map(function (v) {
- return {
- id: v.id,
- dpi: v.dpi,
- width: v.width || v.abscissa,
- height: v.height || v.ordinate || v.high,
- };
- });
- });
- }
- getPhoneSizeList().then(function (phoneSizeList) {
- window.phoneSizeList = phoneSizeList;
- const currentPhoneSize = window.phoneSizeList.find(function (v) {
- return (
- v.width === window.currentPhoneSize.width &&
- v.height === window.currentPhoneSize.height
- );
- });
- window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
- return updatePhoneSizeListHtml();
- });
- // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
- // direction: 'vertical',
- // slidesPerView: 'auto',
- // loop: false,
- // centeredSlides: true,
- // });
- function setPhoneSize(config) {
- // 修改云机分辨率
- wsss.send(
- JSON.stringify({
- type: 'setPhoneSize',
- data: {
- id: config.id,
- width: config.width,
- height: config.height,
- dpi: config.dpi,
- },
- }),
- );
- // 通知其他在线端
- wsss.send(
- JSON.stringify({
- type: 'forwardMsg',
- data: {
- code: 'phoneSizeChange',
- id: config.id,
- width: config.width,
- height: config.height,
- dpi: config.dpi,
- desc: '分辨率修改', // 可选
- },
- }),
- );
- // 上报分辨率
- $.ajax({
- url:
- baseUrl +
- '/api/resources/v5/machine/resolution/operationResolvingPower',
- headers: {
- Authorization: token,
- },
- type: 'post',
- dataType: 'json',
- contentType: 'application/json; charset=UTF-8',
- data: JSON.stringify({
- userCardId: window.userCardId,
- resolvingPowerId: config.id,
- width: config.width,
- height: config.height,
- dpi: config.dpi,
- }),
- });
- window.currentPhoneSize = config;
- }
- // wsss.addEventListener('message', function (event) {
- // console.log(
- // '🚀 ~ file: WXtrialInterface.html ~ line 1476 ~ event',
- // event,
- // );
- // });
- $('#phone-size-list').on('click', '.phone-size-item', function (e) {
- const data = $(e.currentTarget).data();
- console.log(
- '🚀 ~ file: WXtrialInterface.html ~ line 1494 ~ data',
- data,
- );
- window.activePhoneSize = data;
- updatePhoneSizeListHtml();
- // setPhoneSize(data.width, data.height);
- });
- $('#set-phone-size-dialog .dialog-btn.confirm').on('click', function (e) {
- setPhoneSize(window.activePhoneSize);
- $('#set-phone-size-dialog').removeClass('show');
- });
- </script>
- <script type="text/javascript" src="WXdraw.js"></script>
- <script type="text/javascript" src="aac.js"></script>
- </body>
- </html>
|