Commit 4570476bad446fbed1d1e6ec402829c9dce1c9cd

Authored by wangfan
1 parent 83d35bc9

导航修复

@@ -4,31 +4,31 @@ Component({ @@ -4,31 +4,31 @@ Component({
4 * 组件的属性列表 4 * 组件的属性列表
5 */ 5 */
6 properties: { 6 properties: {
7 - backgroundColor:{  
8 - type:String,  
9 - value:'#ffffff' 7 + backgroundColor: {
  8 + type: String,
  9 + value: '#ffffff'
10 }, 10 },
11 - color:{  
12 - type:String,  
13 - value:'#000000'  
14 - },  
15 - hasHome:{  
16 - type:Boolean,  
17 - value:false  
18 - } 11 + color: {
  12 + type: String,
  13 + value: '#000000'
  14 + },
  15 + hasHome: {
  16 + type: Boolean,
  17 + value: false
  18 + }
19 }, 19 },
20 20
21 /** 21 /**
22 * 组件的初始数据 22 * 组件的初始数据
23 */ 23 */
24 data: { 24 data: {
25 - disHome:false,  
26 - disBack:false, 25 + disHome: false,
  26 + disBack: false,
27 }, 27 },
28 28
29 - attached(){  
30 - this.init();  
31 - }, 29 + attached(){
  30 + this.init();
  31 + },
32 /** 32 /**
33 * 组件的方法列表 33 * 组件的方法列表
34 */ 34 */
@@ -37,38 +37,47 @@ Component({ @@ -37,38 +37,47 @@ Component({
37 this.triggerEvent('NavEvent'); 37 this.triggerEvent('NavEvent');
38 wx.navigateBack(); 38 wx.navigateBack();
39 }, 39 },
40 - home(){  
41 - if(!this.data.disHome) return;  
42 - wx.reLaunch({  
43 - url:'/pages/customer/index'  
44 - })  
45 - },  
46 - init(){  
47 - let wxBarHeight=68;  
48 - let disBack = false;  
49 - let disHome = false;  
50 - let pages = getCurrentPages();  
51 - console.log('pages.length',pages[0]);  
52 - if (pages.length > 1) {  
53 - disBack = true;  
54 - } else {  
55 - //if (getApp().shareTicket && this.data.hasHome) {  
56 - if (this.data.hasHome && pages[0].route!="pages/customer/list") {  
57 - disHome = true;  
58 - }  
59 - }  
60 - let statusBarHeight=40;  
61 - if(getApp().system.system){  
62 - statusBarHeight=getApp().system.statusBarHeight  
63 - *(getApp().system.system.toLowerCase().indexOf('ios')>-1?2:getApp().system.pixelRatio);  
64 - }  
65 - this.setData({  
66 - statusBarHeight: statusBarHeight,  
67 - disHome: disHome,  
68 - disBack: disBack,  
69 - statusBarHeightFull:wxBarHeight + statusBarHeight,  
70 - })  
71 - console.log('this.setData',this.data);  
72 - }, 40 + home(){
  41 + if (!this.data.disHome) return;
  42 + wx.reLaunch({
  43 + url: '/pages/customer/index'
  44 + })
  45 + },
  46 + init(){
  47 +
  48 + let disBack = false;
  49 + let disHome = false;
  50 + let pages = getCurrentPages();
  51 + console.log('pages.length', pages[0]);
  52 + if (pages.length > 1) {
  53 + disBack = true;
  54 + } else {
  55 + //if (getApp().shareTicket && this.data.hasHome) {
  56 + if (this.data.hasHome && pages[0].route != "pages/customer/list") {
  57 + disHome = true;
  58 + }
  59 + }
  60 + //导航栏自适应
  61 + let systemInfo = wx.getSystemInfoSync();
  62 + let reg = /ios/i;
  63 + let pt = 20;//导航状态栏上内边距
  64 + let h = 44;//导航状态栏高度
  65 + if(reg.test(systemInfo.system)){
  66 + pt = systemInfo.statusBarHeight;
  67 + h = 44;
  68 + }else{
  69 + pt = systemInfo.statusBarHeight;
  70 + h = 48;
  71 + }
  72 +
  73 + this.setData({
  74 + statusBarHeight: pt,
  75 + disHome: disHome,
  76 + disBack: disBack,
  77 + statusBarHeightFull: pt + h,
  78 + titleBarHeight:h,
  79 + })
  80 + console.log('this.setData', this.data);
  81 + },
73 } 82 }
74 }) 83 })
1 <!--components/nav/nav.wxml--> 1 <!--components/nav/nav.wxml-->
2 -<view class="nav-main-space" style="height: {{statusBarHeightFull}}rpx;"> 2 +<view class="nav-main-space" style="height: {{statusBarHeightFull}}px;">
3 <view class="nav-main" style="background-color: {{backgroundColor}};color:{{color}};"> 3 <view class="nav-main" style="background-color: {{backgroundColor}};color:{{color}};">
4 - <view class="nav" style="margin-top: {{statusBarHeight}}rpx;">  
5 - <view class="flex-lr part"> 4 + <view class="nav" style="margin-top: {{statusBarHeight}}px;">
  5 + <view class="flex-lr part" style="height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px">
6 <view class="opt flex-ll"> 6 <view class="opt flex-ll">
7 <view class="back flex-vc" bindtap="back" wx:if="{{disBack}}"> 7 <view class="back flex-vc" bindtap="back" wx:if="{{disBack}}">
8 <image class="back-image" 8 <image class="back-image"
@@ -10,8 +10,6 @@ @@ -10,8 +10,6 @@
10 font-weight: bold; 10 font-weight: bold;
11 } 11 }
12 .nav .part{ 12 .nav .part{
13 - line-height: 68rpx;  
14 - height: 68rpx;  
15 text-align: center; 13 text-align: center;
16 14
17 } 15 }
@@ -22,10 +20,11 @@ @@ -22,10 +20,11 @@
22 } 20 }
23 .nav .part .opt{ 21 .nav .part .opt{
24 min-width: 188rpx; 22 min-width: 188rpx;
  23 + height: 100%;
25 } 24 }
26 .nav .part .opt view{ 25 .nav .part .opt view{
27 width: 68rpx; 26 width: 68rpx;
28 - height: 68rpx; 27 + height: 100%;
29 margin-left: 26rpx; 28 margin-left: 26rpx;
30 } 29 }
31 .nav .part .opt .back-image{ 30 .nav .part .opt .back-image{