UNPKG

my-uniapp-tools

Version:

一个简洁稳定的 uni-app 开发工具库,提供剪贴板、本地存储、导航、系统信息等常用功能

2 lines (1 loc) 39.1 kB
"use strict";var e=require("@vant/area-data");class t extends Error{code;module;timestamp;constructor(e,t,n){super(t),this.name="UniAppToolsError",this.code=e,this.module=n,this.timestamp=Date.now()}}class n{static instance;errorCallbacks=[];static getInstance(){return n.instance||(n.instance=new n),n.instance}onError(e){return"function"!=typeof e?()=>{}:(this.errorCallbacks.push(e),()=>{const t=this.errorCallbacks.indexOf(e);t>=0&&this.errorCallbacks.splice(t,1)})}handleError(e,n){const r=e instanceof Error?e:new Error(String(e)),o={code:r instanceof t?r.code:"UNKNOWN_ERROR",message:r.message,module:r instanceof t?r.module:n,timestamp:r instanceof t?r.timestamp:Date.now(),stack:r.stack};console.error(`[${o.module}] ${o.code}: ${o.message}`,o),this.errorCallbacks.forEach(e=>{try{e(o)}catch(e){console.error("Error in error callback:",e)}})}createModuleErrorHandler(e){return(n,r,o)=>{const s=new t(n,r,e);return o instanceof Error&&(s.stack=o.stack),this.handleError(s,e),s}}}async function r(e,t,r="ASYNC_ERROR"){try{return await e()}catch(e){return n.getInstance().createModuleErrorHandler(t)(r,`异步操作失败: ${e instanceof Error?e.message:String(e)}`,e),null}}function o(e,t,r="SYNC_ERROR",o=null){try{return e()}catch(e){return n.getInstance().createModuleErrorHandler(t)(r,`同步操作失败: ${e instanceof Error?e.message:String(e)}`,e),o}}const s=n.getInstance();let i=null,a=null,c=null;const u=e=>"weixin"===e||"alipay"===e;let l=!1;const f=()=>{if(i)return i;let e="unknown";try{"undefined"!=typeof wx&&wx.getSystemInfoSync?e="weixin":"undefined"!=typeof my&&my.getSystemInfoSync?e="alipay":"undefined"!=typeof window&&window.document?e="h5":"undefined"!=typeof plus&&(e="app")}catch(t){e="weixin",e="web",e="app",e="alipay",e="h5"}return i=e,e},p=(e=!0)=>e&&c?c:o(()=>{if("undefined"==typeof uni||"function"!=typeof uni.getWindowInfo)return null;const t=uni.getWindowInfo();return e&&(c=t),t},"system","GET_WINDOW_INFO_ERROR",null),m=()=>{if(null!==a)return a;try{const e=p();return a=e?.statusBarHeight||0,a}catch(e){return s.handleError(new t("GET_STATUS_BAR_HEIGHT_ERROR",`获取状态栏高度失败: ${e instanceof Error?e.message:String(e)}`,"system"),"system"),0}},d=()=>{try{const e=f();return u(e)?uni.getMenuButtonBoundingClientRect():null}catch(e){return s.handleError(new t("GET_MENU_BUTTON_ERROR",`获取菜单按钮边界信息失败: ${e instanceof Error?e.message:String(e)}`,"system"),"system"),null}},g=()=>{try{const e=f();if(u(e)){const e=d();return e?.height||44}return 44}catch(e){return s.handleError(new t("GET_NAVIGATION_BAR_HEIGHT_ERROR",`获取导航栏高度失败: ${e instanceof Error?e.message:String(e)}`,"system"),"system"),44}},y=()=>{const e=f(),t=m(),n=g();return{platform:e,statusBarHeight:t,navigationBarHeight:n,totalTopHeight:t+n}},h=n.getInstance();function E(e){if(null===e||"object"!=typeof e)return e;try{return"undefined"!=typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(e){const n=e instanceof Error?e.message:String(e);throw h.handleError(new t("DEEP_CLONE_ERROR",`深拷贝失败: ${n}`,"utils"),"utils"),new Error(`深拷贝失败: ${n}`)}}function w(e,t,n=!1){let r,o=null;const s=function(...s){const i=n&&!o;return o&&clearTimeout(o),o=setTimeout(()=>{o=null,n||(r=e.apply(this,s))},t),i&&(r=e.apply(this,s)),r};return s.cancel=()=>{o&&(clearTimeout(o),o=null)},s}function S(e,t,n={}){let r,o=null,s=0;const{leading:i=!0,trailing:a=!0}=n,c=function(...n){const c=Date.now();s||i||(s=c);const u=t-(c-s);return u<=0||u>t?(o&&(clearTimeout(o),o=null),s=c,r=e.apply(this,n)):!o&&a&&(o=setTimeout(()=>{s=i?Date.now():0,o=null,r=e.apply(this,n)},u)),r};return c.cancel=()=>{o&&(clearTimeout(o),o=null),s=0},c}const A=e.areaList,R=e.useCascaderAreaData,T=(e="",t=!1,n="none",r=2e3)=>{const o="undefined"==typeof uni?null:uni;o&&"function"==typeof o.showToast&&o.showToast({title:"string"==typeof e?e:String(e??""),icon:n,mask:Boolean(t),duration:Number.isFinite(r)&&r>0?r:2e3})},v=n.getInstance();let b={defaultHomePage:"/pages/index/index"};function _(e,t){const n="string"==typeof e?e:String(e??"");if(!t||"object"!=typeof t)return n;const r=Object.entries(t).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`).join("&");return r?n+(n.includes("?")?"&":"?")+r:n}const x=_;function O(e,n,r){const o=r?.errMsg?`${n} - ${r.errMsg}`:n;v.handleError(new t(e,o,"navigation"),"navigation")}function C(){return"function"==typeof getCurrentPages?getCurrentPages():[]}function P(){return"undefined"==typeof uni?null:uni}async function I(e="",t={}){return new Promise(n=>{const r=t&&"object"==typeof t?t:{},o="number"==typeof r.delta&&Number.isFinite(r.delta)&&r.delta>0?Math.floor(r.delta):1,s="number"==typeof r.timeout&&Number.isFinite(r.timeout)&&r.timeout>0?r.timeout:5e3,i=P();if(!i||"function"!=typeof i.navigateBack)return O("NAVIGATION_ENV_ERROR","当前环境不支持 navigateBack"),void n(!1);const a=C();if(a.length<=o)return console.warn(`[navigation] 无法返回${o}页,当前页面栈深度不足(当前: ${a.length})`),void n(!1);let c=!1;const u=setTimeout(()=>{c||(c=!0,console.warn("[navigation] 页面init回调执行超时"),n(!1))},s);i.navigateBack({delta:o,success:()=>{clearTimeout(u),setTimeout(()=>{if(!c)try{const t=C();if(t.length>0){const n=t[t.length-1];n.$vm&&"function"==typeof n.$vm.init&&n.$vm.init(e)}c=!0,n(!0)}catch(e){O("PAGE_CALLBACK_ERROR",`页面回调执行失败: ${e instanceof Error?e.message:String(e)}`),c=!0,n(!0)}},100)},fail:e=>{clearTimeout(u),O("NAVIGATE_BACK_FAILED","导航返回失败",e),c=!0,n(!1)}})})}const N=w(I,300);function M(){try{const e=C();if(0===e.length)return null;const t=e[e.length-1];return{route:t.route||"",options:t.options||{}}}catch(e){return O("GET_CURRENT_PAGE_ERROR",`获取当前页面信息失败: ${e instanceof Error?e.message:String(e)}`),null}}const L=M;function F(){try{return C().map(e=>({route:e.route||"",options:e.options||{}}))}catch(e){return O("GET_PAGE_STACK_ERROR",`获取页面栈信息失败: ${e instanceof Error?e.message:String(e)}`),[]}}const j=F,D={showToast:!0,successMessage:"复制成功",failMessage:"复制失败",timeout:5e3},k=n.getInstance();function U(){return"undefined"==typeof uni?null:uni}class ${static instance;cache=new Map;maxCacheSize=100;static getInstance(){return $.instance||($.instance=new $),$.instance}isExpired(e){return!!e.ttl&&Date.now()-e.timestamp>e.ttl}remember(e,t){if(this.cache.size>=this.maxCacheSize){const e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(e,t)}createItem(e,t={}){return{value:e,timestamp:Date.now(),ttl:t.ttl}}set(e,n,r={}){try{if(!e||"string"!=typeof e)return!1;const t=U();if(!t||"function"!=typeof t.setStorageSync)return!1;const o=this.createItem(n,r),s=JSON.stringify(o);if(s.length>1048576)throw new Error("存储数据过大");return t.setStorageSync(e,s),this.remember(e,o),!0}catch(e){return k.handleError(new t("SET_STORAGE_ERROR",`设置存储失败: ${e instanceof Error?e.message:String(e)}`,"localStorage"),"localStorage"),!1}}async setAsync(e,n,r={}){try{if(!e||"string"!=typeof e)return!1;const t=U();if(!t||"function"!=typeof t.setStorage)return this.set(e,n,r);const o=this.createItem(n,r),s=JSON.stringify(o);return!(s.length>1048576)&&await new Promise(n=>{t.setStorage({key:e,data:s,success:()=>{this.remember(e,o),n(!0)},fail:()=>n(!1)})})}catch(e){return k.handleError(new t("SET_STORAGE_ASYNC_ERROR",`异步设置存储失败: ${e instanceof Error?e.message:String(e)}`,"localStorage"),"localStorage"),!1}}get(e,t){try{if(!e||"string"!=typeof e)return t;if(this.cache.has(e)){const n=this.cache.get(e);return this.isExpired(n)?(this.cache.delete(e),this.remove(e),t):n.value}const n=U();if(!n||"function"!=typeof n.getStorageSync)return t;const r=n.getStorageSync(e);if(!r||"string"!=typeof r)return t;const o=JSON.parse(r);let s;return s=o&&"object"==typeof o&&"value"in o&&"timestamp"in o?o:{value:o,timestamp:Date.now()},this.isExpired(s)?(this.remove(e),t):(this.cache.set(e,s),s.value)}catch(n){return console.warn(`[localStorage] 获取存储失败 [${e}]:`,n),t}}async getAsync(e,t){try{if(!e||"string"!=typeof e)return t;if(this.cache.has(e)){const n=this.cache.get(e);return this.isExpired(n)?(this.cache.delete(e),this.remove(e),t):n.value}const n=U();if(!n||"function"!=typeof n.getStorage)return this.get(e,t);const r=await new Promise(t=>{n.getStorage({key:e,success:e=>t(e.data),fail:()=>t(void 0)})});if(!r||"string"!=typeof r)return t;const o=JSON.parse(r),s=o&&"object"==typeof o&&"value"in o&&"timestamp"in o?o:{value:o,timestamp:Date.now()};return this.isExpired(s)?(this.remove(e),t):(this.remember(e,s),s.value)}catch(n){return console.warn(`[localStorage] 异步获取存储失败 [${e}]:`,n),t}}remove(e){try{if(!e||"string"!=typeof e)return!1;const t=U();return!(!t||"function"!=typeof t.removeStorageSync||(t.removeStorageSync(e),this.cache.delete(e),0))}catch(n){return k.handleError(new t("REMOVE_STORAGE_ERROR",`删除存储失败: ${e}`,"localStorage"),"localStorage"),!1}}clear(){try{const e=U();return!(!e||"function"!=typeof e.clearStorageSync||(e.clearStorageSync(),this.cache.clear(),0))}catch(e){return k.handleError(new t("CLEAR_STORAGE_ERROR","清空存储失败","localStorage"),"localStorage"),!1}}getInfo(){try{const e=U();if(!e||"function"!=typeof e.getStorageInfoSync)return{keys:[],currentSize:0,limitSize:0};const t=e.getStorageInfoSync();return{keys:t.keys||[],currentSize:t.currentSize||0,limitSize:t.limitSize||0}}catch(e){return k.handleError(new t("GET_STORAGE_INFO_ERROR",`获取存储信息失败: ${e instanceof Error?e.message:String(e)}`,"localStorage"),"localStorage"),{keys:[],currentSize:0,limitSize:0}}}cleanExpired(){try{const e=this.getInfo();let t=0;return e.keys.forEach(e=>{void 0===this.get(e)&&t++}),t}catch(e){return k.handleError(new t("CLEAN_EXPIRED_ERROR",`清理过期数据失败: ${e instanceof Error?e.message:String(e)}`,"localStorage"),"localStorage"),0}}}const B=$.getInstance();function H(e,t,n={}){return B.set(e,t,n)}function W(e,t){return B.get(e,t)}const J="上传失败",K="已取消上传",G="选择文件失败",z="用户取消选择",Y="未选择任何文件",V=e=>`部分文件大小超过 ${e}MB 限制`,q=e=>`存在不支持的文件类型,仅支持:${e.join(", ")}`,X="当前环境不支持文件选择",Q=e=>`上传超时(${e}ms)`,Z=e=>`上传请求失败: ${e}`,ee=e=>`上传失败,状态码:${e}`,te={FIELD_NAME:"file",FILE_TYPE:"image",COUNT:1,SHOW_TOAST:!0};function ne(e){if(!e||"string"!=typeof e)return;const t=e.split(/[?#]/)[0].match(/\.([^./\\]+)$/);return t?t[1].toLowerCase():void 0}function re(e){if("string"!=typeof e)return"";const t=e.trim().toLowerCase().replace(/^\./,"");return"jpeg"===t||"jpe"===t?"jpg":t}function oe(e){if(!Array.isArray(e))return;const t=Array.from(new Set(e.map(e=>re(e)).filter(Boolean)));return t.length>0?t:void 0}function se(e){return`${Date.now()}_${e}_${Math.random().toString(16).slice(2)}`}function ie(e){return"string"==typeof e&&e.startsWith("blob:")}function ae(e){if(ie(e)&&"undefined"!=typeof URL&&"function"==typeof URL.revokeObjectURL)try{URL.revokeObjectURL(e)}catch{}}function ce(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}function ue(e){if(null==e)return"";const t=typeof e;if("string"===t||"number"===t||"boolean"===t)return String(e);if("object"===t)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function le(e){if(!e||"object"!=typeof e||Array.isArray(e))return;const t={},n=e;return Object.keys(n).forEach(e=>{t[e]=ue(n[e])}),t}function fe(e){if(!e||"object"!=typeof e||Array.isArray(e))return;const t={};return Object.keys(e).forEach(n=>{const r=e[n];null!=r&&(t[n]=String(r))}),Object.keys(t).length>0?t:void 0}function pe(e){const t=(e||"").trim();if(!t)return"选择文件失败";const n=t.toLowerCase();return n.includes("fail cancel")||n.includes("cancel")?"用户取消选择":/[\u4e00-\u9fff]/.test(t)?t:"选择文件失败"}function me(e,t){return null==t||"number"!=typeof t||!Number.isFinite(t)||t<0?{valid:!0}:("number"==typeof e&&Number.isFinite(e)&&e>0?e:0)>1024*t*1024?{valid:!1,message:`文件大小不能超过 ${t}MB`}:{valid:!0}}function de(e,t){return!Number.isFinite(t)||t<=0?0:"number"!=typeof e||!Number.isFinite(e)||e<=0?t:Math.min(Math.floor(e),t)}function ge(e){return{toast:"function"==typeof e.toast?e.toast:T,shouldShowToast:void 0===e.showToast?te.SHOW_TOAST:Boolean(e.showToast)}}function ye(e){return Boolean(e?.aborted)}function he(e){return[{file:null,success:!1,message:e}]}function Ee(){return he(K)}function we(e,t){t.autoRevokeObjectURL&&e.forEach(e=>{ae(e.path)})}async function Se(e,t,n){const r=function(e){const t=e&&"object"==typeof e?e:{},n="image"===t.type||"file"===t.type||"any"===t.type?t.type:te.FILE_TYPE,r="number"==typeof t.count&&Number.isFinite(t.count)&&t.count>0?Math.floor(t.count):te.COUNT,o="number"==typeof t.timeoutMs&&Number.isFinite(t.timeoutMs)&&t.timeoutMs>0?t.timeoutMs:void 0,s=Array.isArray(t.files)?t.files.filter(e=>Boolean(e)&&"object"==typeof e&&"string"==typeof e.path):void 0;return{...t,url:"string"==typeof t.url?t.url:"",files:s,type:n,count:r,extensions:oe(t.extensions),fieldName:"string"==typeof t.fieldName&&t.fieldName.trim()?t.fieldName:te.FIELD_NAME,formData:le(t.formData),headers:fe(t.headers),timeoutMs:o,autoRevokeObjectURL:Boolean(t.autoRevokeObjectURL),signal:(i=t.signal,Boolean(i&&"object"==typeof i&&"function"==typeof i.addEventListener)?t.signal:void 0),beforeUpload:"function"==typeof t.beforeUpload?t.beforeUpload:void 0,onProgress:"function"==typeof t.onProgress?t.onProgress:void 0,toast:"function"==typeof t.toast?t.toast:void 0,progressToastFormatter:"function"==typeof t.progressToastFormatter?t.progressToastFormatter:void 0,successMessage:"string"==typeof t.successMessage?t.successMessage:void 0,failMessage:"string"==typeof t.failMessage?t.failMessage:void 0};var i}(e),{url:o,files:s,type:i=te.FILE_TYPE,count:a=te.COUNT,maxSizeMB:c,extensions:u,signal:l,successMessage:f}=r,p=o,{toast:m,shouldShowToast:d}=ge(r);if(!p.trim()){const e="上传地址不能为空";return d&&m(e,!1,"none"),he(e)}if(ye(l))return d&&m(K,!1,"none"),Ee();const g=Array.isArray(s);let y=Array.isArray(s)?s:[];if(0===y.length&&!g)try{const e=await t({type:i,count:a,extensions:u});if(!e.success)return d&&e.message&&m(e.message,!1,"none"),[{file:null,success:!1,message:e.message}];y=e.files}catch(e){const t=e instanceof Error?e.message:G;return d&&m(t,!1,"none"),he(t)}if(0===y.length)return he(Y);const h=function(e,t){if(!e||0===e.length)return{success:!1,message:Y};const{maxSizeMB:n,extensions:r}=t||{};if(0===n)return{success:!1,message:"当前不允许选择文件"};const o=null!=n&&"number"==typeof n&&Number.isFinite(n)&&n>0,s=oe(r)||[],i=s.length>0;if(!o&&!i)return{success:!0};const a=i?new Set(s):null;for(const t of e){if(o&&!me(t.size,n).valid)return{success:!1,message:V(n)};if(i&&a){const e=t.ext?re(t.ext):void 0;if(!e||!a.has(e))return{success:!1,message:q(s)}}}return{success:!0}}(y,{maxSizeMB:c,extensions:u});if(!h.success){const e=h.message||G;return d&&m(e,!1,"none"),we(y,r),he(e)}if(ye(l))return d&&m(K,!1,"none"),we(y,r),Ee();const E=await async function(e,t,n,r){const{concurrency:o,signal:s,beforeUpload:i,onProgress:a,showProgressToast:c,progressToastFormatter:u}=t,{toast:l,shouldShowToast:f}=ge(t),p=new Array(e.length);let m=0;const d=e.length,g=de(o,d),y=Boolean(c&&d>0),h="undefined"!=typeof uni?uni:null,E=Boolean(y&&h&&"function"==typeof h.showLoading&&"function"==typeof h.hideLoading),w=E,A=S((t,n)=>{if(!E)return;const r=function(e){const{files:t,index:n,pct:r,finishedCount:o,totalCount:s,progressToastFormatter:i}=e;if("function"==typeof i)try{return i(t[n],r,n+1,s)}catch{}return 1===s?`上传中 ${r}%`:`上传中 (${o}/${s})`}({files:e,index:t,pct:n,finishedCount:m,totalCount:d,progressToastFormatter:u});h.showLoading({title:r,mask:!0})},200);const R=async o=>{const c=e[o];let u=null;try{if(ye(s))return u={file:c,success:!1,message:K},we([c],t),void(E&&A(o,0));const e=await async function(e){if(!i)return null;try{return await i(e)?null:{file:e,success:!1,message:K}}catch(t){const n=(e=>`上传前检查失败: ${e}`)(t instanceof Error?t.message:String(t??"unknown"));return f&&l(n,!1,"error"),{file:e,success:!1,message:n}}}(c);if(e)return u=e,void we([c],t);const p=function(e){return w?{...t,onProgress:(t,n)=>{A(e,n),a&&a(t,n)}}:t}(o);u=await r(c,p,n)}catch(e){u={file:c,success:!1,message:e instanceof Error?e.message:String(e??"Unknown error")}}finally{u||(u={file:c,success:!1,message:"Unknown error"}),p[o]=u,m++,u.success&&A(o,100)}};for(let e=0;e<d;e+=g){const t=Math.min(e+g,d),n=[];for(let r=e;r<t;r+=1)n.push(R(r));await Promise.all(n)}return E&&(A.cancel?.(),h.hideLoading()),p}(y,r,p,n);return E.filter(e=>e.success).length===E.length&&1===E.length&&d&&m(f||"上传成功",!1,"none"),E}function Ae(e){const{type:t="image",count:n=1,extensions:r}=e;return new Promise(e=>{if("undefined"==typeof document||"undefined"==typeof window)return void e({success:!1,files:[],message:X});const o=document.createElement("input");o.type="file",o.multiple=n>1,o.style.display="none";const s=oe(r);"image"===t?o.accept="image/*":s&&(o.accept=s.map(e=>`.${e}`).join(","));let i=!1,a=null;const c=t=>{i||(i=!0,(()=>{a&&(clearTimeout(a),a=null),window.removeEventListener("focus",l);try{o.remove()}catch{}})(),e(t))},u=e=>{if(!e||0===e.length)return void c({success:!1,files:[],message:z});const t=Array.from(e).slice(0,n).map((e,t)=>({id:se(t),name:e.name,size:e.size,path:URL.createObjectURL(e),mimeType:e.type,ext:ne(e.name),source:"file",platform:"h5",raw:e}));c({success:!0,files:t})};o.addEventListener("change",()=>u(o.files)),o.addEventListener("cancel",()=>c({success:!1,files:[],message:z}));const l=()=>{i||(a=window.setTimeout(()=>{i||(o.files&&0!==o.files.length?u(o.files):c({success:!1,files:[],message:z}))},300))};window.addEventListener("focus",l),document.body.appendChild(o),o.click()})}function Re(e,t,n){const{fieldName:r="file",formData:o,headers:s,timeoutMs:i,autoRevokeObjectURL:a}=t,{signal:c,onProgress:u}=t,l="string"==typeof r&&r.trim()?r:"file",f="number"==typeof i&&Number.isFinite(i)&&i>0?i:void 0,p=fe(s),m=le(o),d="function"==typeof u?u:void 0;return new Promise(t=>{const r=e.raw;if(!("undefined"!=typeof File&&r&&r instanceof File))return void t({file:e,success:!1,message:"H5 环境缺少原生文件对象"});const o=new XMLHttpRequest;let s=!1,i=null;const u=n=>{s||(s=!0,c&&i&&"function"==typeof c.removeEventListener&&(c.removeEventListener("abort",i),i=null),a&&ie(e.path)&&ae(e.path),t(n))};if(c&&"function"==typeof c.addEventListener){if(c.aborted)return void u({file:e,success:!1,message:K});i=()=>{o.abort(),u({file:e,success:!1,message:K})},c.addEventListener("abort",i,{once:!0})}o.open("POST",n),f&&f>0&&(o.timeout=f),p&&Object.keys(p).forEach(e=>{o.setRequestHeader(e,p[e])});const g=new FormData;g.append(l,r,e.name),m&&Object.keys(m).forEach(e=>{g.append(e,ue(m[e]))}),o.upload.onprogress=t=>{if(t.lengthComputable&&d){const n=Math.round(t.loaded/t.total*100);d(e,n)}},o.onload=()=>{const t=o.status,n=t>=200&&t<300;let r=ce(o.responseText);u({file:e,success:n,statusCode:t,data:r,message:n?void 0:ee(t)})},o.onerror=()=>u({file:e,success:!1,message:J}),o.ontimeout=()=>u({file:e,success:!1,message:Q(f||0)}),o.onabort=()=>u({file:e,success:!1,message:K});try{o.send(g)}catch(t){const n=t instanceof Error?t.message:"Unknown error";u({file:e,success:!1,message:Z(n)})}})}function Te(e){const{type:t="image",count:n=1,extensions:r}=e,o=oe(r);return new Promise(e=>{const r="undefined"==typeof uni?null:uni;if(!r)return void e({success:!1,files:[],message:X});const s=function(){if("undefined"!=typeof wx&&wx?.getSystemInfoSync)return"weixin";if("undefined"!=typeof my&&my?.getSystemInfoSync)return"alipay";if("undefined"!=typeof window&&"undefined"!=typeof document)return"h5";if("undefined"!=typeof plus)return"app";let e="unknown";return e="h5",e="weixin",e="alipay",e="app","app"}(),i=t=>{e({success:!1,files:[],message:pe(t?.errMsg)})},a=[{name:"chooseMedia(image)",when:()=>"image"===t&&"weixin"===s&&"function"==typeof r.chooseMedia,run:()=>{r.chooseMedia({count:n,mediaType:["image"],success:t=>{const n=(Array.isArray(t?.tempFiles)?t.tempFiles:[]).map((e,t)=>{const n=e.size||e.fileSize||e.originalFileSize||0;return ve(e.tempFilePath,t,n,"album",s,e)});e({success:!0,files:n})},fail:i})}},{name:"chooseImage",when:()=>"image"===t&&"function"==typeof r.chooseImage,run:()=>{r.chooseImage({count:n,success:t=>{const n=(Array.isArray(t?.tempFiles)?t.tempFiles:t?.tempFiles?[t.tempFiles]:[]).map((e,t)=>ve(e.path,t,e.size,"album",s,e));e({success:!0,files:n})},fail:i})}},{name:"chooseFile",when:()=>"image"!==t&&"function"==typeof r.chooseFile,run:()=>{r.chooseFile({count:n,type:"all",extension:o?.map(e=>`.${e}`),success:t=>{const n=(Array.isArray(t?.tempFiles)?t.tempFiles:Array.isArray(t?.tempFilePaths)?t.tempFilePaths:[]).map((e,t)=>"string"==typeof e?ve(e,t,0,"file",s,e):ve(e?.path||e?.tempFilePath||e?.filePath||"",t,e?.size||e?.fileSize||0,"file",s,e,e?.name));e({success:!0,files:n})},fail:i})}},{name:"chooseMessageFile(all)",when:()=>"function"==typeof r.chooseMessageFile,run:()=>{r.chooseMessageFile({count:n,type:"all",success:t=>{const n=(Array.isArray(t?.tempFiles)?t.tempFiles:[]).map((e,t)=>ve(e.path,t,e.size,"file",s,e,e.name));e({success:!0,files:n})},fail:i})}}];for(const e of a)if(e.when())return void e.run();e({success:!1,files:[],message:"当前平台不支持文件选择"})})}function ve(e,t,n,r,o,s,i){const a="string"==typeof e?e:"",c="string"==typeof i&&i.trim()?i:a.split(/[\\/]/).pop()||`file_${t}`,u="number"==typeof n&&Number.isFinite(n)&&n>0?n:0;return{id:se(t),name:c,size:u,path:a,ext:ne(c||a),source:r,platform:o,raw:s}}function be(e,t,n){const{fieldName:r="file",formData:o,headers:s,timeoutMs:i}=t,{signal:a,onProgress:c}=t,u="string"==typeof r&&r.trim()?r:"file",l="number"==typeof i&&Number.isFinite(i)&&i>0?i:void 0,f=fe(s),p=le(o),m="function"==typeof c?c:void 0;return new Promise(t=>{const r="undefined"==typeof uni?null:uni;if(!r?.uploadFile)return void t({file:e,success:!1,message:"当前环境不支持文件上传"});let o=!1,s=null,i=null,c=null;const d=e=>{o||(o=!0,s&&clearTimeout(s),a&&c&&"function"==typeof a.removeEventListener&&(a.removeEventListener("abort",c),c=null),t(e))};l&&l>0&&(s=setTimeout(()=>{i?.abort?.(),d({file:e,success:!1,message:Q(l)})},l)),i=r.uploadFile({url:n,filePath:e.path,name:u,header:f,formData:p,success:t=>{const n=function(e){if(e&&"number"==typeof e.statusCode)return e.statusCode;if(e&&"number"==typeof e.status)return e.status;const t="string"==typeof e?.errMsg?e.errMsg:"";return/:ok\b/i.test(t)?200:0}(t),r=n>=200&&n<300,o=ce(t.data);d({file:e,success:r,statusCode:n,data:o,message:r?void 0:ee(n)})},fail:t=>{o||d({file:e,success:!1,message:t?.errMsg||J})}}),m&&i?.onProgressUpdate&&i.onProgressUpdate(t=>{o||"number"!=typeof t.progress||m(e,t.progress)}),a&&"function"==typeof a.addEventListener&&(a.aborted?(i?.abort?.(),d({file:e,success:!1,message:K})):(c=()=>{i?.abort?.(),d({file:e,success:!1,message:K})},a.addEventListener("abort",c,{once:!0})))})}async function _e(e){const{pickFiles:t,uploadFile:n}="undefined"==typeof window||"undefined"==typeof document||function(){const e="undefined"==typeof uni?null:uni;return Boolean(e&&"function"==typeof e.uploadFile)}()?{pickFiles:Te,uploadFile:be}:{pickFiles:Ae,uploadFile:Re};return Se(e,t,n)}const xe=n.getInstance(),Oe="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js";let Ce=!1,Pe=null;const Ie=n.getInstance(),Ne="WECHAT_PAY_INVALID_CONFIG",Me=n.getInstance(),Le=()=>!("undefined"==typeof navigator||!navigator.userAgent)&&navigator.userAgent.toLowerCase().includes("micromessenger"),Fe=()=>"undefined"!=typeof window&&"undefined"!=typeof document,je=()=>Fe()&&Le()&&window.wx||null,De=(e,t=!1)=>{const n={};return e.forEach(e=>{"string"==typeof e&&""!==e.trim()&&(n[e]=t)}),n};let ke=!1,Ue=null,$e=!1,Be=null;const He=["https://res.wx.qq.com/open/js/jweixin-1.6.0.js","https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"],We=()=>{ke=!1,$e=!1,Ue=null,Be=null},Je=(e={})=>{const t=e&&"object"==typeof e?e:{},n="number"==typeof t.timeoutMs&&Number.isFinite(t.timeoutMs)&&t.timeoutMs>0?t.timeoutMs:1e4;if(ke||Fe()&&window.wx)return ke=!0,Promise.resolve(!0);if(!Fe())return Promise.resolve(!1);if(Ue)return Ue;const r=Array.isArray(t.cdnUrls)&&t.cdnUrls.length>0?t.cdnUrls.filter(e=>"string"==typeof e&&""!==e.trim()):[],o=r.length>0?r:He;return Ue=new Promise(e=>{let t=!1,r=null,s=null,i=0;const a=n=>{t||(t=!0,r&&(clearTimeout(r),r=null),s&&s.parentNode&&s.parentNode.removeChild(s),n&&(ke=!0),Ue=null,e(n))},c=()=>{if(i>=o.length)return void a(!1);if(!document.head)return void a(!1);const e=o[i];i+=1;const t=document.createElement("script");s=t,t.src=e,t.async=!0,t.onload=()=>a(!0),t.onerror=()=>{t.parentNode&&t.parentNode.removeChild(t),s=null,c()},document.head.appendChild(t)};r=setTimeout(()=>{a(!1)},n),c()}),Ue},Ke=async(e,n={})=>{const r=n&&"object"==typeof n?n:{},o="number"==typeof r.timeoutMs&&Number.isFinite(r.timeoutMs)&&r.timeoutMs>0?r.timeoutMs:1e4;return!(!e||"object"!=typeof e||"string"!=typeof e.appId||"string"!=typeof e.nonceStr||"string"!=typeof e.signature||"number"!=typeof e.timestamp||!Array.isArray(e.jsApiList))&&(Le()?Be||(Be=(async()=>{if(!await Je({timeoutMs:o}))return Me.handleError(new t("WECHAT_JSSDK_LOAD_FAILED","微信 JS-SDK 加载失败","weixin"),"weixin"),!1;const n=je();if(!n||"function"!=typeof n.config||"function"!=typeof n.ready||"function"!=typeof n.error)return!1;const r=n.config,s=n.ready,i=n.error,a=await new Promise(n=>{let a=!1,c=null;const u=e=>{a||(a=!0,c&&(clearTimeout(c),c=null),n(e))};c=setTimeout(()=>u(!1),o);try{r({debug:e.debug||!1,appId:e.appId,timestamp:e.timestamp,nonceStr:e.nonceStr,signature:e.signature,jsApiList:e.jsApiList}),s(()=>u(!0)),i(e=>{Me.handleError(new t("WECHAT_JSSDK_CONFIG_ERROR",`微信 JS-SDK 配置错误: ${(e=>{try{return JSON.stringify(e)}catch{return String(e)}})(e)}`,"weixin"),"weixin"),u(!1)})}catch(e){Me.handleError(new t("WECHAT_JSSDK_CONFIG_EXCEPTION",`微信 JS-SDK 配置异常: ${e instanceof Error?e.message:String(e)}`,"weixin"),"weixin"),u(!1)}});return $e=a,a})().finally(()=>{Be=null}),Be):(console.warn("当前不在微信环境中"),!1))},Ge=e=>{if(!e||"object"!=typeof e)return;const t=je();t&&(t.updateTimelineShareData?t.updateTimelineShareData(e):t.onMenuShareTimeline&&t.onMenuShareTimeline(e))},ze=e=>{if(!e||"object"!=typeof e)return;const t=je();t&&(t.updateAppMessageShareData?t.updateAppMessageShareData(e):t.onMenuShareAppMessage&&t.onMenuShareAppMessage(e))};class Ye{static instance;isConfigured=!1;config=null;initPromise=null;constructor(){}static getInstance(){return Ye.instance||(Ye.instance=new Ye),Ye.instance}async init(e){return this.initPromise||(this.initPromise=Ke(e).then(t=>(this.isConfigured=t,this.config=t?e:null,t)).finally(()=>{this.initPromise=null})),this.initPromise}isReady(){return(this.isConfigured||$e)&&Le()}getConfig(){return this.config}reset(){this.isConfigured=!1,this.config=null,this.initPromise=null,We()}setShareData(e){this.isReady()?(Ge(e),ze(e)):console.warn("微信 SDK 未就绪")}}exports.ErrorHandler=n,exports.UniAppToolsError=t,exports.VERSION="5.0.3",exports.WechatSDK=Ye,exports.areaList=A,exports.batchGetStorage=function(e){const t={};return Array.isArray(e)?(e.forEach(e=>{t[e]=W(e)}),t):t},exports.batchSetStorage=function(e,t={}){if(!e||"object"!=typeof e||Array.isArray(e))return 0;let n=0;return Object.entries(e).forEach(([e,r])=>{H(e,r,t)&&n++}),n},exports.buildUrl=x,exports.checkWechatJSAPI=(e,n={})=>{const r=n&&"object"==typeof n?n:{},o="number"==typeof r.timeoutMs&&Number.isFinite(r.timeoutMs)&&r.timeoutMs>0?r.timeoutMs:8e3,s=Array.isArray(e)?e:[];return new Promise(e=>{const n=je();if(!n||"function"!=typeof n.checkJsApi)return void e(De(s,!1));let r=!1;const i=t=>{r||(r=!0,e(t))},a=setTimeout(()=>i(De(s,!1)),o);try{n.checkJsApi({jsApiList:s,success:e=>{clearTimeout(a),i({...De(s,!1),...e?.checkResult||{}})}})}catch(e){clearTimeout(a),Me.handleError(new t("CHECK_WECHAT_JSAPI_ERROR",`检查微信 JS-SDK API 异常: ${e instanceof Error?e.message:String(e)}`,"weixin"),"weixin"),i(De(s,!1))}})},exports.cleanExpiredStorage=function(){return B.cleanExpired()},exports.clearStorageSync=function(e){return void 0!==e?B.remove(e):B.clear()},exports.clearSystemCache=()=>{c=null},exports.configWechatJSSDK=Ke,exports.configureNavigation=function(e){e&&"object"==typeof e&&(b={...b,...e})},exports.copyText=async function(e,t={}){const n={...D,...t},o="number"==typeof n.timeout&&Number.isFinite(n.timeout)&&n.timeout>0?n.timeout:0,s="string"==typeof e?e:String(e??"");return s?s.length>1e4?(n.showToast&&T("复制内容过长",!1,"error"),!1):await r(()=>new Promise(e=>{const t="undefined"==typeof uni?null:uni;if(!t||"function"!=typeof t.setClipboardData)return n.showToast&&T(n.failMessage,!1,"error"),void e(!1);let r=!1,i=null;const a=t=>{r||(r=!0,i&&(clearTimeout(i),i=null),e(t))};o>0&&(i=setTimeout(()=>{n.showToast&&T(n.failMessage,!1,"error"),a(!1)},o)),t.setClipboardData({data:s,showToast:!1,success:()=>{n.showToast&&T(n.successMessage),a(!0)},fail:()=>{n.showToast&&T(n.failMessage),a(!1)}})}),"clipboard","COPY_TEXT_ERROR")??!1:(n.showToast&&T("复制内容不能为空",!1,"error"),!1)},exports.debounce=w,exports.deepClone=E,exports.deepMerge=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))return E(t||{});if(!t||"object"!=typeof t||Array.isArray(t))return E(e);const n=E(e);return function e(t,n){for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const o=n[r],s=t[r];o&&"object"==typeof o&&!Array.isArray(o)&&s&&"object"==typeof s&&!Array.isArray(s)?e(s,o):t[r]=E(o)}}(n,t),n},exports.extractUrlParts=function(e){try{if("string"!=typeof e||!e.trim())throw new Error("URL不能为空");const t=new URL(e,"http://localhost"),n=t.pathname,r={};return t.searchParams.forEach((e,t)=>{r[t]=e}),{path:n,params:r}}catch(n){return h.handleError(new t("EXTRACT_URL_PARTS_ERROR",`无效的URL: ${e}`,"utils"),"utils"),{path:"",params:{}}}},exports.getCurrentEnv=()=>{try{if("undefined"==typeof uni||"function"!=typeof uni.getAccountInfoSync)throw new Error("当前环境不支持 getAccountInfoSync");const e=uni.getAccountInfoSync();return{appId:e.miniProgram?.appId||"",version:e.miniProgram?.version||"",envVersion:e.miniProgram?.envVersion||"",accountInfo:e}}catch(e){return s.handleError(new t("GET_ACCOUNT_INFO_ERROR",`获取小程序账户信息失败: ${e instanceof Error?e.message:String(e)}`,"system"),"system"),{appId:"",version:"",envVersion:"",accountInfo:{}}}},exports.getCurrentPageInfo=L,exports.getExtension=ne,exports.getH5UrlParams=e=>{try{if("undefined"==typeof window||!window.location)throw new Error("不在 H5 浏览器环境中");const t=new URLSearchParams(window.location.search),n={};return t.forEach((e,t)=>{try{n[t]=decodeURIComponent(e)}catch(r){n[t]=e}}),e?Object.prototype.hasOwnProperty.call(n,e)?n[e]:null:n}catch(n){return h.handleError(new t("GET_H5_URL_PARAMS_ERROR",`获取H5 URL参数失败: ${n instanceof Error?n.message:String(n)}`,"utils"),"utils"),e?null:{}}},exports.getMenuButtonBoundingClientRect=d,exports.getNavHeight=()=>y().totalTopHeight,exports.getNavigationBarHeight=g,exports.getPageStack=j,exports.getPlatform=f,exports.getStatusBarHeight=m,exports.getStorage=async function(e,t){return await B.getAsync(e,t)},exports.getStorageInfo=function(){return B.getInfo()},exports.getStorageSync=W,exports.getTopBarMetrics=y,exports.getTopNavBarHeight=()=>{const e=y();return{statusBarHeight:e.statusBarHeight,navHeight:e.totalTopHeight}},exports.injectAlipayJsSdk=(e=Oe,n={})=>{const r="string"==typeof e&&""!==e.trim()?e:Oe,o=n&&"object"==typeof n?n:{},s="number"==typeof o.timeoutMs&&Number.isFinite(o.timeoutMs)&&o.timeoutMs>0?o.timeoutMs:1e4;return"undefined"!=typeof window&&window.document?Ce||window.ap?(Ce=!0,Promise.resolve(!0)):Pe||(Pe=new Promise(e=>{const n={settled:!1,timeoutId:null,script:null,createdByThisCall:!1},o=r=>{n.settled||(n.settled=!0,n.timeoutId&&(clearTimeout(n.timeoutId),n.timeoutId=null),r.success?Ce=!0:xe.handleError(new t(r.code,r.message,"payment"),"payment"),Pe=null,e(r.success))};try{let e;try{e=new URL(r,window.location.href).href}catch{return void o({success:!1,code:"ALIPAY_SDK_INVALID_URL",message:`无效的 JSSDK 地址: ${r}`})}const t=Array.from(document.getElementsByTagName("script")).find(t=>t.src===e),i=t??document.createElement("script");n.script=i,n.createdByThisCall=!t;const a=()=>{setTimeout(()=>{window.ap?o({success:!0}):o({success:!1,code:"ALIPAY_SDK_INIT_ERROR",message:"支付宝 JSSDK 加载成功但未能初始化 window.ap"})},50)},c=e=>{n.createdByThisCall&&i.parentNode&&i.parentNode.removeChild(i),o({success:!1,code:"ALIPAY_SDK_LOAD_ERROR",message:`支付宝 JSSDK 加载失败: ${String(e?.type||"error")}`})};i.addEventListener("load",a,{once:!0}),i.addEventListener("error",c,{once:!0}),n.timeoutId=setTimeout(()=>{n.createdByThisCall&&i.parentNode&&i.parentNode.removeChild(i),o({success:!1,code:"ALIPAY_SDK_LOAD_TIMEOUT",message:"支付宝 JSSDK 加载超时"})},s),n.createdByThisCall&&(i.type="text/javascript",i.src=e,i.async=!0,i.setAttribute("data-uniapp-tools","alipay-jssdk"),(document.head||document.body||document.documentElement).appendChild(i)),window.ap&&o({success:!0})}catch(e){o({success:!1,code:"ALIPAY_SDK_UNEXPECTED_ERROR",message:`支付宝 JSSDK 注入过程发生意外异常: ${e instanceof Error?e.message:String(e)}`})}}),Pe):(xe.handleError(new t("ALIPAY_SDK_ENV_ERROR","不在浏览器环境中,无法注入支付宝 JSSDK","payment"),"payment"),Promise.resolve(!1))},exports.isWechat=Le,exports.loadWechatJSSDK=Je,exports.mergeObjects=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))return e;if(!t||0===Object.keys(t).length)return e;const n={...e};for(const r of Object.keys(e))t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},exports.normalizeConcurrency=de,exports.onCheckForUpdate=()=>{if(!l)try{if("undefined"==typeof uni||"function"!=typeof uni.getUpdateManager)return;const e=uni.getUpdateManager();l=!0,e.onCheckForUpdate(function(e){e.hasUpdate}),e.onUpdateReady(function(t){uni.showModal({title:"更新提示",content:"新版本已经准备好,是否重启应用?",showCancel:!0,cancelText:"稍后",confirmText:"立即重启",success(t){t.confirm&&e.applyUpdate()}})}),e.onUpdateFailed(function(e){s.handleError(new t("UPDATE_DOWNLOAD_FAILED","新版本下载失败","system"),"system"),uni.showModal({title:"更新失败",content:"新版本下载失败,请检查网络连接或稍后重试",showCancel:!1,confirmText:"知道了"})})}catch(e){s.handleError(new t("CHECK_UPDATE_ERROR",`版本更新检查失败: ${e instanceof Error?e.message:String(e)}`,"system"),"system")}},exports.resetAlipayJsSdk=()=>{Ce=!1,Pe=null},exports.resetWechatJSSDK=We,exports.safeAsync=r,exports.safeSync=o,exports.selectAndUpload=_e,exports.selectAndUploadImage=async function(e){return _e({...e||{},type:"image"})},exports.setPageIcon=(e,t="image/x-icon")=>o(()=>{if("string"!=typeof e||""===e.trim())return!1;const n=f();if("h5"===n||"web"===n){if("undefined"!=typeof document){document.querySelectorAll('link[rel*="icon"]').forEach(e=>e.remove());const n=document.createElement("link");return n.rel="icon",n.type=t,n.href=e,document.head.appendChild(n),!0}}else console.warn("setPageIcon 仅在H5/Web平台有效");return!1},"system","SET_PAGE_ICON_ERROR",!1),exports.setPageTitle=e=>"string"!=typeof e?(console.warn("setPageTitle: title必须是字符串"),Promise.resolve(!1)):""===e.trim()?(console.warn("setPageTitle: title不能为空"),Promise.resolve(!1)):new Promise(n=>{try{if("undefined"==typeof uni||"function"!=typeof uni.setNavigationBarTitle)return void n(!1);uni.setNavigationBarTitle({title:e,success:()=>{n(!0)},fail:e=>{console.warn("设置页面标题失败:",e),n(!1)}})}catch(e){s.handleError(new t("SET_PAGE_TITLE_ERROR",`setPageTitle执行异常: ${e instanceof Error?e.message:String(e)}`,"system"),"system"),n(!1)}}),exports.setStorage=async function(e,t,n={}){return await B.setAsync(e,t,n)},exports.setStorageSync=H,exports.shareToFriend=ze,exports.shareToTimeline=Ge,exports.throttle=S,exports.useBack=I,exports.useBackDebounced=N,exports.useBackOrHome=async function(e="",t={}){const n=t&&"object"==typeof t?t:{},r=C(),o="number"==typeof n.delta&&Number.isFinite(n.delta)&&n.delta>0?Math.floor(n.delta):1;if(r.length>o)return await I(e,t);const s=n.homePage||b.defaultHomePage,i=s.startsWith("/")?s:`/${s}`;return console.info(`[navigation] 页面栈深度不足,重定向到首页: ${i}`),new Promise(e=>{const t=P();if(!t||"function"!=typeof t.reLaunch)return O("NAVIGATION_ENV_ERROR","当前环境不支持 reLaunch"),void e(!1);const r=_(i,n.homeParams);t.reLaunch({url:r,success:()=>e(!0),fail:t=>{O("RELAUNCH_FAILED",`重新启动失败: ${r}`,t),e(!1)}})})},exports.useBuildUrl=_,exports.useCascaderAreaData=R,exports.useCurrentPageInfo=M,exports.usePageStack=F,exports.useRegions=function(){return e.useCascaderAreaData()},exports.useToast=T,exports.useWindowInfo=p,exports.validateSizeWithLimit=me,exports.wechatH5Pay=(e,n={})=>{const r=n&&"object"==typeof n?n:{},o=!1!==r.reportError,s="number"==typeof r.timeoutMs&&Number.isFinite(r.timeoutMs)&&r.timeoutMs>0?r.timeoutMs:1e4;return new Promise(n=>{let r=!1,i=null;const a=e=>{r||(r=!0,i&&(clearTimeout(i),i=null),n(e))},c=(e,n,r=null)=>{const s=new t(e,n,"payment");return o&&Ie.handleError(s,"payment"),{success:!1,status:"error",code:e,message:n,raw:r}};if(!(e&&"object"==typeof e&&e?.appId&&e?.timeStamp&&e?.nonceStr&&e?.package&&e?.signType&&e?.paySign))return void a(c(Ne,"微信支付配置参数不完整"));if("string"!=typeof e.package||!e.package.startsWith("prepay_id="))return void a(c(Ne,"微信支付 package 格式非法,应以 'prepay_id=' 开头"));if("undefined"==typeof window||!window.navigator)return void a(c("WECHAT_PAY_ENV_ERROR","不在浏览器环境中,无法调用微信支付"));const u=()=>{try{window.WeixinJSBridge.invoke("getBrandWCPayRequest",e,e=>{"get_brand_wcpay_request:ok"===e.err_msg?a({success:!0,status:"success",code:"WECHAT_PAY_SUCCESS",message:"支付成功",raw:e}):"get_brand_wcpay_request:cancel"===e.err_msg?a({success:!1,status:"cancel",code:"WECHAT_PAY_CANCEL",message:"用户取消支付",raw:e}):a({success:!1,status:"error",code:"WECHAT_PAY_FAIL",message:e.err_desc||"支付失败",raw:e})})}catch(e){a(c("WECHAT_PAY_INVOKE_ERROR",`调用微信支付接口失败: ${e instanceof Error?e.message:String(e)}`))}};if(void 0===window.WeixinJSBridge){const e=()=>{u(),window.document.removeEventListener("WeixinJSBridgeReady",e,!1)};i=setTimeout(()=>{window.document.removeEventListener("WeixinJSBridgeReady",e,!1),a(c("WECHAT_PAY_READY_TIMEOUT","等待微信支付环境就绪超时"))},s),window.document.addEventListener("WeixinJSBridgeReady",e,!1)}else u()})};