mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-03-25 16:48:23 +08:00
1 line
28 KiB
JavaScript
1 line
28 KiB
JavaScript
!function(t,o){o.un,o.uns;var i=o.static,n=o.class,a=o.getset,d=(o.__newvec,laya.utils.Browser),l=o.Config,e=(laya.events.Event,laya.events.EventDispatcher),r=laya.resource.HTMLImage,v=laya.utils.Handler,s=laya.display.Input,m=laya.net.Loader,u=laya.net.LocalStorage,c=(laya.maths.Matrix,laya.renders.Render),f=laya.utils.RunDriver,h=laya.media.SoundChannel,p=laya.media.SoundManager,g=laya.net.URL,y=laya.utils.Utils,_=(n(w,"laya.qq.mini.MiniFileMgr",null,"MiniFileMgr$7"),w.isLocalNativeFile=function(i){for(var e=0,t=S.nativefiles.length;e<t;e++)if(-1!=i.indexOf(S.nativefiles[e]))return!0;return!1},w.getFileInfo=function(i){i=w.fakeObj[i];return null==i?null:i},w.read=function(i,e,t,n,o,a){void 0===e&&(e="utf8"),void 0===o&&(o=!1),void 0===a&&(a=""),i=""==(n=void 0===n?"":n)||-1==n.indexOf("http://")&&-1==n.indexOf("https://")?i:w.getFileNativePath(i),w.fs.readFile({filePath:i,encoding:e,success:function(i){null!=t&&t.runWith([0,i])},fail:function(i){i&&""!=n?w.downFiles(n,e,t,n,o,a):null!=t&&t.runWith([1])}})},w.downFiles=function(e,t,n,o,a,l,s){void 0===t&&(t="ascii"),void 0===o&&(o=""),void 0===a&&(a=!1),void 0===l&&(l=""),void 0===s&&(s=!0),w.wxdown({url:e,success:function(i){200===i.statusCode?w.readFile(i.tempFilePath,t,n,o,a,l,s):403===i.statusCode?null!=n&&n.runWith([0,e]):null!=n&&n.runWith([1,i])},fail:function(i){null!=n&&n.runWith([1,i])}}).onProgressUpdate(function(i){null!=n&&n.runWith([2,i.progress])})},w.readFile=function(e,t,n,o,a,i,l){void 0===o&&(o=""),void 0===a&&(a=!1),void 0===i&&(i=""),void 0===l&&(l=!0),w.fs.readFile({filePath:e,encoding:t=void 0===t?"utf8":t,success:function(i){(-1!=e.indexOf("http://")||-1!=e.indexOf("https://"))&&(S.autoCacheFile||a)?(null!=n&&n.runWith([0,i]),w.copyFile(e,o,null,t,l)):null!=n&&n.runWith([0,i])},fail:function(i){i&&null!=n&&n.runWith([1,i])}})},w.downOtherFiles=function(i,e,t,n,o){void 0===t&&(t=""),void 0===n&&(n=!1),void 0===o&&(o=!0),w.wxdown({url:i,success:function(i){200===i.statusCode?(S.autoCacheFile||n)&&-1==t.indexOf("wx.qlogo.cn")&&-1==t.indexOf(".php")?(null!=e&&e.runWith([0,i.tempFilePath]),w.copyFile(i.tempFilePath,t,null,"",o)):null!=e&&e.runWith([0,i.tempFilePath]):null!=e&&e.runWith([1,i])},fail:function(i){null!=e&&e.runWith([1,i])}})},w.downLoadFile=function(i,e,t,n){void 0===e&&(e=""),void 0===n&&(n="ascii"),S.window.navigator.userAgent.indexOf("MiniGame")<0?o.loader.load(i,t):"image"==e||"sound"==e?w.downOtherFiles(i,t,i,!0,!1):w.downFiles(i,n,t,i,!0,e,!1)},w.copyFile=function(t,n,o,a,l){void 0===a&&(a=""),void 0===l&&(l=!0);var i=t.split("/"),s=i[i.length-1],i=w.getFileInfo(n),r=w.getFileNativePath(s);w.fakeObj[n]={md5:s,readyUrl:n,size:0,times:d.now(),encoding:a};var u=w.getCacheUseSize();i?i.readyUrl!=n?w.fs.getFileInfo({filePath:t,success:function(i){l&&52428800<=u+4194304+i.size&&(i.size>S.minClearSize&&(S.minClearSize=i.size),w.onClearCacheRes()),w.deleteFile(t,n,o,a,i.size)},fail:function(i){null!=o&&o.runWith([1,i])}}):null!=o&&o.runWith([0]):w.fs.getFileInfo({filePath:t,success:function(e){l&&52428800<=u+4194304+e.size&&(e.size>S.minClearSize&&(S.minClearSize=e.size),w.onClearCacheRes()),w.fs.copyFile({srcPath:t,destPath:r,success:function(i){w.onSaveFile(n,s,!0,a,o,e.size)},fail:function(i){null!=o&&o.runWith([1,i])}})},fail:function(i){null!=o&&o.runWith([1,i])}})},w.onClearCacheRes=function(){var i,e=S.minClearSize,t=[];for(i in w.filesListObj)"fileUsedSize"!=i&&t.push(w.filesListObj[i]);w.sortOn(t,"times",16);for(var n=0,o=1,a=t.length;o<a;o++){var l=t[o];if(e<=n)break;n+=l.size,w.deleteFile("",l.readyUrl)}},w.sortOn=function(i,t,e){return 16==(e=void 0===e?0:e)?i.sort(function(i,e){return i[t]-e[t]}):18==e?i.sort(function(i,e){return e[t]-i[t]}):i.sort(function(i,e){return i[t]-e[t]})},w.getFileNativePath=function(i){return laya.qq.mini.MiniFileMgr.fileNativeDir+"/"+i},w.deleteFile=function(n,o,a,l,s){void 0===l&&(l=""),void 0===s&&(s=0);var i=w.getFileInfo(o=void 0===o?"":o);i?(i=w.getFileNativePath(i.md5),w.fs.unlink({filePath:i,success:function(i){var e,t=""!=n;""!=n?(e=w.getFileNativePath(n),w.fs.copyFile({srcPath:n,destPath:e,success:function(i){w.onSaveFile(o,n,t,l,a,i.size)},fail:function(i){null!=a&&a.runWith([1,i])}})):w.onSaveFile(o,n,t,l,a,s)},fail:function(i){}})):w.onSaveFile(o,"",!1,l,a)},w.deleteAll=function(){var i,e=[];for(i in w.filesListObj)"fileUsedSize"!=i&&e.push(w.filesListObj[i]);for(var t=1,n=e.length;t<n;t++){var o=e[t];w.deleteFile("",o.readyUrl)}laya.qq.mini.MiniFileMgr.filesListObj&&laya.qq.mini.MiniFileMgr.filesListObj.fileUsedSize&&(laya.qq.mini.MiniFileMgr.filesListObj.fileUsedSize=0),laya.qq.mini.MiniFileMgr.writeFilesList("",JSON.stringify({}),!1)},w.onSaveFile=function(i,e,t,n,o,a){void 0===t&&(t=!0),void 0===n&&(n=""),void 0===a&&(a=0);var l=i;null==w.filesListObj.fileUsedSize&&(w.filesListObj.fileUsedSize=0),t?(w.getFileNativePath(e),w.filesListObj[l]={md5:e,readyUrl:i,size:a,times:d.now(),encoding:n},w.filesListObj.fileUsedSize=parseInt(w.filesListObj.fileUsedSize)+a,w.writeFilesList(l,JSON.stringify(w.filesListObj),!0),null!=o&&o.runWith([0])):w.filesListObj[l]&&(a=parseInt(w.filesListObj[l].size),w.filesListObj.fileUsedSize=parseInt(w.filesListObj.fileUsedSize)-a,w.fakeObj[l].md5==w.filesListObj[l].md5&&delete w.fakeObj[l],delete w.filesListObj[l],w.writeFilesList(l,JSON.stringify(w.filesListObj),!1),null!=o&&o.runWith([0]))},w.writeFilesList=function(i,e,t){w.fs.writeFile({filePath:w.fileNativeDir+"/"+w.fileListName,encoding:"utf8",data:e,success:function(i){},fail:function(i){}}),!S.isZiYu&&S.isPosMsgYu&&S.window.qq.postMessage&&S.window.qq.postMessage({url:i,data:w.filesListObj[i],isLoad:"filenative",isAdd:t})},w.getCacheUseSize=function(){return w.filesListObj&&w.filesListObj.fileUsedSize?w.filesListObj.fileUsedSize:0},w.existDir=function(i,e){w.fs.mkdir({dirPath:i,success:function(i){null!=e&&e.runWith([0,{data:JSON.stringify({})}])},fail:function(i){-1!=i.errMsg.indexOf("file already exists")?w.readSync(w.fileListName,"utf8",e):null!=e&&e.runWith([1,i])}})},w.readSync=function(i,e,t,n){void 0===e&&(e="utf8"),void 0===n&&(n="");var o,i=w.getFileNativePath(i);try{o=w.fs.readFileSync(i,e),null!=t&&t.runWith([0,{data:o}])}catch(i){null!=t&&t.runWith([1])}},w.setNativeFileDir=function(i){w.fileNativeDir=S.window.qq.env.USER_DATA_PATH+i},w.filesListObj={},w.fakeObj={},w.fileNativeDir=null,w.fileListName="layaairfiles.txt",w.ziyuFileData={},w.ziyuFileTextureData={},w.loadPath="",w.DESCENDING=2,w.NUMERIC=16,i(w,["fs",function(){return this.fs=S.window.qq.getFileSystemManager()},"wxdown",function(){return this.wxdown=S.window.qq.downloadFile}]),w);function w(){}var F=(n(C,"laya.qq.mini.MiniImage",null,"MiniImage$7"),C.prototype._loadImage=function(i){var e=this;if(S.isZiYu)C.onCreateImage(i,e,!0);else{var t,n,o=!1;if(_.isLocalNativeFile(i)){if(-1==i.indexOf("http://")&&-1==i.indexOf("https://")||(i=""!=_.loadPath?i.split(_.loadPath)[1]:(n=i,(i=""!=(t=""!=g.rootPath?g.rootPath:g.basePath)?i.split(t)[1]:i)||n)),S.subNativeFiles&&0==S.subNativeheads.length)for(var a in S.subNativeFiles){var l=S.subNativeFiles[a];S.subNativeheads=S.subNativeheads.concat(l);for(var s=0;s<l.length;s++)S.subMaps[l[s]]=a+"/"+l[s]}!S.subNativeFiles||-1==i.indexOf("/")||(t=i.split("/")[0]+"/")&&-1!=S.subNativeheads.indexOf(t)&&(n=S.subMaps[t],i=i.replace(t,n))}else o=!0,i=g.formatURL(i);_.getFileInfo(i)?C.onCreateImage(i,e,!o):-1==i.indexOf("http://")&&-1==i.indexOf("https://")||S.isZiYu?C.onCreateImage(i,e,!0):_.downOtherFiles(encodeURI(i),new v(C,C.onDownImgCallBack,[i,e]),i)}},C.onDownImgCallBack=function(i,e,t,n){void 0===n&&(n=""),t?e.onError(null):C.onCreateImage(i,e,!1,n)},C.onCreateImage=function(e,t,i,n){var o,a,l;function s(){l.onload=null,l.onerror=null,delete t.imgCache[e]}void 0===i&&(i=!1),void 0===n&&(n=""),a=S.autoCacheFile?i?S.isZiYu?(o=g.formatURL(e),_.ziyuFileTextureData[o]||e):e:""!=n?n:(a=_.getFileInfo(e).md5,_.getFileNativePath(a)):i?e:n,null==t.imgCache&&(t.imgCache={});i=function(){s(),delete _.fakeObj[e],delete _.filesListObj[e],t.onLoaded(l)},n=function(){s(),t.event("error","Load image failed")};"nativeimage"==t._type?((l=new d.window.Image).crossOrigin="",l.onload=i,l.onerror=n,l.src=a,t.imgCache[e]=l):new r.create(a,{onload:i,onerror:n,onCreate:function(i){l=i,t.imgCache[e]=i}})},C);function C(){}var E=(n(q,"laya.qq.mini.MiniInput",null,"MiniInput$7"),q._createInputElement=function(){s._initInput(s.area=d.createElement("textarea")),s._initInput(s.input=d.createElement("input")),s.inputContainer=d.createElement("div"),s.inputContainer.style.position="absolute",s.inputContainer.style.zIndex=1e5,d.container.appendChild(s.inputContainer),s.inputContainer.setPos=function(i,e){s.inputContainer.style.left=i+"px",s.inputContainer.style.top=e+"px"},o.stage.on("resize",null,q._onStageResize),qq.onWindowResize&&qq.onWindowResize(function(i){t.dispatchEvent&&t.dispatchEvent("resize")}),p._soundClass=N,p._musicClass=N;var i=S.systemInfo.model,e=S.systemInfo.system;-1!=i.indexOf("iPhone")&&(d.onIPhone=!0,d.onIOS=!0,d.onIPad=!0,d.onAndroid=!1),-1==e.indexOf("Android")&&-1==e.indexOf("Adr")||(d.onAndroid=!0,d.onIPhone=!1,d.onIOS=!1,d.onIPad=!1)},q._onStageResize=function(){o.stage._canvasTransform.identity().scale(d.width/c.canvas.width/f.getPixelRatio(),d.height/c.canvas.height/f.getPixelRatio())},q.wxinputFocus=function(i){var e=s.inputElement.target;e&&!e.editable||(S.window.qq.offKeyboardConfirm(),S.window.qq.offKeyboardInput(),S.window.qq.showKeyboard({defaultValue:e.text,maxLength:e.maxChars,multiple:e.multiline,confirmHold:!0,confirmType:"done",success:function(i){},fail:function(i){}}),S.window.qq.onKeyboardConfirm(function(i){i=i?i.value:"";e.text=i,e.event("input"),laya.qq.mini.MiniInput.inputEnter()}),S.window.qq.onKeyboardInput(function(i){i=i?i.value:"";e.multiline||-1==i.indexOf("\n")?(e.text=i,e.event("input")):laya.qq.mini.MiniInput.inputEnter()}))},q.inputEnter=function(){s.inputElement.target.focus=!1},q.wxinputblur=function(){q.hideKeyboard()},q.hideKeyboard=function(){S.window.qq.offKeyboardConfirm(),S.window.qq.offKeyboardInput(),S.window.qq.hideKeyboard({success:function(i){console.log("隐藏键盘")},fail:function(i){console.log("隐藏键盘出错:"+(i?i.errMsg:""))}})},q);function q(){}var b=(n(L,"laya.qq.mini.MiniLocalStorage",null,"MiniLocalStorage$7"),L.__init__=function(){L.items=L},L.setItem=function(e,t){try{qq.setStorageSync(e,t)}catch(i){qq.setStorage({key:e,data:t})}},L.getItem=function(i){return qq.getStorageSync(i)},L.setJSON=function(i,e){L.setItem(i,e)},L.getJSON=function(i){return L.getItem(i)},L.removeItem=function(i){qq.removeStorageSync(i)},L.clear=function(){qq.clearStorageSync()},L.getStorageInfoSync=function(){try{var i=qq.getStorageInfoSync();return console.log(i.keys),console.log(i.currentSize),console.log(i.limitSize),i}catch(i){}return null},L.support=!0,L.items=null,L);function L(){}n(x,"laya.qq.mini.MiniLocation",null,"MiniLocation$7"),x.__init__=function(){S.window.navigator.geolocation.getCurrentPosition=x.getCurrentPosition,S.window.navigator.geolocation.watchPosition=x.watchPosition,S.window.navigator.geolocation.clearWatch=x.clearWatch},x.getCurrentPosition=function(e,i,t){var n;(n={success:function(i){null!=e&&e(i)}}).fail=i,S.window.qq.getLocation(n)},x.watchPosition=function(i,e,t){var n;return x._curID++,(n={}).success=i,n.error=e,x._watchDic[x._curID]=n,o.timer.loop(1e3,null,x._myLoop),x._curID},x.clearWatch=function(i){delete x._watchDic[i],x._hasWatch()||o.timer.clear(null,x._myLoop)},x._hasWatch=function(){for(var i in x._watchDic)if(x._watchDic[i])return!0;return!1},x._myLoop=function(){x.getCurrentPosition(x._mySuccess,x._myError)},x._mySuccess=function(i){var e,t={};for(e in t.coords=i,t.timestamp=d.now(),x._watchDic)x._watchDic[e].success&&x._watchDic[e].success(t)},x._myError=function(i){for(var e in x._watchDic)x._watchDic[e].error&&x._watchDic[e].error(i)},x._watchDic={},x._curID=0;function x(){}!function(){function i(i,e){this.videoend=!1,this.videourl="",this.videoElement=null,this.onPlayFunc=null,this.onEndedFunC=null,this._duration=NaN,this.position=NaN,this.videoElement=S.window.qq.createVideo({width:i=void 0===i?320:i,height:e=void 0===e?240:e,autoplay:!0})}n(i,"laya.qq.mini.MiniVideo",null,"MiniVideo$5");var e=i.prototype;e.on=function(i,e,t){"loadedmetadata"==i?(this.onPlayFunc=t.bind(e),this.videoElement.onPlay=this.onPlayFunction.bind(this)):"ended"==i&&(this.onEndedFunC=t.bind(e),this.videoElement.onEnded=this.onEndedFunction.bind(this)),this.videoElement.onTimeUpdate=this.onTimeUpdateFunc.bind(this)},e.onTimeUpdateFunc=function(i){this.position=i.position,this._duration=i.duration},e.onPlayFunction=function(){this.videoElement&&(this.videoElement.readyState=200),console.log("=====视频加载完成========"),null!=this.onPlayFunc&&this.onPlayFunc()},e.onEndedFunction=function(){this.videoElement&&(this.videoend=!0,console.log("=====视频播放完毕========"),null!=this.onEndedFunC&&this.onEndedFunC())},e.off=function(i,e,t){"loadedmetadata"==i?(this.onPlayFunc=t.bind(e),this.videoElement.offPlay=this.onPlayFunction.bind(this)):"ended"==i&&(this.onEndedFunC=t.bind(e),this.videoElement.offEnded=this.onEndedFunction.bind(this))},e.load=function(i){this.videoElement&&(this.videoElement.src=i)},e.play=function(){this.videoElement&&(this.videoend=!1,this.videoElement.play())},e.pause=function(){this.videoElement&&(this.videoend=!0,this.videoElement.pause())},e.size=function(i,e){this.videoElement&&(this.videoElement.width=i,this.videoElement.height=e)},e.destroy=function(){this.videoElement&&this.videoElement.destroy(),this.videoElement=null,this.onEndedFunC=null,this.onPlayFunc=null,this.videoend=!1,this.videourl=null},e.reload=function(){this.videoElement&&(this.videoElement.src=this.videourl)},a(0,e,"duration",function(){return this._duration}),a(0,e,"paused",function(){return!!this.videoElement&&this.videoElement.paused}),a(0,e,"loop",function(){return!!this.videoElement&&this.videoElement.loop},function(i){this.videoElement&&(this.videoElement.loop=i)}),a(0,e,"currentTime",function(){return this.videoElement?this.videoElement.initialTime:0},function(i){this.videoElement&&(this.videoElement.initialTime=i)}),a(0,e,"ended",function(){return this.videoend}),a(0,e,"muted",function(){return!!this.videoElement&&this.videoElement.muted},function(i){this.videoElement&&(this.videoElement.muted=i)}),a(0,e,"videoWidth",function(){return this.videoElement?this.videoElement.width:0}),a(0,e,"videoHeight",function(){return this.videoElement?this.videoElement.height:0}),a(0,e,"playbackRate",function(){return this.videoElement?this.videoElement.playbackRate:0},function(i){this.videoElement&&(this.videoElement.playbackRate=i)}),a(0,e,"x",function(){return this.videoElement?this.videoElement.x:0},function(i){this.videoElement&&(this.videoElement.x=i)}),a(0,e,"y",function(){return this.videoElement?this.videoElement.y:0},function(i){this.videoElement&&(this.videoElement.y=i)}),a(0,e,"currentSrc",function(){return this.videoElement.src}),i.__init__=function(){laya.device.media.Video=i}}();var S=(n(O,"laya.qq.mini.QQMiniAdapter"),O.getJson=function(i){return JSON.parse(i)},O.init=function(i,e){if(void 0===i&&(i=!1),void 0===e&&(e=!1),!O._inited&&(O._inited=!0,(O.window=t).hasOwnProperty("qq")&&!(O.window.navigator.userAgent.indexOf("MiniGame")<0))){O.isZiYu=e,O.isPosMsgYu=i,O.EnvConfig={};try{laya.webgl.resource.WebGLCanvas.premulAlpha=!0}catch(i){}if(O.isZiYu||(_.setNativeFileDir("/layaairGame"),_.existDir(_.fileNativeDir,v.create(O,O.onMkdirCallBack))),"ios 10.1.1"===(O.systemInfo=O.window.qq.getSystemInfoSync()).system.toLowerCase())try{laya.webgl.resource.WebGLCharImage.canUseCanvas=!1}catch(i){}O.window.focus=function(){},o._getUrlPath=function(){},o.getUrlPath=function(){},O.window.logtime=function(i){},O.window.alertTimeLog=function(i){},O.window.resetShareInfo=function(){},O.window.CanvasRenderingContext2D=function(){},O.window.CanvasRenderingContext2D.prototype=O.window.qq.createCanvas().getContext("2d").__proto__,O.window.document.body.appendChild=function(){},O.EnvConfig.pixelRatioInt=0,f.getPixelRatio=O.pixelRatio,O._preCreateElement=d.createElement,d.createElement=O.createElement,f.createShaderCondition=O.createShaderCondition,y.parseXMLFromString=O.parseXMLFromString,s._createInputElement=E._createInputElement,O.EnvConfig.load=m.prototype.load,m.prototype.load=I.prototype.load,m.prototype._loadImage=F.prototype._loadImage,(u._baseClass=b).__init__(),O.onReciveData(),l.useRetinalCanvas=!0}},O.onReciveData=function(){laya.qq.mini.QQMiniAdapter.isZiYu&&O.window.qq.onMessage(function(i){"opendatacontext"==i.isLoad?i.url&&(_.ziyuFileData[i.url]=i.atlasdata,_.ziyuFileTextureData[i.imgReadyUrl]=i.imgNativeUrl):"openJsondatacontext"==i.isLoad?i.url&&(_.ziyuFileData[i.url]=i.atlasdata):"openJsondatacontextPic"==i.isLoad&&(_.ziyuFileTextureData[i.imgReadyUrl]=i.imgNativeUrl)})},O.measureText=function(i){i=O._measureText(i);return i||(i={width:16},console.warn("-------微信获取文字宽度失败----等待修复---------")),i},O.getUrlEncode=function(i,e){return"arraybuffer"==e?"":"utf8"},O.downLoadFile=function(i,e,t,n){void 0===e&&(e=""),void 0===n&&(n="utf8"),_.getFileInfo(i)?null!=t&&t.runWith([0]):_.downLoadFile(i,e,t,n)},O.remove=function(i,e){_.deleteFile("",i,e,"",0)},O.removeAll=function(){_.deleteAll()},O.hasNativeFile=function(i){return _.isLocalNativeFile(i)},O.getFileInfo=function(i){return _.getFileInfo(i)},O.getFileList=function(){return _.filesListObj},O.exitMiniProgram=function(){O.window.qq.exitMiniProgram()},O.onMkdirCallBack=function(i,e){i||(_.filesListObj=JSON.parse(e.data),_.fakeObj=JSON.parse(e.data))},O.pixelRatio=function(){if(!O.EnvConfig.pixelRatioInt)try{return O.EnvConfig.pixelRatioInt=O.systemInfo.pixelRatio,O.systemInfo.pixelRatio}catch(i){}return O.EnvConfig.pixelRatioInt},O.createElement=function(i){var e;if("canvas"==i)return 1==O.idx?O.isZiYu?(e=O.window.sharedCanvas).style={}:e=O.window.canvas:e=O.window.qq.createCanvas(),O.idx++,e;if("textarea"==i||"input"==i)return O.onCreateInput(i);if("div"!=i)return O._preCreateElement(i);i=O._preCreateElement(i);return i.contains=function(i){return null},i.removeChild=function(i){},i},O.onCreateInput=function(i){i=O._preCreateElement(i);return i.focus=E.wxinputFocus,i.blur=E.wxinputblur,i.style={},i.value=0,i.parentElement={},i.placeholder={},i.type={},i.setColor=function(i){},i.setType=function(i){},i.setFontFace=function(i){},i.addEventListener=function(i){},i.contains=function(i){return null},i.removeChild=function(i){},i},O.createShaderCondition=function(i){var e=this;return function(){return e[i.replace("this.","")]}},O.sendAtlasToOpenDataContext=function(i){if(!laya.qq.mini.QQMiniAdapter.isZiYu){var e=m.getRes(g.formatURL(i));if(!e)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";e.meta.image.split(",");if(e.meta&&e.meta.image)for(var t=e.meta.image.split(","),n=0<=i.indexOf("/")?"/":"\\",n=i.lastIndexOf(n),o=0<=n?i.substr(0,n+1):"",a=0,l=t.length;a<l;a++)t[a]=o+t[a];else t=[i.replace(".json",".png")];for(a=0;a<t.length;a++){var s=t[a];O.postInfoToContext(i,s,e)}}},O.postInfoToContext=function(i,e,t){var n={frames:t.frames,meta:t.meta},t=e,e=_.getFileInfo(g.formatURL(e)),o=e?(o=e.md5,_.getFileNativePath(o)):t;if(!o)throw"获取图集的磁盘url路径不存在!";O.window.qq.postMessage({url:i,atlasdata:n,imgNativeUrl:o,imgReadyUrl:t,isLoad:"opendatacontext"})},O.sendSinglePicToOpenDataContext=function(i){var e,t=g.formatURL(i),n=_.getFileInfo(t);if(n?(e=n.md5,e=_.getFileNativePath(e),i=t):e=i,!e)throw"获取图集的磁盘url路径不存在!";O.window.qq.postMessage({url:i,imgNativeUrl:e,imgReadyUrl:i,isLoad:"openJsondatacontextPic"})},O.sendJsonDataToDataContext=function(i){if(!laya.qq.mini.QQMiniAdapter.isZiYu){var e=m.getRes(i);if(!e)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";O.window.qq.postMessage({url:i,atlasdata:e,isLoad:"openJsondatacontext"})}},O.EnvConfig=null,O.window=null,O._preCreateElement=null,O._inited=!1,O.systemInfo=null,O.isZiYu=!1,O.isPosMsgYu=!1,O.autoCacheFile=!0,O.minClearSize=5242880,O.subNativeFiles=null,O.subNativeheads=[],O.subMaps=[],O.AutoCacheDownFile=!1,O._measureText=null,O.parseXMLFromString=function(i){var e;i=i.replace(/>\s+</g,"><");try{e=(new t.Parser.DOMParser).parseFromString(i,"text/xml")}catch(i){throw"需要引入xml解析库文件"}return e},O.idx=1,i(O,["nativefiles",function(){return this.nativefiles=["layaNativeDir","wxlocal"]}]),O);function O(){}!function(o){function a(){a.__super.call(this)}n(a,"laya.qq.mini.MiniAccelerator",o,"MiniAccelerator$7");var i=a.prototype;i.on=function(i,e,t,n){return o.prototype.on.call(this,i,e,t,n),a.startListen(this.onDeviceOrientationChange),this},i.off=function(i,e,t,n){return void 0===n&&(n=!1),this.hasListener(i)||a.stopListen(),o.prototype.off.call(this,i,e,t,n)},a.__init__=function(){try{var i=laya.device.motion.Accelerator;if(!i)return;i.prototype.on=a.prototype.on,i.prototype.off=a.prototype.off}catch(i){}},a.startListen=function(i){if(a._callBack=i,!a._isListening){a._isListening=!0;try{S.window.qq.onAccelerometerChange(laya.qq.mini.MiniAccelerator.onAccelerometerChange)}catch(i){}}},a.stopListen=function(){a._isListening=!1;try{S.window.qq.stopAccelerometer({})}catch(i){}},a.onAccelerometerChange=function(i){var e={};e.acceleration=i,e.accelerationIncludingGravity=i,e.rotationRate={},null!=a._callBack&&a._callBack(e)},a._isListening=!1,a._callBack=null}(e);var I=(n(P,"laya.qq.mini.MiniLoader",e,"MiniLoader$7"),P.prototype.load=function(i,e,t,n,o){void 0===t&&(t=!0),void 0===o&&(o=!1);var a=this;if(0===(a._url=i).indexOf("data:image")?a._type=e="image":a._type=e=e||a.getTypeFromUrl(i),a._cache=t,a._data=null,!o&&m.loadedMap[g.formatURL(i)])return a._data=m.loadedMap[g.formatURL(i)],this.event("progress",1),void this.event("complete",a._data);if(null!=m.parserMap[e])return a._customParse=!0,void(m.parserMap[e]instanceof laya.utils.Handler?m.parserMap[e].runWith(this):m.parserMap[e].call(null,this));var l=S.getUrlEncode(i,e),s=y.getFileExtension(i);if(-1!=P._fileTypeArr.indexOf(s)||"image"==e)S.EnvConfig.load.call(this,i,e,t,n,o);else if(S.isZiYu&&!_.ziyuFileData[i]&&(i=g.formatURL(i)),S.isZiYu&&_.ziyuFileData[i]){s=_.ziyuFileData[i];a.onLoaded(s)}else if(_.getFileInfo(g.formatURL(i))){var r=_.getFileInfo(g.formatURL(i));r.encoding=null==r.encoding?"utf8":r.encoding;var u=_.getFileNativePath(r.md5);_.readFile(u,r.encoding,new v(P,P.onReadNativeCallBack,[l,i,e,t,n,o,a]),g.formatURL(i))}else{if(_.isLocalNativeFile(i)){if(S.subNativeFiles&&0==S.subNativeheads.length)for(var d in S.subNativeFiles){var c=S.subNativeFiles[d];S.subNativeheads=S.subNativeheads.concat(c);for(var f=0;f<c.length;f++)S.subMaps[c[f]]=d+"/"+c[f]}return!S.subNativeFiles||-1==i.indexOf("/")||(u=i.split("/")[0]+"/")&&-1!=S.subNativeheads.indexOf(u)&&(h=S.subMaps[u],i=i.replace(u,h)),void _.read(i,l,new v(P,P.onReadNativeCallBack,[l,i,e,t,n,o,a]))}var h=i;-1!=g.formatURL(i).indexOf(S.window.qq.env.USER_DATA_PATH)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")||S.AutoCacheDownFile?(r=_.getFileInfo(i))?(r.encoding=null==r.encoding?"utf8":r.encoding,_.readFile(r.url,l,new v(P,P.onReadNativeCallBack,[l,i,e,t,n,o,a]),i)):"image"==a.type||"htmlimage"==a.type?S.EnvConfig.load.call(a,i,e,t,n,o):(i=g.formatURL(i),"image"!=e&&(-1==i.indexOf("http://")&&-1==i.indexOf("https://")||_.isLocalNativeFile(i))?_.readFile(i,l,new v(P,P.onReadNativeCallBack,[l,i,e,t,n,o,a]),i):_.downFiles(encodeURI(i),l,new v(P,P.onReadNativeCallBack,[l,i,e,t,n,o,a]),i,t)):S.EnvConfig.load.call(a,h,e,t,n,o)}},P.onReadNativeCallBack=function(i,e,t,n,o,a,l,s,r){void 0===n&&(n=!0),void 0===a&&(a=!1),(s=void 0===s?0:s)?1==s&&(console.log("-----------本地加载失败,尝试外网加载----"),S.EnvConfig.load.call(l,e,t,n,o,a)):(r="json"==t||"atlas"==t?S.getJson(r.data):"xml"==t?y.parseXMLFromString(r.data):r.data,!S.isZiYu&&S.isPosMsgYu&&"arraybuffer"!=t&&S.window.qq&&S.window.qq.postMessage({url:e,data:r,isLoad:"filedata"}),l.onLoaded(r))},i(P,["_fileTypeArr",function(){return this._fileTypeArr=["png","jpg","bmp","jpeg","gif"]}]),P);function P(){P.__super.call(this)}var N=function(){function l(){this._sound=null,this.url=null,this.loaded=!1,this.readyUrl=null,l.__super.call(this)}n(l,"laya.qq.mini.MiniSound",e,"MiniSound$7");var i=l.prototype;return i.load=function(i){if(_.isLocalNativeFile(i)?-1==i.indexOf("http://")&&-1==i.indexOf("https://")||(""!=_.loadPath?i=i.split(_.loadPath)[1]:""!=(e=""!=g.rootPath?g.rootPath:g.basePath)&&(i=i.split(e)[1])):i=g.formatURL(i),this.url=i,this.readyUrl=i,l._audioCache[this.readyUrl])this.event("complete");else if(S.autoCacheFile&&_.getFileInfo(i))this.onDownLoadCallBack(i,0);else if(S.autoCacheFile)if(_.isLocalNativeFile(i)){var e,t=i;if(i=(i=""!=(e=""!=g.rootPath?g.rootPath:g.basePath)?i.split(e)[1]:i)||t,S.subNativeFiles&&0==S.subNativeheads.length)for(var n in S.subNativeFiles){var o=S.subNativeFiles[n];S.subNativeheads=S.subNativeheads.concat(o);for(var a=0;a<o.length;a++)S.subMaps[o[a]]=n+"/"+o[a]}!S.subNativeFiles||-1==i.indexOf("/")||(e=i.split("/")[0]+"/")&&-1!=S.subNativeheads.indexOf(e)&&(t=S.subMaps[e],i=i.replace(e,t)),this.onDownLoadCallBack(i,0)}else _.downOtherFiles(i,v.create(this,this.onDownLoadCallBack,[i]),i);else this.onDownLoadCallBack(i,0)},i.onDownLoadCallBack=function(i,e){var t;e?this.event("error"):(S.autoCacheFile?(t=(e=_.getFileInfo(i))&&e.md5?(t=e.md5,_.getFileNativePath(t)):i,this._sound=l._createSound(),this._sound.src=this.url=t):(this._sound=l._createSound(),this._sound.src=i),this._sound.onCanplay(l.bindToThis(this.onCanPlay,this)),this._sound.onError(l.bindToThis(this.onError,this)))},i.onError=function(i){try{console.log("-----1---------------minisound-----id:"+l._id),console.log(i)}catch(i){console.log("-----2---------------minisound-----id:"+l._id),console.log(i)}this.event("error"),this._sound.offError(null)},i.onCanPlay=function(){this.loaded=!0,this.event("complete"),this._sound.offCanplay(null)},i.play=function(i,e){var t;void 0===i&&(i=0),void 0===e&&(e=0),n=this.url==p._tMusic?(l._musicAudio||(l._musicAudio=l._createSound()),l._musicAudio):l._audioCache[this.readyUrl]?l._audioCache[this.readyUrl]._sound:l._createSound(),S.autoCacheFile&&_.getFileInfo(this.url)?(t=_.getFileInfo(this.url).md5,n.src=this.url=_.getFileNativePath(t)):n.src=this.url;var n=new M(n,this);return n.url=this.url,n.loops=e,n.loop=0===e,n.startTime=i,n.play(),p.addChannel(n),n},i.dispose=function(){var i=l._audioCache[this.readyUrl];i&&(i.src="",i._sound&&(i._sound.destroy(),i._sound=null,i=null),delete l._audioCache[this.readyUrl])},a(0,i,"duration",function(){return this._sound.duration}),l._createSound=function(){return l._id++,S.window.qq.createInnerAudioContext()},l.bindToThis=function(i,e){return i.bind(e)},l._musicAudio=null,l._id=0,l._audioCache={},l}(),M=function(){function t(i,e){this._audio=null,this._onEnd=null,this._miniSound=null,t.__super.call(this),this._audio=i,this._miniSound=e,this._onEnd=t.bindToThis(this.__onEnd,this),i.onEnded(this._onEnd)}n(t,"laya.qq.mini.MiniSoundChannel",h,"MiniSoundChannel$7");var i=t.prototype;return i.__onEnd=function(){if(1==this.loops)return this.completeHandler&&(o.timer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event("complete");0<this.loops&&this.loops--,this.startTime=0,this.play()},i.play=function(){this.isStopped=!1,p.addChannel(this),this._audio.play()},i.stop=function(){this.isStopped=!0,p.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.pause(),this._audio.offEnded(null),this._audio=null,this._miniSound=null,this._onEnd=null)},i.pause=function(){this.isStopped=!0,this._audio.pause()},i.resume=function(){this._audio&&(this.isStopped=!1,p.addChannel(this),this._audio.play())},a(0,i,"startTime",null,function(i){this._audio&&(this._audio.startTime=i)}),a(0,i,"autoplay",function(){return this._audio.autoplay},function(i){this._audio.autoplay=i}),a(0,i,"position",function(){return this._audio?this._audio.currentTime:0}),a(0,i,"duration",function(){return this._audio?this._audio.duration:0}),a(0,i,"loop",function(){return this._audio.loop},function(i){this._audio.loop=i}),a(0,i,"volume",function(){return this._audio?this._audio.volume:1},function(i){this._audio&&(this._audio.volume=i)}),t.bindToThis=function(i,e){return i.bind(e)},t}()}(window,(document,Laya)),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(i,e){"use strict";for(var t in Object.defineProperty(e,"__esModule",{value:!0}),Laya){var n=Laya[t];n&&n.__isclass&&(e[t]=n)}}); |