123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118 |
- <!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,minimum-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no,viewport-fit=cover"
- />
- <!-- 删除苹果默认的工具栏和菜单栏 -->
- <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>
- <script src="../static/lib/qs.js"></script>
- <script src="../static/lib/copy-to-clipboard.js"></script>
- <script
- type="text/javascript"
- src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.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-id="{{= value.id }}"
- data-dpi="{{= value.dpi }}"
- data-width="{{= value.width }}"
- data-height="{{= value.height }}"
- >
- <span>{{= value.width }}x{{= value.height }}</span>
- </div>
- {{~}}
- </template>
- <template id="template-shear">
- {{? it.length }}
- <div class="title">
- 剪贴板
- <div class="btn-clear">清空</div>
- </div>
- <div class="slide-wrapper-content">
- {{~ it :item:index }}
- <div class="slide-wrapper" data-id="{{= item.id}}">
- <div class="slide-scroll animate-slide-start">
- <div
- class="slide-content"
- data-content="{{= encodeHtml(item.content)}}"
- >
- <div>{{= encodeHtml(item.content)}}</div>
- </div>
- <div class="slide-content-button" data-id="{{= item.id}}">
- <button>删除</button>
- </div>
- </div>
- </div>
- {{~}}
- </div>
- {{??}}
- <img class="empty" src="img/jianqieban_pic@2x.png" alt="" />
- <div class="empty-txt">剪贴板为空</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">
- <!-- 默认webRTC是关闭状态的 -->
- <video
- muted
- poster=""
- autoplay="autoplay"
- webkit-playsinline=""
- playsinline=""
- style="object-fit: contain; display: none"
- id="playVideo"
- ></video>
- <canvas id="playCanvas" width="450" height="800"></canvas>
- </div>
- <div class="count-view" id="countView">
- <div class="fnca">
- <span class="countdown-time" style="color: #ffffff"></span>
- <div class="line"></div>
- <img
- class="wh22"
- src="../static/img/close.png"
- alt=""
- onclick="handleclose()"
- />
- </div>
- </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="open-set-phone-size-dialog-btn-wrap">
- <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" onclick="showShearPlate()" data-text="Shearplate">
- <img src="../static/img/wx/jianqieban_icon.png" />
- <div>剪贴板</div>
- </div>
- <div
- class="upload"
- id="upload"
- data-text="Signout"
- onclick="handleQuit('quit')"
- >
- <img src="../static/img/wx/tuichu_icon.png" />
- <div>退出</div>
- </div>
- <div
- class="upload"
- id="dormant"
- data-text="Dormant"
- onclick="handleQuit('dormant')"
- >
- <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>
- <div class="dialog-jifei">
- <div class="apply-wrap">
- <div class="apply-container">
- <div class="apply-title">应用推荐</div>
- <div class="apply-list"></div>
- <div class="apply-list-change">换一批</div>
- <img class="apply-close" src="img/close.png" alt="" />
- </div>
- </div>
- <div class="time-lang-wrap">
- <div class="time-lang-container">
- <img class="time-lang-img" src="img/smallBell.png" />
- <div class="time-lang-title">本月时长已用完</div>
- <div class="time-lang-tip">您可以去购买时长页面进行购买</div>
- <div class="time-lang-btn">续时长</div>
- </div>
- </div>
- <div class="countdown-wrap">
- <div class="countdown-container">
- <img class="countdown-img" src="img/countdown.png" />
- <div class="countdown-title">计费规则</div>
- <div class="countdown-tip">
- 进入云机开始计时,点击退出并下机停止<br />计时。点击退出云机仍处于计时状态。
- </div>
- <div class="countdown-tip2">
- 云机时长剩余:<span class="countdown-time"></span>
- </div>
- <div class="countdown-btn">我知道了</div>
- </div>
- </div>
- <script type="text/html" id="apply">
- <div class="apply-item">
- <img class="apply-img" src="{{imageUrl}}" />
- <div class="apply-row">
- <div class="apply-row-title">{{filename}}</div>
- <div class="apply-row-down">{{installNum}}</div>
- </div>
- <div
- class="apply-down-btn"
- data-id="{{id}}"
- data-url="{{downloadUrl}}"
- >
- 下载
- </div>
- </div>
- </script>
- </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="rtcEngine.min.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>
- let isVideo = !!(
- typeof RTCPeerConnection !== 'undefined' &&
- typeof RTCIceCandidate !== 'undefined' &&
- typeof RTCSessionDescription !== 'undefined'
- );
- let engine = null;
- let connectData = null;
- window.addEventListener('message', function (e) {
- let data = e.data;
- if (data.bool && isVideo) {
- $('#playVideo').hide();
- $('#playCanvas').show();
- document.getElementById('playVideo').pause();
- document.getElementById('playVideo').play();
- $('.weui-mask_transparent').show();
- $('.weui-toast').show();
- engine.disconnect();
- wsss.close();
- decodeWoker.postMessage('close');
- decodeWoker.terminate();
- webSocketWorker.postMessage('close');
- doConnectBusiness(connectData);
- doConnectDirectives();
- }
- });
- // 开发环境
- 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];
- var parameters = GetRequest();
- var token = parameters['token'];
- var mealType = parameters['mealType'];
- var userCardId = parameters['userCardId'];
- var username = parameters['username'];
- var connectStatus = parameters['connectStatus'];
- var videoTimer = null,
- videoTime = 0,
- adType = 0,
- sourceType = isNaN(parameters['sourceType'])
- ? sourceType
- : +parameters['sourceType'],
- userCardType = isNaN(parameters['userCardType'])
- ? userCardType
- : +parameters['userCardType'],
- disconnectionFlag = false,
- getDate = false;
- // 计时套餐显示退出并下机按钮
- if ([1, 2, 3].includes(userCardType)) {
- $('#dormant').css({ display: 'block' });
- }
- 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 && !isVideo) {
- socketURL = request.result.socketURL;
- cUrl = request.result.cUrl;
- cardToken = request.result.cardToken;
- resolvingPower = request.result.resolvingPower;
- window.currentPhoneSize = {
- width: request.result.width,
- height: request.result.height,
- dpi: request.result.dpi,
- };
- 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('数据更新失败');
- };
- }
- // 根据id删除数据
- function deleteDB(db, storeName, id) {
- let request = db
- .transaction([storeName], 'readwrite')
- .objectStore(storeName)
- .delete(id);
- 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) {
- //getResidueTime()
- 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;
- connectData = res;
- doConnectBusiness(res);
- doConnectDirectives();
- if (type === 'add') {
- addData(db, storeName, {
- id: userCardId,
- socketURL: socketURL,
- cUrl: cUrl,
- cardToken: res.data.cardToken,
- resolvingPower: res.data.resolvingPower,
- width: res.data.width,
- height: res.data.high,
- dpi: res.data.dpi,
- });
- } else {
- updateDB(db, storeName, {
- id: userCardId,
- socketURL: socketURL,
- cUrl: cUrl,
- cardToken: res.data.cardToken,
- resolvingPower: res.data.resolvingPower,
- width: res.data.width,
- height: res.data.high,
- dpi: res.data.dpi,
- });
- }
- const data = window.phoneSizeList.find(function (v) {
- return (
- v.width === res.data.width &&
- v.height === res.data.height &&
- v.dpi === res.data.dpi
- );
- });
- window.currentPhoneSize = data || {
- width: res.data.width,
- height: res.data.height,
- dpi: res.data.dpi,
- };
- } else {
- $.toast('网络异常,请稍后重试', 'text');
- setTimeout(() => {
- clearInterval(intervaler);
- quit();
- }, 3000);
- }
- return;
- }
- if (res.status === 5200) {
- if (timeInterval > 7) {
- $.toast('网络异常,请稍后重试', 'text');
- timerInterval = clearTimeout();
- setTimeout(() => {
- quit();
- }, 3000);
- return;
- }
- timerInterval = setTimeout(() => {
- connect(type);
- timeInterval += 1;
- }, 3000);
- return;
- }
- if (res.status === 5220) {
- $.toast('云手机正在一键修复中', 'text');
- setTimeout(() => {
- quit();
- }, 3000);
- return;
- }
- if (res.status === 5203) {
- $.toast('正在排队中,请稍等', 'text');
- setTimeout(() => {
- quit();
- }, 3000);
- return;
- }
- if (res.status === 5204) {
- $.toast('云机异常,正在为你重新分配云机', 'text');
- setTimeout(() => {
- quit();
- }, 3000);
- return;
- }
- $('#countView').hide();
- $('.countdown-wrap').hide();
- //downline();
- $.toast('画面异常,请重新进入', 'text');
- setTimeout(() => {
- quit();
- }, 3000);
- },
- });
- }
- initAD();
- var isShowCountdown = +parameters['isShowCountdown'],
- isShowRule = +parameters['isShowRule'];
- $.alert({
- title: '提示',
- text: '开始使用云手机',
- onOK: function () {
- isAudioPlay = true;
- if (isShowCountdown) {
- $('#countView').eq(0).show();
- }
- if (isShowRule) {
- $('.countdown-wrap').eq(0).show();
- }
- //getResidueTime();
- },
- });
- //云机倒计时
- 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;
- const shearTemplate = doT.template(
- $('#template-shear').html().replace(/&/g, '&'),
- );
- function updateShearHtml(list) {
- $('.box-shear-plate').html(shearTemplate(list));
- }
- // 对字符串进行html转义
- function encodeHtml(content) {
- return [
- ['<', '<'],
- ['>', '>'],
- ['&', '&'],
- ['"', '"'],
- ].reduce(function (previousValue, currentValue) {
- return previousValue.replace(
- new RegExp(currentValue[0], 'g'),
- currentValue[1],
- );
- }, content);
- }
- $('.box-shear-plate').on('click', '.slide-content', function (e) {
- handleCopy(e.currentTarget.dataset.content);
- });
- $('.box-shear-plate').on('click', '.btn-clear', function (e) {
- handleClear();
- });
- $('.box-shear-plate').on('click', '.slide-content-button', function (e) {
- handleDelete(e.currentTarget.dataset.id);
- });
- function showShearPlate(type) {
- if (!isControl) {
- return;
- }
- 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) {
- if (type === 'clear') {
- return;
- }
- $.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) {
- updateShearHtml(res.status === 0 ? res.data : []);
- $('.mask').show();
- initSlider();
- },
- });
- });
- });
- }
- //防止提示一秒内重复显示
- function stopManyClick(fn) {
- if (isFlag) {
- fn();
- }
- isFlag = false;
- if (timer) {
- clearTimeout(timer);
- }
- timer = setTimeout(() => {
- isFlag = true;
- }, 1500);
- }
- // 清空剪贴板
- function handleClear() {
- $.confirm('确定清空剪贴板?', function () {
- $.ajax({
- url:
- baseUrl +
- '/api/public/v5/shear/content' +
- Qs.stringify(
- {
- ids: Array.from($('.slide-wrapper')).map((v) => v.dataset.id),
- },
- { arrayFormat: 'repeat', addQueryPrefix: true },
- ),
- headers: {
- Authorization: token,
- },
- type: 'DELETE',
- dataType: 'json',
- success: function (res) {
- if (res.status === 0) {
- showShearPlate('clear');
- } 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;
- }
- }
- });
- }
- $('#wine').on('click', function (e) {
- console.log('🚀 ~ file: WXdraw.js ~ line 4 ~ e', e);
- $('.control-right-img').attr({
- 'data-id': '1',
- });
- $('.leftmains').css({
- right: '-4rem',
- });
- });
- 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');
- })();
- 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 statusCallBack(event) {
- if (event.type == 'open') {
- $('.weui-mask_transparent').hide();
- $('.weui-toast').hide();
- // $('.loading').hide();
- console.log('流已经打开');
- }
- if (event.type == 'screenChange') {
- console.log('横竖屏切换事件:' + event.val);
- }
- if (event.type == 'verifyFailed') {
- console.log('鉴权失败');
- }
- }
- function successCallback() {
- console.log('webRTC请求成功了');
- // 如果支持webRTC,就直接切换成webRTC的画面显示
- $('#playVideo').show();
- $('#playCanvas').hide();
- }
- let extranetIp, extranetPort;
- function doConnectBusiness(res) {
- if (isVideo) {
- var url0 = url[0]; //协议
- let ip = res.data.internetIp; //服务器拿到的ip
- let port = res.data.internetVideoPort; //服务器拿到的端口
- extranetIp = res.data.internetIp;
- extranetPort = res.data.internetVideoPort;
- let rtcUrl, wsUrl;
- if (url0 == 'https:') {
- rtcUrl =
- 'https://' +
- res.data.internetHttps +
- '/webrtc?cardIp=' +
- res.data.localIp;
- wsUrl =
- 'wss://' +
- res.data.internetHttps +
- '/plugflow?cardIp=' +
- res.data.localIp;
- } else {
- rtcUrl =
- 'http://' +
- ip +
- ':' +
- port +
- '/index/api/webrtc?app=live&stream=test&type=play';
- wsUrl = 'ws://' + ip + ':' + port + '/plugflow';
- }
- let token = res.data.cardToken;
- let videoId = 'playVideo';
- let mode = 'webrtc'; //指定解码模式, 目前支持mse、webrtc
- // let ip = res.data.internetIp; //服务器拿到的ip
- // let port = res.data.internetVideoPort; //服务器拿到的端口
- // let rtcUrl = "http://" + ip + ":" + port + "/index/api/webrtc?app=live&stream=test&type=play";
- // let wsUrl = "ws://" + ip + ":" + port + '/plugflow';
- // let token = res.data.cardToken;
- // let videoId = "playCanvas";
- // let mode = "webrtc"; //指定解码模式, 目前支持mse、webrtc
- let option = {
- url: wsUrl, //websocket url
- rtcUrl: rtcUrl, //webrtc 推流地址,webrtc 推流时必须要填
- token: token, //用于校验的token
- videoId: videoId, //视频标签ID
- mode: mode, //可选,默认为自动切换,可以强行指定模式
- debug: true, //可选
- callback: statusCallBack, //回调函数
- successCallback, // 成功请求WEBRTC回调
- };
- engine = new RtcEngine(option);
- let myVideo = document.getElementById('playVideo');
- // 禁用 <video> 元素的默认控件(例如播放按钮、进度条等)
- myVideo.controls = false;
- // 启动视频流连接过程。这将根据之前配置的参数建立与服务器的 WebSocket 连接,并开始视频流的传输和播放。
- engine.connect();
- }
- var webSocketWorker = new Worker(
- 'websocket.js?socketURL=' +
- encodeURIComponent(socketURL) +
- '&cardToken=' +
- encodeURIComponent(cardToken),
- );
- window.webSocketWorker = webSocketWorker;
- webSocketWorker.onmessage = function (event) {
- if (connectStatus == 1) {
- getResidueTime();
- }
- var input = event.data;
- if (input[0] == 0xff && isAudioPlay && !isVideo) {
- 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) {
- //横竖屏标识
- if (input[28] == 0x01 && input[29] == 0x01) {
- 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');
- }
- }
- // window.phoneSizeList = window.phoneSizeListBack.map(function (
- // item,
- // ) {
- // return resolving
- // ? item
- // : Object.assign({}, item, {
- // width: item.height,
- // height: item.width,
- // });
- // });
- // wsss.send(
- // JSON.stringify({
- // type: 'getPhoneSize',
- // }),
- // );
- // 横竖屏变更时获取分辨率要延迟,不然会获取到变更前的分辨率
- // setTimeout(function () {
- // wsss.send(
- // JSON.stringify({
- // type: 'getPhoneSize',
- // }),
- // );
- // }, 500);
- }
- if (input[23] == 0x0b) {
- console.log('多端登陆');
- }
- }
- if (event.data === 'close') {
- $('#countView').hide();
- $('.countdown-wrap').hide();
- downline();
- $.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 &&
- $('.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);
- }
- }
- }
- var residueTimer = null;
- // 获取云机剩余时长
- function getResidueTime() {
- clearInterval(residueTimer);
- if (userCardType !== 1) {
- return;
- }
- return $.ajax({
- url:
- baseUrl +
- `/api/resources/yearMember/getResidueTime?userCardId=${userCardId}`,
- headers: {
- Authorization: token,
- },
- type: 'get',
- dataType: 'json',
- contentType: 'application/json;charset=UTF-8',
- }).then(function (res) {
- if (res.status === 0) {
- let time = res.data;
- startTime();
- residueTimer = setInterval(() => {
- if (time > 0) {
- time--;
- $('.countdown-time').text(residueTimeStamp(time));
- } else {
- clearInterval(residueTimer);
- downline();
- }
- }, 1000);
- } else {
- return Promise.reject(new Error(res.msg));
- }
- });
- }
- // 客户端成功进入云手机后调用
- function startTime() {
- if (userCardType !== 1) {
- return;
- }
- return $.ajax({
- url:
- baseUrl +
- `/api/resources/yearMember/startTime?userCardId=${userCardId}`,
- headers: {
- Authorization: token,
- },
- type: 'get',
- dataType: 'json',
- contentType: 'application/json;charset=UTF-8',
- }).then(function (res) {});
- }
- // 秒转化为时分秒
- function getResultTime(time) {
- let theTime = parseInt(time); // 秒
- let theTime1 = 0; // 分
- let theTime2 = 0; // 小时
- if (theTime > 60) {
- theTime1 = parseInt(theTime / 60);
- theTime = parseInt(theTime % 60);
- if (theTime1 > 60) {
- theTime2 = parseInt(theTime1 / 60);
- theTime1 = parseInt(theTime1 % 60);
- }
- }
- let result = '' + parseInt(theTime);
- if (theTime1 > 0) {
- result = '' + parseInt(theTime1) + ':' + result;
- }
- if (theTime2 > 0) {
- result = '' + parseInt(theTime2) + ':' + result;
- }
- return result;
- }
- // 推荐列表
- function getRecommend() {
- return $.ajax({
- url:
- baseUrl +
- `/api/public/v1/market/get/recommend?userCardId=${userCardId}`,
- headers: {
- Authorization: token,
- },
- type: 'get',
- dataType: 'json',
- contentType: 'application/json;charset=UTF-8',
- }).then(function (res) {
- if (res.status === 0) {
- $('.apply-wrap').eq(0).show();
- let list = res.data;
- let result = '';
- list.map((item) => {
- item.installNum = `有${item.installNum}人下载`;
- result += $('#apply')
- .text()
- .replace(/{{(.*?)}}/g, function (node, key) {
- return item[key];
- });
- });
- $('.apply-list').eq(0).append(result);
- } else {
- return Promise.reject(new Error(res.msg));
- }
- });
- }
- //点击了换一批
- $('.apply-list-change')[0].addEventListener('click', () => {
- $('.apply-list').eq(0).empty();
- getRecommend();
- });
- //点击了关闭按钮
- $('.apply-close')[0].addEventListener('click', () => {
- localStorage.setItem('isShowRecommend', true);
- $('.apply-wrap').eq(0).hide();
- });
- // 点击下载按钮
- $('.apply-wrap')[0].addEventListener('click', (e) => {
- let id = e.target.dataset.id;
- let downloadUrl = e.target.dataset.url;
- let className = e.target.className;
- if (className === 'apply-down-btn') {
- var pings2 = {
- type: 'downAndInstallApk',
- data: {
- apkUrl: downloadUrl,
- taskUid: id,
- },
- };
- wsss.send(JSON.stringify(pings2));
- }
- });
- // 点击了我知道了
- $('.countdown-btn')[0].addEventListener('click', () => {
- $('.countdown-wrap').eq(0).hide();
- getRecommend();
- });
- // 点击了续时长
- $('.time-lang-btn')[0].addEventListener('click', () => {
- $('.time-lang-wrap').eq(0).hide();
- if (window.__wxjs_environment === 'miniprogram') {
- wx.miniProgram.navigateTo({
- url: `/packageA/order/renew/index?record=` + userCardId,
- });
- } else {
- uni.webView.navigateTo({
- url: '/pages/order/renew?record=' + userCardId,
- });
- }
- });
- /**
- * 初始化广告
- * 因移动端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/' + userCardId,
- headers: {
- Authorization: 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 {
- if (userCardType === 1) {
- uni.webView.navigateTo({
- url: '/pages/order/renewTime',
- });
- } 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 {
- if (userCardType === 1) {
- uni.webView.navigateTo({
- url: '/pages/order/renewTime',
- });
- } else {
- uni.webView.navigateTo({
- url: '/pages/order/order',
- });
- }
- }
- }
- });
- window.onbeforeunload = function () {
- wsss.close();
- decodeWoker.postMessage('close');
- decodeWoker.terminate();
- };
- // 埋点
- function systemBuriedPoint(pointName) {
- $.ajax({
- url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
- headers: {
- Authorization: token,
- },
- type: 'post',
- data: JSON.stringify({
- pointName: pointName,
- }),
- contentType: 'application/json',
- dataType: 'json',
- success: function (res) {},
- });
- }
- 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, '&'),
- );
- // console.log({
- // list: window.phoneSizeList,
- // active: window.activePhoneSize,
- // resolving,
- // });
- const phoneSizeListItemsHtml = templatePhoneSizeItem({
- list: window.phoneSizeList,
- active: window.activePhoneSize,
- resolving,
- });
- $('#phone-size-list').html(phoneSizeListItemsHtml);
- }
- $('#open-set-phone-size-dialog-btn').on('click', async function (e) {
- !window.phoneSizeList.length && (await getPhoneSizeList());
- 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.activePhoneSize = window.currentPhoneSize;
- async function getPhoneSizeList() {
- const response = await $.ajax({
- url:
- baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
- headers: {
- Authorization: token,
- },
- type: 'get',
- dataType: 'json',
- data: {
- userCardId,
- },
- });
- const phoneSizeList = response.data.map(function (v) {
- return {
- id: v.id,
- dpi: v.dpi,
- width: v.width,
- height: v.high,
- };
- });
- window.phoneSizeList = phoneSizeList;
- // 关联上当前云机分辨率
- const currentPhoneSize = phoneSizeList.find(function (v) {
- return (
- window.currentPhoneSize &&
- v.width === window.currentPhoneSize.width &&
- v.height === window.currentPhoneSize.height &&
- v.dpi === window.currentPhoneSize.dpi
- );
- });
- window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
- }
- /*
- getPhoneSizeList().then(function (phoneSizeList) {
- window.phoneSizeList = phoneSizeList;
- // window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
- const currentPhoneSize = window.phoneSizeList.find(function (v) {
- return (
- window.currentPhoneSize &&
- v.width === window.currentPhoneSize.width &&
- v.height === window.currentPhoneSize.height &&
- v.dpi === window.currentPhoneSize.dpi
- );
- });
- window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
- // return updatePhoneSizeListHtml();
- });
- */
- // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
- // direction: 'vertical',
- // slidesPerView: 'auto',
- // loop: false,
- // centeredSlides: true,
- // });
- let lastSetPhone = 0;
- function setPhoneSize(config) {
- if (config.id === currentPhoneSize.id) {
- return;
- }
- if (Date.now() <= lastSetPhone + 1000 * 5) {
- throw new Error('请勿频繁操作');
- }
- lastSetPhone = Date.now();
- // config = Object.assign({}, config, {
- // width: config.width,
- // height: config.height,
- // });
- // 修改云机分辨率
- wsss.send(
- JSON.stringify({
- type: 'setPhoneSize',
- data: {
- id: config.id,
- width: config.width,
- height: config.height,
- dpi: config.dpi,
- },
- }),
- );
- // XXX: 去除了,改为中台发送
- // 通知其他在线端
- // wsss.send(
- // JSON.stringify({
- // type: 'forwardMsg',
- // data: {
- // code: 'phoneSizeChange',pause
- // id: config.id,
- // width: config.width,
- // height: config.height,
- // dpi: config.dpi,
- // desc: '分辨率修改', // 可选
- // },
- // }),
- // );
- // 上报分辨率
- 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) {
- try {
- setPhoneSize(window.activePhoneSize);
- $('#set-phone-size-dialog').removeClass('show');
- } catch (error) {
- $.toast(error.message, 'text');
- }
- });
- </script>
- <script type="text/javascript" src="WXdraw.js"></script>
- <script type="text/javascript" src="aac.js"></script>
- <script type="text/javascript" src="./timer.js"></script>
- </body>
- </html>
|