webviewPage.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view>
  3. <web-view :webview-styles="webviewStyles" :src="url" style='width: 100%;max-width:100%' ></web-view>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. url: "",
  11. webviewStyles: {
  12. progress: {
  13. color: '#F07423'
  14. }
  15. },
  16. type: "",
  17. };
  18. },
  19. onLoad(param) {
  20. this.type = param.type;
  21. let title = ""
  22. if (this.type == 1) {
  23. title = "用户使用协议"
  24. } else if (this.type == 2) {
  25. title = "隐私协议"
  26. } else if (this.type == 3) {
  27. title = "入驻协议"
  28. }
  29. uni.setNavigationBarTitle({
  30. title: title
  31. })
  32. this.webviewStyles.progress.color = getApp().globalData.color1;
  33. this.queryProtocolConfigView();
  34. },
  35. methods: {
  36. async queryProtocolConfigView() {
  37. let res = await this.$myRequest({
  38. url: "/project/queryProtocolConfigView",
  39. data: {},
  40. })
  41. if (res.data.success) {
  42. const curryUrl = this.curry("/hybrid/html/web/viewer.html?file=")
  43. if (this.type == '1') { //使用协议
  44. this.url = curryUrl(res.data.single.userUseProtocol);
  45. } else if (this.type == '2') { //隐私协议
  46. this.url = curryUrl(res.data.single.userPrivacyProtocol);
  47. } else if (this.type == '3') { //业主注册协议
  48. this.url = curryUrl(res.data.single.ownerRegistProtocol);
  49. }
  50. }
  51. },
  52. curry(baseUrl) {
  53. return function(url) {
  54. let index = url.lastIndexOf('.');
  55. if (url.substring(index + 1).indexOf('pdf') > -1) {
  56. return baseUrl + url;
  57. } else {
  58. return url;
  59. }
  60. }
  61. },
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. </style>