i-navbar.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view>
  3. <view class="fixed">
  4. <view class="navbar">
  5. <view :style="{height:statusBarHeight + 'px'}">
  6. <!-- 这里是状态栏 -->
  7. </view>
  8. <view class="inner">
  9. <view class="search_box">
  10. <view class="search_icon"></view>
  11. <view class="search_text">搜索</view>
  12. </view>
  13. <view class="right_icon" @click="scan_code()"></view>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 占位符 -->
  18. <view :style="{height: statusBarHeight + 'px'}"></view>
  19. <view style="height: 93rpx;"></view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. statusBarHeight: 20,
  27. };
  28. },
  29. created() {
  30. // 获取手机系统信息
  31. const info = uni.getSystemInfoSync()
  32. // 设置状态栏高度
  33. this.statusBarHeight = info.statusBarHeight
  34. },
  35. onLoad() {
  36. },
  37. methods:{
  38. scan_code(){
  39. // 允许从相机和相册扫码
  40. uni.scanCode({
  41. success: function (res) {
  42. console.log('条码类型:' + res.scanType);
  43. console.log('条码内容:' + res.result);
  44. }
  45. });
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss">
  51. .fixed{
  52. position: fixed;
  53. top: 0;
  54. left: 0;
  55. background-image: url(../../static/top_1.png);
  56. background-size: 100% 100%;
  57. background-repeat: no-repeat;
  58. z-index: 999;
  59. }
  60. .navbar{
  61. padding-top: 10rpx;
  62. box-sizing: border-box;
  63. padding-left: 28rpx;
  64. padding-right: 28rpx;
  65. padding-bottom: 10rpx;
  66. .inner{
  67. display: flex;
  68. .search_box{
  69. width: 617rpx;
  70. height: 66rpx;
  71. background: rgba(255, 255, 255, 0.2);
  72. border-radius: 34rpx;
  73. display: flex;
  74. .search_icon{
  75. margin-top: 17rpx;
  76. margin-left: 38rpx;
  77. width: 34rpx;
  78. height: 34rpx;
  79. background-image: url(icon/search.png);
  80. background-size: cover;
  81. background-repeat: no-repeat;
  82. }
  83. .search_text{
  84. margin-left: 14rpx;
  85. line-height: 66rpx;
  86. font-size: 24rpx;
  87. font-family: PingFangSC-Regular, PingFang SC;
  88. font-weight: 400;
  89. color: #FFFFFF;
  90. }
  91. }
  92. .right_icon{
  93. margin-left: 30rpx;
  94. width: 50rpx;
  95. height: 73rpx;
  96. background-image: url(icon/saoma.png);
  97. background-size: cover;
  98. background-repeat: no-repeat;
  99. }
  100. }
  101. }
  102. </style>