Blame view

ceres-uniapp-master/components/canvasShow/basics/banner.vue 4.41 KB
3f535f30   杨鑫   '初始'
1
2
3
  <template>
    <div class="banner" :class="'terminal' + terminal">
      <swiper class="swiper" :circular="true" :indicator-dots="false" :autoplay="true" :style="{'height':bannerHeight + 'rpx'}" @change="swiperChange">
72e22e26   杨鑫   最新修改
4
5
        <swiper-item class="banner-item" v-for="(item,index) in bannerList" :key="index" :style="{backgroundImage: 'url('+item.imageUrl+')'}"  @click="jumpLink(item.jumpUrl,item.id)">
          <div class="a-link" @click="jumpLink(item.jumpUrl,item.id)"><img class="img" :src="item.imageUrl" v-show="item.imageUrl" mode="widthFix"></div>
3f535f30   杨鑫   '初始'
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
        </swiper-item>
      </swiper>
      <view class="swiper-dots" v-if="bannerList && bannerList.length > 1">
        <text class="dot" :class="index === swiperCurrent  && 'dot-active'" v-for="(dot, index) in bannerList.length"
              :key="index"></text>
      </view>
    </div>
  </template>
  
  <script>
    import {funMixin} from '../config/mixin';
    const API = require('../../../config/api')
    const NET = require('../../../utils/request')
    export default {
      name: 'cereBanner',
      mixins: [funMixin],
      data () {
        return {
          bannerHeight: 0,
          swiperCurrent: 0,
  		bannerList:[]
  			  }
      },
      props: {
        terminal: {
          type: Number,
          default: 4
        },
        componentContent: {
          type: Object
        }
      },
      mounted() {
  		let pagesize = {
  			pageNumber: 1,
  			pageSize: 10,
5d752fd3   杨鑫   '最新'
42
  			type:1
3f535f30   杨鑫   '初始'
43
44
  			}
  		NET.request2(API.cereCarouselImage, pagesize, 'POST').then(res => {
3bfff9e5   杨鑫   最新1
45
46
  			res.data.content.map(item=>{
  				 if(item.state ==1){
233bb387   杨鑫   Merge branch 'mas...
47
  					 item.imageUrl ='https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/sp/6fcdaf60-9442-4172-8247-9869761aa247-0c5150bb-7419-43e2-a8b0-e57c305eb99b-微信图片_20250110172248.jpg'
3bfff9e5   杨鑫   最新1
48
49
50
51
52
  					 item.jumpUrl = ''
  				 } 
  				 
  			})
  			this.bannerList = res.data.content
b7023175   杨鑫   '最新'
53
  			
3f535f30   杨鑫   '初始'
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  		})
  		// uni.request({
  		//     url: 'http://8.130.38.56:8027/admin-server/cereCarouselImage/queryByPage', //仅为示例,并非真实接口地址。
  		//     data: {
  		//        pageNumber: 1, 
  		//        pageSize: 10
  		//     },
  		//     header: {
  		//         'content-type': 'application/json;charset=UTF-8' //自定义请求头信息
  		//     },
  		//     success: (res) => {
  		//         console.log(res.data);
  		      
  		//     }
  		// });
  
        this.bannerHeight = this.componentContent.height
        this.$forceUpdate() // 刷新轮播图
      },
b7023175   杨鑫   '最新'
73
74
75
76
77
78
79
80
      // computed: {
      //   bannerList: function () {
      //     console.log(this.componentContent)
      //     return this.componentContent.bannerData.filter(function (item) {
      //       return item.bannerUrl
      //     })
      //   }
      // },
3f535f30   杨鑫   '初始'
81
      methods:{
72e22e26   杨鑫   最新修改
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  		getCurrentTime() {
  		     const now = new Date();
  		     const year = now.getFullYear();
  		     const month = ('0' + (now.getMonth() + 1)).slice(-2);
  		     const day = ('0' + now.getDate()).slice(-2);
  		     const hours = ('0' + now.getHours()).slice(-2);
  		     const minutes = ('0' + now.getMinutes()).slice(-2);
  		     const seconds = ('0' + now.getSeconds()).slice(-2);
  					
  		     return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  		   },
  		jumpLink(urls,ids){
  			let obj ={
  				adPlacementId:ids,
  				createdAt:this.getCurrentTime()
  			}
  			NET.request(API.bannerUpdete, obj, 'POST').then(res => {
  			})
3f535f30   杨鑫   '初始'
100
101
  			if(urls){
  					window.open(urls, '_blank');
3f535f30   杨鑫   '初始'
102
  			}
72e22e26   杨鑫   最新修改
103
104
105
106
107
  			// else{
  			// 	uni.navigateTo({
  			// 		url: '/pages_category_page1/goodsModule/goodsList'
  			// 	});
  			// }
3f535f30   杨鑫   '初始'
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
  			
  		
  			// uni.navigateBack({
  			//   url: urls
  			// });
  		},
        swiperChange(e) {
          this.swiperCurrent = e.detail.current;
        }
      }
    }
  </script>
  
  <style lang="scss" scoped>
  .banner{
    position: relative;
    margin-top: 20rpx;
    margin-bottom: 20rpx;
    .banner-item{
      width: 100%;
      background-repeat: no-repeat;
      background-position: center;
      background-size: auto 100%;
      img{
        display: none;
      }
    }
    &.terminal4{
      ::v-deep .el-carousel{
        height: 100%;
        .el-carousel__container{
          height: 100%;
        }
      }
      .banner-item{
        background-repeat: no-repeat;
        background-position: center;
        background-size: auto 100%;
        img{
          display: none;
        }
      }
    }
  
    .swiper-dots {
      display: flex;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      bottom: 20upx;
      z-index: 200;
      .dot {
        width: 12upx;
        height: 12upx;
        background: #FFFFFF;
        border-radius: 6upx;
        opacity: 0.2;
        margin: 0 10upx;
      }
  
      .dot-active {
        opacity: 1;
        width: 24upx;
      }
    }
  
  }
  </style>