hysbanner.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="hometop">
  3. <swiper class="swiper" circular :indicator-active-color="activecolor" :current="currentidx" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
  4. :duration="duration">
  5. <block v-for="(ite,idx) in bannerlist" :key='idx'>
  6. <swiper-item>
  7. <image :src="baseUrl+ite" class="swiperimg" @click.stop="getPreviewImage(idx)"></image>
  8. </swiper-item>
  9. </block>
  10. </swiper>
  11. <block v-if="bannerlist.length>1">
  12. <image :src="leftimg" class="arrow arrowleft" @click.stop="prev"></image>
  13. <image :src="rightimg" class="arrow arrowright" @click.stop="next"></image>
  14. </block>
  15. </view>
  16. </template>
  17. <script>
  18. import config from '@/config.js';
  19. export default{
  20. props:{
  21. bannerlist:{
  22. type: Array,
  23. default () {
  24. return []
  25. }
  26. },
  27. type:{
  28. type: String,
  29. default () {
  30. return 'zhao'
  31. }
  32. },
  33. currentdate:{
  34. type: String,
  35. default () {
  36. return ''
  37. }
  38. }
  39. },
  40. data(){
  41. return{
  42. leftimg:require('@/work/static/yuy/left.png'),
  43. rightimg:require('@/work/static/yuy/right.png'),
  44. background: ['color1', 'color2', 'color3'],
  45. activecolor:'#ffffff',
  46. indicatorDots: true,
  47. autoplay: false,
  48. interval: 2000,
  49. duration: 500,
  50. baseUrl:config.baseUrl,
  51. currentidx:0,
  52. }
  53. },
  54. methods:{
  55. getPreviewImage(idx){
  56. var newArr=[];
  57. var arr=this.bannerlist
  58. arr.forEach(ite=>{
  59. var ds=this.baseUrl+ite
  60. newArr.push(ds)
  61. })
  62. uni.previewImage({
  63. urls: newArr,
  64. current:idx,
  65. success: function(data) {
  66. },
  67. fail: function(err) {
  68. }
  69. });
  70. },
  71. prev(){
  72. var len=this.bannerlist.length
  73. this.currentidx=(this.currentidx-1+len)%len
  74. },
  75. next(){
  76. var len=this.bannerlist.length
  77. this.currentidx=(this.currentidx+1)%len
  78. }
  79. },
  80. mounted() {
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .hometop{position: relative;}
  86. .arrow{width: 30rpx;height: 30rpx;position: absolute;top: 50%;transform: translateY(-50%);
  87. &.arrowleft{left: 26rpx;}
  88. &.arrowright{right: 26rpx;}
  89. }
  90. // height: 246rpx;
  91. .swiper{height: 322rpx;position: relative;border-radius: 10rpx;overflow: hidden;
  92. .swiperimg{width: 100%;height: 100%;border-radius: 10rpx;overflow: hidden;}
  93. }
  94. .swiper /deep/ .uni-swiper-wrapper .uni-swiper-dot{
  95. width:12rpx;height:12rpx;border-radius: 50%;background: rgba(0, 0, 0, 0.5);
  96. }
  97. .swiper /deep/ .uni-swiper-wrapper .uni-swiper-dot-active{
  98. width: 20rpx;height: 12rpx;border-radius: 6rpx;background-color: #ffffff;
  99. }
  100. // wx
  101. .swiper /deep/ .wx-swiper-wrapper .wx-swiper-dot{
  102. width:12rpx;height:12rpx;border-radius: 50%;background: rgba(0, 0, 0, 0.5);
  103. }
  104. .swiper /deep/ .wx-swiper-wrapper .wx-swiper-dot-active{
  105. width: 20rpx;height: 12rpx;border-radius: 6rpx;background-color: #ffffff;
  106. }
  107. .bannerfot{position: absolute;left: 0;right: 0;height: 70rpx;background-color: rgba(0, 0, 0, 0.5);padding: 0 32rpx;bottom: 0;display: flex;align-items: center;justify-content: space-between;}
  108. </style>