TopBar.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="topbar flex-between" :style="{'height':`${topbarOffsetHeight-statusBarHeight}px`,'padding-top':`${statusBarHeight}px`}">
  3. <view class="icon flex-center" @click="action">
  4. <image src="../../static/back.png" mode="aspectFill" class="icon-img" v-if="icon==='back'"></image>
  5. </view>
  6. <view class="text font32 fw600" :style="{'line-height':`${topbarOffsetHeight-statusBarHeight}px`}">
  7. {{title}}
  8. </view>
  9. <view class="null">
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name:"TopBar",
  16. props:{
  17. icon:{
  18. type:String,
  19. default:''
  20. },
  21. title:{
  22. type:String,
  23. default:''
  24. }
  25. },
  26. data() {
  27. return {
  28. };
  29. },
  30. computed:{
  31. statusBarHeight(){
  32. return this.$store.state.statusBarHeight;
  33. },
  34. topbarOffsetHeight(){
  35. return this.$store.state.topbarOffsetHeight;
  36. }
  37. },
  38. methods:{
  39. action(){
  40. switch(this.icon){
  41. case 'back':
  42. uni.navigateBack({
  43. delta:1
  44. })
  45. break;
  46. }
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .topbar{
  53. background-color: $bgcolor1;
  54. }
  55. .icon{
  56. width: 128rpx;
  57. height: 100%;
  58. .icon-img{
  59. width: 40rpx;
  60. height: 40rpx;
  61. }
  62. }
  63. .text{
  64. height: 100%;
  65. flex: 1;
  66. color: $fontcolor5;
  67. text-align: center;
  68. }
  69. .null{
  70. width: 128rpx;
  71. height: 100%;
  72. }
  73. </style>