index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="text-v">
  3. <view class="" v-if="option.styleType==1">
  4. <view v-if="option.textAutoplay" @click="jump"
  5. :style="{'font-weight':option.textFontWeight?700:400,'font-style':option.textFontStyle?'italic':'normal','text-decoration':option.textUnderLine,'color':option.textFontColor}">
  6. <u-notice-bar :volume-icon="false" :list="option.defaultValue" :bg-color="option.textBgColor || '#fff'"
  7. :color="option.textFontColor" :font-size="option.textFontSize*2" :speed="option.textAutoplaySpeed"
  8. :autoplay="option.textAutoplay">
  9. </u-notice-bar>
  10. </view>
  11. <view class="txtSty" v-if="!option.textAutoplay" @click="jump"
  12. :style="{'color':option.textFontColor,'font-size':option.textFontSize*2+'rpx','background-color':option.textBgColor,'font-weight':option.textFontWeight?700:400,'text-decoration':option.textUnderLine,'font-style':option.textFontStyle?'italic':'normal','text-align':option.textLeft}">
  13. <text>{{option.defaultValue}}</text>
  14. </view>
  15. </view>
  16. <view class="u-p-20 parse" v-if="option.styleType==2">
  17. <mp-html class="editor-box" :content="option.defaultValue" :key="key" />
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. getDataInterfaceRes
  24. } from '@/api/common'
  25. export default {
  26. props: {
  27. config: {
  28. type: Object,
  29. default: () => {}
  30. }
  31. },
  32. data() {
  33. return {
  34. option: {},
  35. key: +new Date()
  36. }
  37. },
  38. created() {
  39. this.init()
  40. uni.$off('proRefresh')
  41. uni.$on('proRefresh', () => {
  42. this.initData()
  43. })
  44. },
  45. methods: {
  46. init() {
  47. this.option = JSON.parse(JSON.stringify(this.config.option))
  48. this.initData()
  49. if (!this.config.allRefresh.autoRefresh && this.config.refresh.autoRefresh) {
  50. setInterval(this.initData, this.config.refresh.autoRefreshTime * 60000)
  51. }
  52. },
  53. jump() {
  54. let item = {
  55. urlAddress: this.option.appUrlAddress,
  56. value: this.option.defaultValue
  57. }
  58. this.jnpf.solveAddressParam(item, this.config)
  59. this.option.appUrlAddress = item.urlAddress
  60. if (this.config.platform === 'mp') return
  61. let url;
  62. if (!this.option.appLinkType) return
  63. if (this.option.appLinkType == 1 && this.option.appType == 8) {
  64. let propertyJson = JSON.parse(this.option.appPropertyJson)
  65. uni.navigateTo({
  66. url: "/pages/portal/scanPortal/index?id=" + propertyJson.moduleId + "&protalType=1" +
  67. "&fullName=" + this.option.defaultValue || '',
  68. fail: (err) => {},
  69. });
  70. return
  71. }
  72. if (this.option.appLinkType == 1) {
  73. let data = {
  74. id: this.option.appModuleId,
  75. moduleId: this.option.appModuleId,
  76. urlAddress: this.option.appUrlAddress,
  77. ...JSON.parse(this.option.appPropertyJson)
  78. }
  79. if (this.option.appType == 3) {
  80. url = '/pages/apply/dynamicModel/index?config=' +
  81. this.jnpf.base64.encode(JSON.stringify(data))
  82. } else if (this.option.appType == 2) {
  83. url = this.option.appUrlAddress + '?menuId=' + this.option.appModuleId
  84. } else {
  85. url = '/pages/apply/externalLink/index?url=' + encodeURIComponent(this.option.appUrlAddress)
  86. }
  87. } else {
  88. url = '/pages/apply/externalLink/index?url=' + encodeURIComponent(this.option.appUrlAddress)
  89. }
  90. uni.navigateTo({
  91. url: url,
  92. fail: (err) => {
  93. this.$u.toast("暂无此页面")
  94. }
  95. })
  96. },
  97. initData() {
  98. if (this.config.dataType === "dynamic") {
  99. if (!this.config.propsApi) return
  100. const query = {
  101. paramList: this.config.templateJson
  102. };
  103. getDataInterfaceRes(this.config.propsApi, query).then(res => {
  104. this.option.defaultValue = res.data
  105. if (this.option.styleType == 2 && typeof(res) != 'string') {
  106. this.option.defaultValue = JSON.stringify(res)
  107. }
  108. this.handleAttrs()
  109. })
  110. } else {
  111. this.handleAttrs()
  112. }
  113. },
  114. handleAttrs() {
  115. if (this.option.textAutoplay) this.option.defaultValue = [this.option
  116. .defaultValue
  117. ]
  118. this.key = +new Date()
  119. },
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. .text-v {
  125. // padding: 20rpx 0;
  126. ::v-deep .u-notice-box {
  127. margin-bottom: 0 !important;
  128. }
  129. .parse {
  130. word-break: break-all;
  131. }
  132. .txtSty {
  133. width: 100wh;
  134. height: 100%;
  135. padding: 20rpx;
  136. word-wrap: break-word;
  137. color: blue;
  138. font-size: 36rpx;
  139. }
  140. }
  141. </style>