2 lines
9.2 KiB
JavaScript
2 lines
9.2 KiB
JavaScript
![]() |
const e="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),t="undefined"!=typeof uni&&"undefined"==typeof window,n=e||t,o="undefined"!=typeof uni,r=("undefined"!=typeof uni||"undefined"!=typeof window)&&!n,i=e?wx:o?uni:"undefined"!=typeof window?window:{},s=r&&window&&window.navigator&&window.navigator.userAgent||"",c=/Android/i.test(s),l=/(?:Windows Phone)/.test(s),a=/(?:SymbianOS)/.test(s),u=/OpenHarmony/i.test(s),d=r&&("ontouchstart"in window||navigator.maxTouchPoints>0)&&function(){if(r){if(/Tablet|Pad/i.test(s))return!0;if(180===window.orientation||0===window.orientation)return window.innerWidth>=768&&window.innerHeight>=1024;if(90===window.orientation||-90===window.orientation)return window.innerWidth>=1024&&window.innerHeight>=768}return!1}(),f=/iPhone/i.test(s)||/iPod/i.test(s),w=e,h=c||l||a||f||d||u,m=r&&!h,p=t&&!e;function g(){let e="";return m?e="pc":h?e="h5":w?e="wechat":p&&(e="app"),e}function b(t){const{count:n=1,sourceType:r=["album"],mediaType:s,dom:c}=t;return new Promise(((t,l)=>{o?e&&i.chooseMedia?i.chooseMedia({count:n,sourceType:r,mediaType:s,success:e=>{t({files:e})},error:e=>{l(e)}}):i.chooseVideo({count:n,sourceType:r,success:e=>{t({files:e})},error:e=>{l(e)}}):((null==c?void 0:c.click)&&c.click(),c.value="",null==c||c.addEventListener("change",(e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)<=0||t({files:e.target.files[0]})}),!1))}))}function y(e){return b(Object.assign({mediaType:["image"]},e))}function S(e){return b(Object.assign({mediaType:["video"]},e))}const E=new Map;function v(e,t){E.set(e,t)}function T(e,t){if(!e)return Promise.reject(new Error(`getBoundingClientRect get error selector ${typeof e}.`));if(window||document){const t="object"==typeof e?e:document.querySelector(e);if(!t)return Promise.reject(new Error(`getBoundingClientRect can't find ${e} dom.`));const n=t.getBoundingClientRect();return Promise.resolve({id:t.id,top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height,x:n.x,y:n.y})}if(o){if(!t)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const n=uni.createSelectorQuery().in(E.get(t));return new Promise(((t,o)=>{n.select(e).boundingClientRect((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getBoundingClientRect ${e} timeout.`))),500)}))}return Promise.reject(new Error("getBoundingClientRect occur error"))}function C(e){if(o)throw new Error("getBoundingClientRectSync can not use in uni-app.");if(window||document){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getBoundingClientRectSync can't find ${e} dom.`);const n=t.getBoundingClientRect();return{id:t.id,top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height,x:n.x,y:n.y}}throw new Error("getBoundingClientRectSync occur error.")}function P(e,t){if(!e)return Promise.reject(new Error(`getScrollInfo get error selector ${typeof e}.`));if(!o&&window){const t="object"==typeof e?e:document.querySelector(e);return t?Promise.resolve({id:t.id,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}):Promise.reject(new Error(`getScrollInfo can't find ${e} dom.`))}if(o){if(!t)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const n=uni.createSelectorQuery().in(E.get(t));return new Promise(((t,o)=>{n.select(e).scrollOffset((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getScrollInfo ${e} timeout.`))),500)}))}return Promise.reject(new Error("getScrollInfo occur error"))}function x(e){if(o)throw new Error("getScrollInfoSync can not use in uni-app.");if(!o&&window){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getScrollInfoSync can't find ${e} dom.`);return{id:t.id,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}}throw new Error("getScrollInfoSync() occur error.")}function R(e,t){if(o){if(!t)return Promise.reject(new Error("getFields need instanceName in params."));const n=uni.c
|