chat-custom.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template name="headerNavbar">
  2. <!-- 自定义导航栏 -->
  3. <view class='navbar-wrap'
  4. :style="{height:CustomBar+'px',paddingTop:StatusBar+'px',background:navbarData.bgColor ? navbarData.bgColor : '#f5f4f6'}">
  5. <view class="navbar-text"
  6. :style="{color:navbarData.textColor ? navbarData.textColor:'',lineHeight:(CustomBar - StatusBar)+'px;',fontSize:fontSizeSetting+'px;',paddingLeft:navbarData.textLeft ? '' : (capsule.height+10)+'px'}"
  7. :class="platformClass">
  8. {{navbarData.title ? navbarData.title : " "}}
  9. </view>
  10. <view class="navbar-icon"
  11. :style="{top:capsule.top +'px;',left:((screenWidth-capsule.right)+5)+'px;',height:capsule.height+'px;',lineHeight:capsule.height+'px;'}">
  12. <text :style="{width:navbarBtn.height+'px;'}" @tap="handleBack" class="iconfont icon-fanhui"></text>
  13. <text :style="{width:navbarBtn.height+'px;'}" @tap="handleShowDr" class="iconfont icon-xiaoxi"></text>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. var self
  19. export default {
  20. name: 'chatCustom',
  21. props: {
  22. navbarData: { // 由父页面传递的数据
  23. type: Object
  24. }
  25. },
  26. data() {
  27. return {
  28. CustomBar: this.CustomBar, // 顶部导航栏高度
  29. StatusBar: this.StatusBar,
  30. fontSizeSetting: this.fontSizeSetting,
  31. screenWidth: this.screenWidth,
  32. capsule: this.capsule,
  33. platformClass: this.platformClass,
  34. }
  35. },
  36. created() {
  37. if (getCurrentPages().length === 1) { // 当只有一个页面时
  38. this.navbarData.haveBack = false
  39. } else {
  40. this.navbarData.haveBack = true
  41. }
  42. },
  43. onLoad() {
  44. },
  45. methods: {
  46. handleBack() {
  47. this.$emit('navigateBack')
  48. },
  49. handleShowDr() {
  50. this.$emit('showDr')
  51. }
  52. },
  53. onShow() {
  54. }
  55. }
  56. </script>
  57. <style lang="scss">
  58. .navbar-wrap {
  59. position: fixed;
  60. width: 100%;
  61. top: 0;
  62. z-index: 100000;
  63. box-sizing: border-box;
  64. background: #f5f4f6;
  65. border-bottom: 1px solid #f5f4f6;
  66. }
  67. .navbar-text {
  68. font-size: 30rpx;
  69. color: #000000;
  70. font-weight: 500;
  71. }
  72. .navbar-text.center {
  73. text-align: center;
  74. }
  75. .navbar-text.left {
  76. text-align: left;
  77. padding-left: 45px;
  78. }
  79. .navbar-icon {
  80. position: fixed;
  81. display: flex;
  82. border-radius: 50%;
  83. text-align: center;
  84. background: rgba(255,255,255,0.6);
  85. border: 0.5px solid rgba(0,0,0, 0.1);
  86. box-sizing: border-box;
  87. z-index: 9999;
  88. }
  89. .navbar-icon .iconfont {
  90. height: 100%;
  91. width: 100%;
  92. font-size: 38rpx;
  93. font-weight: bold;
  94. display: inline-block;
  95. overflow: hidden;
  96. }
  97. .navbar-icon view {
  98. height: 18px;
  99. border-left: 0.5px solid rgba(0,0,0, 0.3);
  100. margin-top: 6px;
  101. }
  102. .navbar-icon .icon-xiaoxi {
  103. color: #FF5B00;
  104. }
  105. .navbar-loading {
  106. background: #fff;
  107. text-align: center;
  108. }
  109. </style>