webviewPage.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. wx.hideMenuItems({
  35. menuList: ['menuItem:share:qq','menuItem:share:QZone','menuItem:favorite','menuItem:originPage','menuItem:copyUrl','menuItem:openWithSafari','menuItem:openWithQQBrowser'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
  36. });
  37. },
  38. methods: {
  39. async queryProtocolConfigView() {
  40. let res = await this.$myRequest({
  41. url: "/project/queryProtocolConfigView",
  42. data: {},
  43. })
  44. if (res.data.success) {
  45. const curryUrl = this.curry("/hybrid/html/web/viewer.html?file=")
  46. if (this.type == '1') { //使用协议
  47. this.url = curryUrl(res.data.single.userUseProtocol);
  48. } else if (this.type == '2') { //隐私协议
  49. this.url = curryUrl(res.data.single.userPrivacyProtocol);
  50. } else if (this.type == '3') { //业主注册协议
  51. this.url = curryUrl(res.data.single.ownerRegistProtocol);
  52. }
  53. }
  54. },
  55. curry(baseUrl) {
  56. return function(url) {
  57. let index = url.lastIndexOf('.');
  58. if (url.substring(index + 1).indexOf('pdf') > -1) {
  59. return baseUrl + url;
  60. } else {
  61. return url;
  62. }
  63. }
  64. },
  65. }
  66. }
  67. </script>
  68. <style lang="scss">
  69. </style>