index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="image-v">
  3. <view class="custom-cover" @click="jump()">
  4. <image class="cover-image" :mode="option.imageFillStyle" :src="imgUrl"></image>
  5. <view class="cover-content"
  6. :style="{'justify-content':option.textLeft,'background-color':option.textBgColor}">
  7. <text class=" uni-subtitle uni-white"
  8. :style="{'text-decoration':option.textUnderLine,'color':option.textFontColor,'font-weight':option.textFontWeight?700:0,'font-size':option.textFontSize}">{{option.textDefaultValue}}</text>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import {
  15. getDataInterfaceRes
  16. } from '@/api/common'
  17. export default {
  18. props: {
  19. config: {
  20. type: Object,
  21. default: () => {}
  22. }
  23. },
  24. data() {
  25. return {
  26. option: {},
  27. imgUrl: ''
  28. }
  29. },
  30. created() {
  31. this.init()
  32. uni.$off('proRefresh')
  33. uni.$on('proRefresh', () => {
  34. this.initData()
  35. })
  36. },
  37. methods: {
  38. init() {
  39. this.option = JSON.parse(JSON.stringify(this.config.option))
  40. this.option.imageFillStyle = this.option.imageFillStyle === 'fill' ? 'scaleToFill' : this.option
  41. .imageFillStyle === 'cover' ? ' aspectFill' : 'aspectFit'
  42. this.option.textFontSize = this.option.textFontSize * 2 + 'rpx'
  43. this.initData()
  44. if (!this.config.allRefresh.autoRefresh && this.config.refresh.autoRefresh) {
  45. setInterval(this.initData, this.config.refresh.autoRefreshTime * 60000)
  46. }
  47. },
  48. initData() {
  49. if (this.option.styleType == 1) this.imgUrl = this.define.baseURL + this.option.defaultValue
  50. if (this.option.styleType == 2) this.imgUrl = this.option.defaultValue
  51. if (this.config.dataType === "dynamic") {
  52. if (!this.config.propsApi) return
  53. const query = {
  54. paramList: this.config.templateJson
  55. };
  56. getDataInterfaceRes(this.config.propsApi, query).then(res => {
  57. this.imgUrl = toString.call(res.data) === `[object String]` ? res.data : ''
  58. })
  59. }
  60. },
  61. jump() {
  62. if (this.config.platform === 'mp') return
  63. let url = '';
  64. if (this.config.option.appLinkType == 1 && this.config.option.appType == 3) {
  65. let data = {
  66. id: this.config.option.appModuleId,
  67. moduleId: this.config.option.appModuleId,
  68. urlAddress: this.config.option.appUrlAddress,
  69. ...JSON.parse(this.config.option.propertyJson)
  70. }
  71. url = '/pages/apply/dynamicModel/index?config=' +
  72. this.jnpf.base64.encode(JSON.stringify(data))
  73. } else if (this.config.option.appLinkType == 1 && this.config.option.appType == 2) {
  74. url = this.config.option.appUrlAddress
  75. } else if (this.config.option.appLinkType == 1 && this.config.option.appType == 8) {
  76. let propertyJson = JSON.parse(this.config.option.appPropertyJson)
  77. uni.navigateTo({
  78. url: "/pages/portal/scanPortal/index?id=" + propertyJson.moduleId + "&protalType=1" +
  79. "&fullName=" + this.config.option.textDefaultValue || '',
  80. fail: (err) => {},
  81. });
  82. return
  83. } else {
  84. if (!this.config.option.appUrlAddress) return
  85. url = '/pages/apply/externalLink/index?url=' + encodeURIComponent(this.config.option.appUrlAddress) +
  86. '&fullName= ' + this.config.option.fullName
  87. }
  88. uni.navigateTo({
  89. url: url,
  90. fail: (err) => {
  91. // this.$u.toast("暂无此页面")
  92. }
  93. })
  94. },
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. .image-v {
  100. .custom-cover {
  101. display: flex;
  102. width: 100%;
  103. flex: 1;
  104. flex-direction: row;
  105. position: relative;
  106. margin: 20rpx 0;
  107. .cover-image {
  108. width: 100%;
  109. }
  110. .cover-content {
  111. position: absolute;
  112. bottom: 0;
  113. left: 0;
  114. right: 0;
  115. height: 40px;
  116. display: flex;
  117. flex-direction: row;
  118. align-items: center;
  119. padding-left: 15px;
  120. }
  121. }
  122. }
  123. </style>