img1.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view :style="{padding:showStyle}">
  3. <view v-if="storage" class="bg-white" >
  4. <image @click="naviageToPage(nav)" :src="imgUrl"
  5. :mode="imgStyle==='cover'?'aspectFill':'scaleToFill'"
  6. :style="{borderRadius:borderRadius,height:getHeight}"
  7. style="width: 100%;"
  8. ></image>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'img1',
  15. props: ['storage', 'options'],
  16. computed: {
  17. imgStyle() {
  18. return this.options.imgStyle
  19. },
  20. showStyle() {
  21. if (this.options.showStyle == 'custom'){
  22. return this.options.customStyle
  23. }
  24. return this.options.showStyle
  25. },
  26. nav() {
  27. return this.options.nav
  28. },
  29. imgUrl() {
  30. let imgUrl = this.options.imgUrl
  31. if (imgUrl) {
  32. return JSON.parse(imgUrl)[0].url
  33. } else {
  34. return "https://nontax.oss-cn-beijing.aliyuncs.com/kxmall/G2urVA.png"
  35. }
  36. },
  37. borderRadius() {
  38. return this.options.borderRadius
  39. },
  40. getHeight() {
  41. return this.options.height
  42. }
  43. },
  44. methods: {
  45. naviageToPage(url, title) {
  46. this.$emit('naviage-to-page', url, title)
  47. }
  48. }
  49. }
  50. </script>
  51. <style scoped lang="scss">
  52. </style>