diff --git a/common/js/util.js b/common/js/util.js index 3279c14..0875518 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -988,14 +988,14 @@ export default { */ isIPhoneX() { let res = this.getDeviceInfo(); - if (res.model.search('iPhone X') != -1) { + if (res?.model?.search('iPhone X') != -1) { return true; } return false; }, //判断安卓还是iOS isAndroid() { - let platform = this.getDeviceInfo().platform; + let platform = this.getDeviceInfo()?.platform; if (platform == 'ios') { return false; } else if (platform == 'android') { @@ -1006,21 +1006,21 @@ export default { * 获取设备信息(包含降级处理) */ getDeviceInfo() { - try { - return uni.getDeviceInfo(); - } catch (e) { - return uni.getSystemInfoSync(); + let info = {}; + try { info = uni.getDeviceInfo(); } catch (e) { + try { info = uni.getSystemInfoSync(); } catch (e) {} } + return info; }, /** * 获取窗口信息(包含降级处理) */ getWindowInfo() { - try { - return uni.getWindowInfo(); - } catch (e) { - return uni.getSystemInfoSync(); + let info; + try {info = uni.getWindowInfo();} catch (e) { + try {info = uni.getSystemInfoSync();} catch (e) {} } + return info; }, /** * 深度拷贝对象 @@ -1118,10 +1118,10 @@ export default { // auto: host 完全一致才还原 const appHosts = []; // #ifdef H5 - try { if (typeof location !== 'undefined' && location.hostname) appHosts.push(location.hostname); } catch (e) {} + try { if (typeof location !== 'undefined' && location.hostname) appHosts.push(location.hostname); } catch (e) { } // #endif - try { if (Config.h5Domain) appHosts.push(Config.h5Domain); } catch (e) {} - try { if (Config.baseUrl) appHosts.push(Config.baseUrl); } catch (e) {} + try { if (Config.h5Domain) appHosts.push(Config.h5Domain); } catch (e) { } + try { if (Config.baseUrl) appHosts.push(Config.baseUrl); } catch (e) { } internalPath = _extractInternalAppPath(link.wap_url, appHosts); } if (internalPath) { @@ -1152,7 +1152,7 @@ export default { // #endif // #ifdef MP - console.log(`外部链接,跳转到webview`, url); + console.log(`外部链接,跳转到webview`, url); this.redirectTo(PAGE_KEY_MAP.PAGE_WEBVIEW, { ...link, src: url @@ -1312,7 +1312,7 @@ export default { */ uniappIsIPhone11() { let isIphone11 = false; - let systemInfo = this.getDeviceInfo(); + let systemInfo = this?.getDeviceInfo(); // #ifdef MP if (systemInfo.model.search('iPhone 11') != -1) { isIphone11 = true; @@ -1323,8 +1323,7 @@ export default { // #ifdef H5 //判断该浏览器是否为safaria浏览器 isSafari() { - let res = this.getDeviceInfo(); - var ua = navigator.userAgent.toLowerCase(); + var ua = navigator?.userAgent?.toLowerCase(); if (ua.indexOf('applewebkit') > -1 && ua.indexOf('mobile') > -1 && ua.indexOf('safari') > -1 && ua.indexOf('linux') === -1 && ua.indexOf('android') === -1 && ua.indexOf('chrome') === -1 && ua.indexOf('ios') === -1 && ua.indexOf('browser') === -1) { diff --git a/components/ns-form/ns-form.vue b/components/ns-form/ns-form.vue index 2a3840d..ca053f6 100644 --- a/components/ns-form/ns-form.vue +++ b/components/ns-form/ns-form.vue @@ -1,36 +1,59 @@