customNav.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view>
  3. <!-- 自定义导航栏 -->
  4. <view class="contentView">
  5. <!-- 状态栏占位 -->
  6. <view class="navBarBox" :style="{marginTop:statusBarHeight+'rpx'}">
  7. <!-- 直正的导航栏内容 -->
  8. <view v-if="shownav" class="navBar" >
  9. <view class="leftconten">
  10. <image class="logo" src="/static/images/fanhuiz@3x.png" mode="aspectFit" @click="leftbuttonsel(1)"></image>
  11. <view v-if="titledetl==''" class="textlableR">
  12. <view class="lableTR">
  13. <text class="titleT" style="color: white;">{{title}}</text>
  14. </view>
  15. </view>
  16. <view v-if="titledetl!=''" class="textlable">
  17. <view class="lableT">{{title}}</view>
  18. <view class="lableB">{{titledetl}}</view>
  19. </view>
  20. </view>
  21. <view class="rightconten">
  22. <!-- <image v-if="shareBT==1" class="mycart" src="/static/images/fenxiang@3x.png" mode="aspectFit" @click="leftbuttonsel(2)"></image> -->
  23. <image v-if="faverBT==1" class="mycart" :src="isfaver==0?'/static/images/faver@3x.png':'/static/images/faverr@3x.png'" mode="aspectFit" @click="leftbuttonsel(3)"></image>
  24. <!-- <image v-if="addBT==1" class="mycart" src="/static/images/plus-circle-fill@3x.png" mode="aspectFit" @click="leftbuttonsel(4)"></image> -->
  25. <text v-if="xinzeng==1" class="xinzengTxt" @click="leftbuttonsel(5)">{{$t('schema.add')}}</text>
  26. <uni-icons v-if="addBT==1" custom-prefix="custom-icon" color="white" type="plus" size="26" @click="leftbuttonsel(4)"></uni-icons>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view v-if="shownav" :style="{height:navBarHeight+'rpx'}">
  32. </view>
  33. <view v-if="!shownav" :style="{height:yincbtHeight+'rpx'}">
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default
  39. {
  40. props:{
  41. shownav:true,
  42. title:'',
  43. titledetl:'',
  44. faverBT:0,
  45. shareBT:0,
  46. isfaver:0,
  47. addBT:0,
  48. xinzeng:0
  49. },
  50. data() {
  51. return{
  52. // 状态栏高度
  53. statusBarHeight:0,
  54. // 导航栏高度
  55. navBarHeight: 50,
  56. yincbtHeight:0,
  57. };
  58. },
  59. //第一次加载时调用
  60. created() {
  61. //获取手机状态栏高度
  62. var systemInfo = uni.getSystemInfoSync();
  63. this.statusBarHeight=systemInfo.statusBarHeight*2+30;
  64. this.navBarHeight = 50+this.statusBarHeight;
  65. this.yincbtHeight=this.statusBarHeight;
  66. },
  67. methods:{
  68. leftbuttonsel(item){
  69. //触发一个更新事件
  70. if(item==1){
  71. uni.navigateBack();
  72. }
  73. this.$emit('Enavbarsel',item);
  74. }
  75. },
  76. }
  77. </script>
  78. <style>
  79. .contentView{
  80. position: fixed;
  81. left: 0;
  82. right: 0;
  83. top: 0;
  84. z-index: 9999;
  85. background-color: #00A6FF;
  86. }
  87. .navBarBox{
  88. display: flex;
  89. width: 750upx;
  90. background-color: #00A6FF;
  91. }
  92. .navBar {
  93. display: flex;
  94. width: 690upx;
  95. margin-left: 30upx;
  96. margin-bottom: 20rpx;
  97. display: flex;
  98. flex-direction: row;
  99. justify-content: space-between;
  100. align-items: center
  101. }
  102. .logo {
  103. width: 50rpx;
  104. height: 50rpx;
  105. margin-left: 6rpx;
  106. }
  107. .textlable{
  108. flex-direction:column;
  109. margin-left: 20rpx;
  110. }
  111. .textlableR{
  112. flex-direction:column;
  113. margin-left: 20rpx;
  114. }
  115. .lableTR{
  116. font-size: 32rpx;
  117. color: rgb(255, 255, 255);
  118. }
  119. .lableT{
  120. font-size: 30rpx;
  121. color: rgb(255, 255, 255);
  122. }
  123. .lableB{
  124. font-size: 22rpx;
  125. color: rgb(255, 255, 255);
  126. }
  127. .leftconten{
  128. display: flex;
  129. flex-direction: row;
  130. justify-content:flex-start;
  131. margin-left: 20rpx;
  132. }
  133. .rightconten{
  134. display: flex;
  135. flex-direction: row;
  136. justify-content:flex-end;
  137. }
  138. .mycart {
  139. margin-right: 10rpx;
  140. width: 50rpx;
  141. height: 50rpx;
  142. }
  143. .xinzengTxt{
  144. margin-right: 10rpx;
  145. color: white;
  146. font-size: 28rpx;
  147. }
  148. .titleT{
  149. /* width: 580upx; */
  150. overflow: hidden;
  151. text-overflow: ellipsis;
  152. /* #ifndef APP-PLUS-NVUE */
  153. display: -webkit-box;
  154. -webkit-line-clamp: 1;
  155. -webkit-box-orient: vertical;
  156. /* #endif */
  157. }
  158. </style>