wbpNavBar.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="u-f-ajc u-f-jsb wbpNavBar" :style="{backgroundColor: bgColor}">
  3. <view class="wbp-back-content" @click="onBack">
  4. <image v-if="showBack" :src="bgColor!='#ffffff'?'/static/news/back_icon20.png':'/static/common/back.png'" class="wbp-back"></image>
  5. </view>
  6. <text class="wbp-title" :style="{color:titleColor}">{{title}}</text>
  7. <view v-if="rightTitle.length > 0" class="wbp-right-icon">
  8. <view v-for="(item,index) in rightTitle" :src="item" :data-index="index" @click="rightTap">
  9. <text>{{item}}</text>
  10. </view>
  11. </view>
  12. <view v-else class="wbp-right-icon">
  13. <view v-for="(item,index) in rightIcons" :src="item" :data-index="index" @click="rightTap">
  14. <image :src="item"></image>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. props: {
  22. title: {
  23. type: String,
  24. default: "标题"
  25. },
  26. rightIcons: {
  27. type: Array,
  28. default: () => {
  29. return []
  30. }
  31. },
  32. rightTitle: {
  33. type: Array,
  34. default: () => {
  35. return []
  36. }
  37. },
  38. bgColor: {
  39. type: String,
  40. default: "#ffffff"
  41. },
  42. titleColor: {
  43. type: String,
  44. default: "#0A0204"
  45. },
  46. backgroundImage:{
  47. type: String,
  48. default: "#0A0204"
  49. },
  50. customOnBack: {
  51. type: Boolean,
  52. default: false
  53. },
  54. showBack: {
  55. type: Boolean,
  56. default: true
  57. }
  58. },
  59. data() {
  60. return {
  61. };
  62. },
  63. methods: {
  64. onBack() {
  65. if (!this.showBack) {
  66. return;
  67. }
  68. if (this.customOnBack) {
  69. this.$emit("onBack");
  70. return;
  71. }
  72. uni.navigateBack({
  73. animationType: 'pop-out',
  74. animationDuration: 200
  75. });
  76. },
  77. rightTap(e) {
  78. this.$emit("rightTap", {
  79. index: e.currentTarget.dataset.index
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .wbpNavBar {
  87. /* #ifdef MP-WEIXIN */
  88. padding-right: 200rpx;
  89. width: 550rpx;
  90. /* #endif */
  91. /* #ifdef APP-PLUS */
  92. width: 750rpx;
  93. /* #endif */
  94. background-color: #FFFFFF;
  95. height: 88rpx;
  96. display: flex;
  97. justify-content: space-between;
  98. align-items: center;
  99. .wbp-back-content {
  100. width: 140rpx;
  101. height: 100%;
  102. display: flex;
  103. justify-content: flex-start;
  104. align-items: center;
  105. .wbp-back {
  106. width: 40rpx;
  107. height: 40rpx;
  108. margin-left: 30rpx;
  109. }
  110. }
  111. .wbp-title {
  112. font-size: 36rpx;
  113. width: 470rpx;
  114. text-align: center;
  115. color: #0A0204;
  116. white-space: nowrap;
  117. text-overflow: ellipsis;
  118. overflow: hidden;
  119. word-break: break-all;
  120. }
  121. .wbp-right-icon {
  122. display: flex;
  123. width: 140rpx;
  124. flex-direction: row;
  125. justify-content: flex-end;
  126. align-items: center;
  127. height: 100%;
  128. image {
  129. width: 40rpx;
  130. height: 40rpx;
  131. margin-right: 30rpx;
  132. }
  133. text {
  134. margin-right: 30rpx;
  135. color: #DF0E14;
  136. font-size: 32rpx;
  137. }
  138. }
  139. }
  140. </style>