bg.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view>
  3. <view class="back" :style="{ paddingTop: top + 'px' }">
  4. <view class="cont">
  5. <text class="title">{{ title }}</text>
  6. </view>
  7. </view>
  8. <view class="top" :style="{ marginBottom: '-' + mb + 'px' }">
  9. <image src="../../static/bg.png" mode="widthFix"></image>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'back',
  16. props: {
  17. title: {
  18. type: String,
  19. default: '承揽时代'
  20. }
  21. },
  22. data() {
  23. return {
  24. top: 0,
  25. mb: 140
  26. };
  27. },
  28. mounted() {
  29. uni.getSystemInfo({
  30. success: res => {
  31. this.top = parseInt(res.safeArea.top) - 5;
  32. // #ifdef MP-WEIXIN
  33. this.mb = this.mb - this.top + 10;
  34. // #endif
  35. // #ifdef H5
  36. this.mb = this.mb - this.top;
  37. // #endif
  38. },
  39. fail(err) {
  40. console.error(err);
  41. }
  42. });
  43. },
  44. methods: {
  45. back() {
  46. uni.navigateBack();
  47. }
  48. }
  49. };
  50. </script>
  51. <style lang="scss">
  52. .back {
  53. position: fixed;
  54. top: 0px;
  55. width: 100%;
  56. height: 50px;
  57. text-align: center;
  58. color: white;
  59. z-index: 11111;
  60. text-align: left;
  61. padding-left: 20px;
  62. .cont {
  63. padding: 15px 0px 15px 0px;
  64. position: relative;
  65. .icon {
  66. position: absolute;
  67. font-size: 25px;
  68. left: 10px;
  69. }
  70. .title {
  71. font-size: 16px;
  72. font-weight: bold;
  73. }
  74. }
  75. }
  76. .top {
  77. image {
  78. width: 100%;
  79. }
  80. }
  81. </style>