lx 5 years ago
parent
commit
ce0f2d7e3c
5 changed files with 28 additions and 11 deletions
  1. 2 3
      app.js
  2. 2 1
      app.wxss
  3. 5 5
      components/navBar/navBar.js
  4. 18 1
      pages/index/index.js
  5. 1 1
      pages/index/index.wxml

+ 2 - 3
app.js

@@ -12,16 +12,15 @@ App({
         let statusBarHeight = res.statusBarHeight,
           navTop = menuButtonObject.top,//胶囊按钮与顶部的距离
           navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight)*2;//导航高度
-        this.statusBarHeight = statusBarHeight;
+        this.globalData.statusBarHeight = statusBarHeight;
         this.globalData.navHeight = navHeight;
         this.globalData.navTop = navTop;
         this.globalData.windowHeight = res.windowHeight;
       },
       fail(err) {
         console.log(err);
-      }
+      },
     })
-
     // 登录
     wx.login({
       success: res => {

+ 2 - 1
app.wxss

@@ -4,7 +4,7 @@ page{
   background-color: #000000;
 }
 .container {
-  height: 100%;
+  /* height: 88%; */
   display: flex;
   flex-direction: column;
   align-items: center;
@@ -14,3 +14,4 @@ page{
   overflow:hidden;
   background-color: #000000;
 } 
+

+ 5 - 5
components/navBar/navBar.js

@@ -52,11 +52,11 @@ Component({
     methods: {
         // 通过获取系统信息计算导航栏高度
         setNavSize: function() {
-            var that = this
-                , sysinfo = wx.getSystemInfoSync()
-                , statusHeight = sysinfo.statusBarHeight
-                , isiOS = sysinfo.system.indexOf('iOS') > -1
-                , navHeight;
+            var that = this, 
+            sysinfo = wx.getSystemInfoSync(),
+            statusHeight = sysinfo.statusBarHeight, 
+            isiOS = sysinfo.system.indexOf('iOS') > -1, 
+            navHeight;
             if (!isiOS) {
                 navHeight = 48;
             } else {

+ 18 - 1
pages/index/index.js

@@ -150,6 +150,20 @@ Page({
 },
 
   onLoad: function () {
+    let sysinfo = wx.getSystemInfoSync(),
+    windowHeight = sysinfo.windowHeight,
+    statusHeight = sysinfo.statusBarHeight, 
+    isiOS = sysinfo.system.indexOf('iOS') > -1, 
+    navHeight;
+    if (!isiOS) {
+        navHeight = 48;
+    } else {
+        navHeight = 44;
+    }
+    let height = windowHeight-statusHeight-navHeight;
+    this.setData({
+      height:height
+    })
     this.echartsComponnet = this.selectComponent('#mychart');
     console.log(this.echartsComponnet);
     //如果是第一次绘制
@@ -194,13 +208,16 @@ Page({
     query.select('.news').boundingClientRect()
     query.exec(res => {
       let topHeight = res[0].height
+      console.log(topHeight);
       let searchHeight = res[1].height
+      console.log(searchHeight);
       let titleHeight = res[2].height
+      console.log(titleHeight);
       let windowHeight = wx.getSystemInfoSync().windowHeight
       let windowWidth = wx.getSystemInfoSync().windowWidth
       let height = windowHeight - topHeight - searchHeight - titleHeight
       let ratio = 750 / windowWidth
-      let scrollHeight = height * ratio + 20
+      let scrollHeight = height * ratio
       that.setData({ scrollHeight: scrollHeight})
     })
   },

+ 1 - 1
pages/index/index.wxml

@@ -4,7 +4,7 @@
 </view> -->
 
 <navBar></navBar>
-<view class="container">
+<view class="container" style="height:{{height}}px" >
   <view class="swiper-tab">
     <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">沪深</view>
     <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">港股</view>