From 517fb253f39bf8120f9bed693d35349727ae650c Mon Sep 17 00:00:00 2001 From: wanshenmean <cathay_xy@163.com> Date: 星期二, 08 四月 2025 09:35:18 +0800 Subject: [PATCH] PDA添加完整URL判断 --- 代码管理/NEWCode/WIDESEAWCS_PDA/uview-ui/libs/request/index.js | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/uview-ui/libs/request/index.js" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/uview-ui/libs/request/index.js" index 1f5f471..c07f38a 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/uview-ui/libs/request/index.js" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_PDA/uview-ui/libs/request/index.js" @@ -15,7 +15,7 @@ let interceptorRequest = this.interceptor.request(options); if (interceptorRequest === false) { // 杩斿洖涓�涓浜巔ending鐘舵�佷腑鐨凱romise锛屾潵鍙栨秷鍘焢romise锛岄伩鍏嶈繘鍏hen()鍥炶皟 - return new Promise(()=>{}); + return new Promise(() => {}); } this.options = interceptorRequest; } @@ -34,7 +34,7 @@ clearTimeout(this.config.timer); this.config.timer = null; // 鍒ゆ柇鐢ㄦ埛瀵规嫤鎴繑鍥炴暟鎹殑瑕佹眰锛屽鏋渙riginalData涓簍rue锛岃繑鍥炴墍鏈夌殑鏁版嵁(response)鍒版嫤鎴櫒锛屽惁鍒欏彧杩斿洖response.data - if(this.config.originalData) { + if (this.config.originalData) { // 鍒ゆ柇鏄惁瀛樺湪鎷︽埅鍣� if (this.interceptor.response && typeof this.interceptor.response === 'function') { let resInterceptors = this.interceptor.response(response); @@ -51,7 +51,8 @@ } } else { if (response.statusCode == 200) { - if (this.interceptor.response && typeof this.interceptor.response === 'function') { + if (this.interceptor.response && typeof this.interceptor.response === + 'function') { let resInterceptors = this.interceptor.response(response.data); if (resInterceptors !== false) { resolve(resInterceptors); @@ -74,14 +75,20 @@ } } - // 鍒ゆ柇鐢ㄦ埛浼犻�掔殑URL鏄惁/寮�澶�,濡傛灉涓嶆槸,鍔犱笂/锛岃繖閲屼娇鐢ㄤ簡uView鐨則est.js楠岃瘉搴撶殑url()鏂规硶 - options.url = validate.url(options.url) ? options.url : (this.config.baseUrl + (options.url.indexOf('/') == 0 ? - options.url : '/' + options.url)); - + // 鍒ゆ柇鏄惁涓哄畬鏁� URL锛屽鏋滄槸鍒欎笉浣跨敤 baseUrl + if (options.url.includes('http://') || options.url.includes('https://')) { + options.url = options.url; + } else { + // 鍒ゆ柇鐢ㄦ埛浼犻�掔殑URL鏄惁/寮�澶�,濡傛灉涓嶆槸,鍔犱笂/锛岃繖閲屼娇鐢ㄤ簡uView鐨則est.js楠岃瘉搴撶殑url()鏂规硶 + options.url = validate.url(options.url) ? options.url : (this.config.baseUrl + (options.url + .indexOf('/') == 0 ? + options.url : '/' + options.url)); + } + // 鏄惁鏄剧ずloading // 鍔犱竴涓槸鍚﹀凡鏈塼imer瀹氭椂鍣ㄧ殑鍒ゆ柇锛屽惁鍒欐湁涓や釜鍚屾椂璇锋眰鐨勬椂鍊欙紝鍚庤�呬細娓呴櫎鍓嶈�呯殑瀹氭椂鍣╥d // 鑰屾病鏈夋竻闄ゅ墠鑰呯殑瀹氭椂鍣紝瀵艰嚧鍓嶈�呰秴鏃讹紝涓�鐩存樉绀簂oading - if(this.config.showLoading && !this.config.timer) { + if (this.config.showLoading && !this.config.timer) { this.config.timer = setTimeout(() => { uni.showLoading({ title: this.config.loadingText, @@ -116,7 +123,7 @@ originalData: false, // 鏄惁鍦ㄦ嫤鎴櫒涓繑鍥炴湇鍔$鐨勫師濮嬫暟鎹紝瑙佹枃妗h鏄� loadingMask: true, // 灞曠ずloading鐨勬椂鍊欙紝鏄惁缁欎竴涓�忔槑鐨勮挋灞傦紝闃叉瑙︽懜绌块�� } - + // 鎷︽埅鍣� this.interceptor = { // 璇锋眰鍓嶇殑鎷︽埅 @@ -144,7 +151,7 @@ data }) } - + // put璇锋眰锛屼笉鏀寔鏀粯瀹濆皬绋嬪簭(HX2.6.15) this.put = (url, data = {}, header = {}) => { return this.request({ @@ -154,7 +161,7 @@ data }) } - + // delete璇锋眰锛屼笉鏀寔鏀粯瀹濆拰澶存潯灏忕▼搴�(HX2.6.15) this.delete = (url, data = {}, header = {}) => { return this.request({ @@ -166,4 +173,4 @@ } } } -export default new Request +export default new Request \ No newline at end of file -- Gitblit v1.9.3