|
@@ -0,0 +1,44 @@
|
|
|
+window.onload=function(){
|
|
|
+ $('#myCarousel').html(`
|
|
|
+ <ol class="carousel-indicators"></ol>
|
|
|
+ <div class="carousel-inner"></div>
|
|
|
+ `)
|
|
|
+ let href = window.location.href,http = window.location.host,api='';
|
|
|
+ let pre = /.html|\#|\?/,
|
|
|
+ r1 = href.match(pre);
|
|
|
+ if(pre.test(href)){
|
|
|
+ let p1 = href.split(r1);
|
|
|
+ api=p1[0].split('/').pop();
|
|
|
+ }else{
|
|
|
+ api=href.split('/').pop();
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ method:'get',
|
|
|
+ dataType:'json',
|
|
|
+ url: globalConfig.context + "/api/portal/banners/list",
|
|
|
+ data:{
|
|
|
+ apiUrl:api,
|
|
|
+ client:0
|
|
|
+ }
|
|
|
+ }).done(data=>{
|
|
|
+ let theData=data.data,bannerDott=[],bannerImgs=[];
|
|
|
+ theData.map((item,index)=>{
|
|
|
+ bannerDott.push(`
|
|
|
+ <li data-target="#myCarousel" data-slide-to=${index} class="${index?'':'active'}"></li>
|
|
|
+ `);
|
|
|
+ bannerImgs.push(`
|
|
|
+ <div class="${index?'item':'item active'}">
|
|
|
+ <a href="${item.forwardUrl?'http://'+http+item.forwardUrl:'javascript:;'}"><img src="${globalConfig.avatarHost+item.imgUrl}" alt="${item.text}"></a>
|
|
|
+ </div>
|
|
|
+ `);
|
|
|
+ })
|
|
|
+ $('.carousel-indicators').html(bannerDott.length>1?bannerDott.join(''):'');
|
|
|
+ $('.carousel-inner').html(bannerImgs.join(''));
|
|
|
+ if(theData.length>1){
|
|
|
+ $('#myCarousel').append(`
|
|
|
+ <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
|
|
|
+ <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
|
|
|
+ `)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|