bar.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view>
  3. <view class="header" :style="{ height: titleBarHeight, 'padding-top': statusBarHeight, 'background-color': nav.bg }">
  4. <view class="back">
  5. <image src="../static/left_arr.png" :style="{ border: nav.color }" v-if="nav.isdisPlayNavTitle" @click="back"></image>
  6. </view>
  7. <view class="header-title weight">{{ nav.navTitle }}</view>
  8. </view>
  9. <view :style="{ height: titleBarHeight, 'padding-top': statusBarHeight }"></view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props: ['nav'],
  15. data() {
  16. return {
  17. statusBarHeight: 0,
  18. titleBarHeight: 0
  19. };
  20. },
  21. created() {
  22. var that = this;
  23. uni.getSystemInfo({
  24. success: function(res) {
  25. if (res.model.indexOf('iPhone') !== -1) {
  26. that.titleBarHeight = 44 + 'px';
  27. } else {
  28. that.titleBarHeight = 48 + 'px';
  29. }
  30. that.statusBarHeight = res.statusBarHeight + 'px';
  31. }
  32. });
  33. },
  34. methods: {
  35. // 回到上一页
  36. back: function() {
  37. uni.navigateBack({
  38. delta: 1
  39. });
  40. }
  41. }
  42. };
  43. </script>
  44. <style lang="scss">
  45. .header {
  46. display: flex;
  47. align-items: center;
  48. top: 0;
  49. left: 0;
  50. position: fixed;
  51. width: 100%;
  52. z-index: 100;
  53. }
  54. .back{
  55. width: 60rpx;
  56. margin-left:30rpx;
  57. image{
  58. width: 40rpx;
  59. height:40rpx;
  60. }
  61. }
  62. .header .header-title {
  63. position: absolute;
  64. left: 50%;
  65. font-size: 38upx;
  66. transform: translateX(-50%);
  67. }
  68. .header-back {
  69. position: absolute;
  70. left: 15upx;
  71. font-size: 30upx;
  72. padding: 10upx;
  73. border-radius: 50%;
  74. }
  75. </style>