张文飞 3 лет назад
Родитель
Сommit
acd5904ca0
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      pages/webviewPage/webviewPage.vue

+ 14 - 3
pages/webviewPage/webviewPage.vue

@@ -40,15 +40,26 @@
 					data: {},
 				})
 				if (res.data.success) {
+					const curryUrl =  this.curry("/hybrid/html/web/viewer.html?file=")
 					if (this.type == '1') { //使用协议
-						this.url = "/hybrid/html/web/viewer.html?file="+res.data.single.userUseProtocol;
+						this.url = curryUrl(res.data.single.userUseProtocol);
 					} else if (this.type == '2') { //隐私协议
-						this.url = "/hybrid/html/web/viewer.html?file="+res.data.single.userPrivacyProtocol;
+					    this.url = curryUrl(res.data.single.userPrivacyProtocol);
 					} else if (this.type == '3') { //业主注册协议
-						this.url = "/hybrid/html/web/viewer.html?file="+res.data.single.ownerRegistProtocol;
+						this.url = curryUrl(res.data.single.ownerRegistProtocol);
 					}
 				}
 			},
+			curry(baseUrl){
+				return function(url){
+					let index = url.lastIndexOf('.');
+					if(url.substring(index+1).indexOf('pdf')>-1){
+						return baseUrl+url;
+					}else{
+						return url;
+					}
+				}
+			}
 		}
 	}
 </script>