liming 5 jaren geleden
bovenliggende
commit
7e0e60f829
2 gewijzigde bestanden met toevoegingen van 71 en 4 verwijderingen
  1. 68 1
      pages/policy/index.js
  2. 3 3
      pages/policy/index.wxml

+ 68 - 1
pages/policy/index.js

@@ -15,6 +15,7 @@ Page({
       height: app.globalData.height * 2 + 20,
     },
     currentTab: 0,
+    sHeight:'100vh',
     policyPageIndex: 0,
     policyPageSize: 6,
     policyHasMore: true,
@@ -46,6 +47,25 @@ Page({
     that.setData({
       currentTab: e.detail.current
     });
+
+    if(this.data.currentTab === 0){
+      console.log(this.data.currentTab);
+      let query = wx.createSelectorQuery();
+      query.select('#policy').boundingClientRect(function (rect) {
+        that.setData({
+          sHeight: 180*(that.data.policyList.length)+'rpx'
+        })
+      }).exec();
+    }else {
+      console.log(this.data.currentTab);
+      let query = wx.createSelectorQuery();
+      query.select('#unscramble').boundingClientRect(function (rect) {
+        that.setData({
+          sHeight: 180*(that.data.unscrambleList.length)+'rpx'
+        })
+      }).exec();
+    }
+
   },
 
   policyListDetail: function (e) {
@@ -74,13 +94,33 @@ Page({
   },*/
   //点击切换
   clickTab: function (e) {
+    console.log('点击切换');
     var that = this;
     if (this.data.currentTab === e.target.dataset.current) {
       return false;
     } else {
       that.setData({
         currentTab: e.target.dataset.current
-      })
+      });
+
+      if(this.data.currentTab === 0){
+        console.log(this.data.currentTab);
+        let query = wx.createSelectorQuery();
+        query.select('#policy').boundingClientRect(function (rect) {
+          that.setData({
+            sHeight: 180*(that.data.policyList.length)+'rpx'
+          })
+        }).exec();
+      }else {
+        console.log(this.data.currentTab);
+        let query = wx.createSelectorQuery();
+        query.select('#unscramble').boundingClientRect(function (rect) {
+          that.setData({
+            sHeight: 180*(that.data.unscrambleList.length)+'rpx'
+          })
+        }).exec();
+      }
+
     }
   },
   // 切换菜单
@@ -133,6 +173,15 @@ Page({
         console.log(newList);
         console.log(res.data.total);
         let flag = this.data.policyPageIndex * this.data.policyPageSize < res.data.total;
+
+        let query = wx.createSelectorQuery();
+        let that = this;
+        query.select('#policy').boundingClientRect(function (rect) {
+          that.setData({
+            sHeight: 180*(newList.length)+'rpx'
+          })
+        }).exec();
+
         this.setData({
           policyList: newList,
           policyHasMore: flag,
@@ -161,6 +210,15 @@ Page({
         console.log(newList);
         console.log(res.data.total);
         let flag = this.data.unscramblePageIndex * this.data.unscramblePageSize < res.data.total;
+
+        let query = wx.createSelectorQuery();
+        let that = this;
+        query.select('#unscramble').boundingClientRect(function (rect) {
+          that.setData({
+            sHeight: 180*(newList.length)+'rpx'
+          })
+        }).exec();
+
         this.setData({
           unscrambleList: newList,
           unscrambleHasMore: flag,
@@ -193,6 +251,15 @@ Page({
       console.log(newList);
       console.log(res.data.total);
       let flag = this.data.policyPageIndex * this.data.policyPageSize < res.data.total;
+
+      let query = wx.createSelectorQuery();
+      let that = this;
+      query.select('#policy').boundingClientRect(function (rect) {
+        that.setData({
+          sHeight: 180*(newList.length)+'rpx'
+        })
+      }).exec();
+
       this.setData({
         policyList: newList,
         policyHasMore: flag,

+ 3 - 3
pages/policy/index.wxml

@@ -5,10 +5,10 @@
 			<view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">政策解读</view>
 			<view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">政策发布</view>
 		</view>
-		<swiper current="{{currentTab}}" bindchange="swiperTab">
+		<swiper current="{{currentTab}}" bindchange="swiperTab" style="height:{{sHeight}}">
 			<swiper-item>
 				<view class="policyLeft">
-					<view class="list" wx:key="unique" wx:for="{{policyList}}" wx:for-item="item">
+					<view class="list" wx:key="unique" wx:for="{{policyList}}" wx:for-item="item" id="policy">
 						<view bindtap="policyListDetail" id="{{list._id}}" data-pid="{{item.id}}">
 							<image src="{{item.image}}"></image>
 							<view class="info">
@@ -26,7 +26,7 @@
 			</swiper-item>
 			<swiper-item>
 				<view class="policyLeft policyRight">
-					<view class="list" wx:key="unique" wx:for="{{unscrambleList}}" wx:for-item="item">
+					<view class="list" wx:key="unique" wx:for="{{unscrambleList}}" wx:for-item="item" id="unscramble">
 						<view bindtap="unscrambleListDetail" id="{{list._id}}" data-unid="{{item.id}}">
 							<image src="{{item.image}}"></image>
 							<view class="info">