店播抖音版小程序

page-head.vue 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template name="page-head">
  2. <view class="topBar" :style="'padding-top:'+buttonTop+'px;height:'+statusNavBarHeight+'px;background:'+background+';color:'+color">
  3. <view class="back" :style="'height:'+buttonHeight+'px'" v-if="isBack" @click="back">
  4. <image class="back_image" src="/static/logo.png" v-if="color=='#ffffff'"></image>
  5. <image v-else class="back_image" src="/static/icon.png"></image>
  6. </view>
  7. <text class="topBar_title" :style="'top:'+buttonTop+'px;line-height:'+buttonHeight+'px'">{{title}}</text>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. name:"page-head",
  13. props: {
  14. title: {
  15. type: String,
  16. default: "问星数据 - 抖音版"
  17. },
  18. background:{
  19. type:String,
  20. default:"#f2f2f2"
  21. },
  22. color:{
  23. type:String,
  24. default:"#666666"
  25. },
  26. isBack:{
  27. type:Boolean,
  28. default:false
  29. }
  30. },
  31. data() {
  32. return {
  33. buttonTop:this.$store.state.systemInfo.safeAreaInsets.top,
  34. statusNavBarHeight:this.$store.state.systemInfo.safeAreaTop,
  35. buttonHeight:this.$store.state.systemInfo.statusBarHeight,
  36. };
  37. },
  38. methods:{
  39. back(){
  40. let pages = getCurrentPages(); //页面对象
  41. let prevpage = pages[pages.length - 2];
  42. if(prevpage) {
  43. uni.navigateBack()
  44. }else {
  45. uni.redirectTo({
  46. url:'../pages/index/index?page=homePage'
  47. })
  48. }
  49. }
  50. }
  51. }
  52. </script>
  53. <style>
  54. .topBar{
  55. background: #f2f2f2;
  56. position: fixed;
  57. left: 0;
  58. top: 0rpx;
  59. width: 100%;
  60. height: var(--status-bar-height);;
  61. color: #FFFFFF;
  62. z-index: 999;
  63. box-sizing: border-box;
  64. }
  65. .topBar_title{
  66. font-size: 32rpx;
  67. line-height: 44rpx;
  68. position: absolute;
  69. width: 50%;
  70. left: 0;
  71. right: 0;
  72. margin:auto;
  73. text-align: center;
  74. }
  75. .back {
  76. width: 80rpx;
  77. height: 40rpx;
  78. margin-left: 10rpx;
  79. position: relative;
  80. }
  81. .back_image{
  82. width: 34rpx;
  83. height: 34rpx;
  84. position: absolute;
  85. top: 50%;
  86. transform: translateY(-50%);
  87. }
  88. </style>