Model1.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="model-1">
  3. <view class="adv-wrapper" :style="{backgroundColor:editablePageConfig.editable_page_config_content.back_color}">
  4. <swiper v-bind:style="getBannerStyle" :vertical="editablePageConfig.editable_page_config_content.show_format==1" :autoplay="true" :indicator-dots="isShowIndicators">
  5. <swiper-item v-for="(item,index) in editablePageConfig.editable_page_config_content.adv" :key="index">
  6. <image mode="aspectFit" :style="getBannerStyle" :src="item.image" @click="goAdUrl(item.link)"/>
  7. </swiper-item>
  8. </swiper>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'Model1',
  15. data () {
  16. return {}
  17. },
  18. props: ['editablePageConfig','editablePage'],
  19. computed: {
  20. itemSize(){
  21. let itemWidth = parseFloat(this.editablePageConfig.editable_page_config_content.image_width)
  22. let itemHeight = parseFloat(this.editablePageConfig.editable_page_config_content.image_height)
  23. if(isNaN(itemWidth) || itemWidth<=0){
  24. itemWidth=750
  25. }
  26. if(isNaN(itemHeight) || itemHeight<=0){
  27. itemHeight=376
  28. }
  29. const { width, height } = window.screen
  30. var imageWidth=width-parseFloat(this.editablePage.editable_page_theme_config.page_margin)*2
  31. return {
  32. width: imageWidth,
  33. height: itemHeight/itemWidth*imageWidth
  34. }
  35. },
  36. getBannerStyle: function () {
  37. return {
  38. width: this.itemSize.width+'px',
  39. height: this.itemSize.height+'px'
  40. }
  41. },
  42. isShowIndicators () {
  43. if (this.editablePageConfig.editable_page_config_content.adv.length>1) {
  44. return true
  45. }
  46. return false
  47. },
  48. },
  49. methods: {
  50. goAdUrl (url) {
  51. uni.navigateTo({url: url })
  52. }
  53. }
  54. }
  55. </script>
  56. <style scoped lang="scss">
  57. .model-1 .adv-wrapper .wrapper{position:relative}
  58. .model-1 .adv-wrapper{
  59. overflow: hidden;
  60. position:relative;
  61. font-size: 0;
  62. border-radius: 5px;
  63. }
  64. .model-1 .adv-wrapper .bd{position:relative;transition: top 0.5s;}
  65. .model-1 .adv-wrapper .hd {
  66. position:absolute;
  67. bottom:10px;
  68. text-align: center;
  69. width: 100%;
  70. }
  71. .model-1 .adv-wrapper .hd .li{
  72. display: inline-block;
  73. width:10px;
  74. height: 10px;
  75. border-radius:10px;
  76. background-color: rgba(0,0,0,.5);
  77. margin:0 5px;
  78. }
  79. .model-1 .adv-wrapper .hd .li.on{
  80. background-color: rgba(255,255,255,.5);
  81. }
  82. </style>