Loading...
el:"PCAM00",value:"RENO"},{label:"PCKM00",value:"RENO2"},{label:"PCDM10",value:"RENOOZ"},{label:"PCPM00",value:"RENO3"},{label:"PCRM00",value:"RENO3 Pro"},{label:"PACM00",value:"R15"},{label:"PBCM10",value:"R15X"},{label:"PBEM00",value:"R17"},{label:"PCDM/DT00",value:"R17 Pro"},{label:"PCGM00",value:"K3"},{label:"PCNM00",value:"K5"},{label:"PAFM00",value:"Find X"}]}];function x(){const e=navigator.userAgent,l=e.indexOf("Android")>-1||e.indexOf("Linux")>-1;return e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?"ios":l?"android":""}function S(e){const l=e.match(/iphone/i)=="iphone",o=e.match(/huawei/i)=="huawei",n=e.match(/honor/i)=="honor",t=e.match(/oppo/i)=="oppo",i=e.match(/pacm00/i)=="pacm00",a=e.match(/vivo/i)=="vivo",v=e.match(/mi\s/i)=="mi ",b=e.match(/mix\s/i)=="mix ",P=e.match(/redmi/i)=="redmi",g=e.match(/sm-/i)=="sm-",m=e.match(/lg/i)=="lg";return l?"iPhone":o||n?"Huawei":t||i?"oppo":a?"vivo":v||P||b?"xiaomi":g?"Samsung":m?"LG":"未知手机品牌"}const E=()=>{const e=window.navigator.userAgent,l=x();let o="";e.split(")")[0].includes("HMSCore")&&(o=e.split(")")[0].split("HMSCore")[0].split(";"));let n=o[o.length-2],t;if(l=="ios"){const i=[["430,932,3","A17","iPhone 15 Pro Max"],["393,852,3","A17","iPhone 15 Pro"],["430,932,3","A16","iPhone 15 Plus"],["393,852,3","A16","iPhone 15"],["430,932,3","A15","iPhone 14 Pro Max"],["393,852,3","A15","iPhone 14 Pro"],["375,812,3","A15","iPhone 13(12) min"],["428,926,3","A14","iPhone 14(12/13) Plus"],["390,844,3","A14","iPhone 14(12/13)"],["414,896,3","A13","iPhone 11 Pro Max(Xs Max)"],["375,812,3","A13","iPhone 11 Pro(X/Xs)"],["414,896,2","A13","iPhone 11(XR)"],["414,736,3","A12","iPhone 8(7/6s) Plus"],["375,667,2","A11","iPhone 8(7/6)"],["320,568,2","A11","iPhone 5(s/se)"],["320,480,2","A10","iPhone 4(s)"]],a=document.createElement("canvas"),v=a.getContext("experimental-webgl"),b=v.getExtension("WEBGL_debug_renderer_info"),P=v.getParameter(b.UNMASKED_RENDERER_WEBGL),g=window.screen.width,m=window.screen.height,w=window.devicePixelRatio,f=g+","+m+","+w;i.some(c=>{if(c[0]===f&&P.indexOf(c[1])>-1)return n=c[2],!0;c[0]===f&&!n&&(n=c[2])}),n?t=n:t="iOS未知型号"}else if(l=="android"){let i=-1;const a=e.split(";");for(let v=0;v0){i=v;break}i>-1&&(n=a[i].substring(0,a[i].indexOf("Build/"))),t=`手机品牌:${S(e.toLowerCase())},手机型号:未知`,typeof n=="string"&&M.map(v=>{v.type==S(e.toLowerCase())&&v.modelNumber.map(b=>{b.label==n.trim()&&(t=`手机品牌:${S(e.toLowerCase())},手机型号:${b.value}`)})})}return t=t||"未获取到设备信息",t};function L(e){document.readyState==="complete"||document.readyState==="interactive"?e():document.addEventListener("DOMContentLoaded",e,!1)}class V{constructor({env:l,baseInfo:o,log:n=!1,enable:t=!0}){A(this,"uploadErrorCount",0);A(this,"baseInfo");A(this,"enable",!0);A(this,"log",!1);A(this,"uploadQueue",[]);const i=p();this.log=n;const a=h()||d();if(this.baseInfo=Object.assign({},o,{deviceInfo:navigator.appVersion.replace(/.[^\(\)]+\((.[^\(\)]+)\).*/,"$1"),uuid:a,clientType:"h5",i_code:i,uniqueKey:"",pageUrl:window.location.href,phoneInfo:E(),siteId:window.siteID,userName:window.localStorage.getItem("userName")}),l!=="prod")return this.enable=!1,this;this.enable=t,this.enableToggle(this.enable)}config(l){this.baseInfo=Object.assign({},this.baseInfo,l)}onClick(l){const o=l.target&&l.target.getAttribute("data-log");o&&this.upload(o)}eventToggle(l){L(()=>{l?document.body.addEventListener("click",this.onClick,!1):document.body.removeEventListener("click",this.onClick,!1)})}enableToggle(l){this.enable=l,this.errorCapture(l),this.eventToggle(l)}onErrorCb(l){this.upload({eventName:"global_error",params:JSON.stringify({message:l.message,error:l.error}),typeName:"TYLogUploadEventTypeIndex"})}onunhandledrejection(l){this.upload({eventName:"global_error",params:JSON.stringify({message:l.reason||"default: Unhandled promise rejection"}),typeName:"TYLogUploadEventTypeIndex"})}errorCapture(l){l?(window.onerror=(o,n,t,i,a)=>(this.upload({eventName:"global_error",params:JSON.stringify({message:o,source:n,lineno:t,colno:i,error:a}),typeName:"TYLogUploadEventTypeIndex"}),!1),window.addEventListener("error",this.onErrorCb,!1),window.addEventListener("unhandledrejection",this.onunhandledrejection,!1)):(window.onerror=()=>!1,window.removeEventListener("error",this.onErrorCb,!1),window.removeEventListener("unhandledrejection",this.onunhandledrejection,!1))}async uploadAll(){if(!this.enable||!this.uploadQueue.length)return;const l=this.uploadQueue[0];await this.upload(l)}async upload(l,o={}){if(!this.enable)return!1;let n="",t="",i="";if(typeof l=="string")try{({eventName:n,params:t,typeName:i}=JSON.parse(l))}catch{return console.warn("埋点参数解析出错",l),!0}else({eventName:n,params:t,typeName:i}=l);if(!n||!i)return console.warn("埋点参数解析出错, 缺失 eventName 或 typeName",l),!0;const a={jsonInfo:{reportInfo:{eventName:n,params:t},baseInfo:{userAgent:navigator.userAgent,...this.baseInfo,pageUrl:window.location.href,typeName:i,requestTime:s(),uniqueKey:d(),...o}}};return a.jsonInfo.baseInfo.userName||(a.jsonInfo.baseInfo.userName=window.localStorage.getItem("userName")||""),this.log&&console.log("log: ",a),await r({url:u.url,data:a,retry:3,onSuccess:()=>{this.uploadErrorCount=0},onError:()=>{this.uploadErrorCount++}}),!0}}return V});