Browse Source

首页轮播

zhaoxiaohai 3 years ago
parent
commit
4d57f8fe6b

+ 2 - 1
pages/login/modules/login.js

@@ -60,12 +60,13 @@ function query_adspacelist(i = 0) {
         "method": "query_adspacelist",
         "content": {}
     }).then(res => {
-        console.log("轮播图", res)
         if (res.msg != '成功') return query_adspacelist(i + 1);
+        wx.setStorageSync('banner_list', res.data)
         count += 1;
         toHome();
     })
 }
+
 function toHome() {
     if (count < 3) return;
     let pages = getCurrentPages();

+ 7 - 3
pages/tabbar/home/index.js

@@ -6,6 +6,7 @@ Page({
      * 页面的初始数据
      */
     data: {
+        bannerList: null, //banner列表
         user: {},
         annunciateList: [], //通告列表
         gridList: [],
@@ -19,9 +20,8 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
+        /* 首页宫格授权查询 */
         if (wx.getStorageSync('userauth').length != 0) {
-
-            /* 首页宫格授权查询 */
             let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告', '推广素材', '商学院', '提报', '销售线索']),
                 gridList = [],
                 subassembly = [];
@@ -84,6 +84,11 @@ Page({
                 subassembly
             })
         }
+        /* 获取banner */
+        this.setData({
+            bannerList: wx.getStorageSync('banner_list')[0].ads
+        })
+        console.log()
         this.refreshData(wx.getStorageSync('userMsg'))
         this.setData({ //获取胶囊位置信息
             capsule: wx.getMenuButtonBoundingClientRect()
@@ -199,5 +204,4 @@ Page({
     onHide() {
         clearInterval(DataCarousel);
     },
-
 })

+ 16 - 2
pages/tabbar/home/index.scss

@@ -38,10 +38,24 @@
     /* 主内容 */
     &_content {
         position: absolute;
+        width: 690rpx;
         height: 300rpx;
-        left: 30rpx;
+        background-color: #FFFFFF;
         box-shadow: inset 0px 2rpx 0px 2rpx rgba(255, 255, 255, 0.16);
+        border-radius: 16rpx;
+        overflow: hidden;
         margin: 0 !important;
+        left: 30rpx;
+
+        swiper-item {
+            width: 100%;
+            height: 100%;
+
+            image {
+                width: 100%;
+                height: 100%;
+            }
+        }
     }
 }
 
@@ -181,7 +195,7 @@
         }
     }
 
-    .item-box{
+    .item-box {
         padding: 20rpx 0;
     }
 }

+ 5 - 2
pages/tabbar/home/index.wxml

@@ -13,8 +13,11 @@
 <!-- 轮播区域 -->
 <view class="banner">
     <view class="banner_oval" />
-    <My_card custom-class='banner_content' hover>
-    </My_card>
+    <swiper class='banner_content'>
+        <swiper-item wx:for="{{bannerList}}">
+            <image src="{{item.attinfos[0].url}}" mode="aspectFill"></image>
+        </swiper-item>
+    </swiper>
 </view>
 <view style="height: 130rpx;" />
 <!-- 滚动通知 -->