DocHead.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="notice-warp" :style="{height:noticeWarpH + 'px'}">
  3. <view class="search-box" style="background-color: #fff;">
  4. <u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="keyword" height="72" :show-action="false"
  5. @change="search" bg-color="#f0f2f6" shape="square" />
  6. </view>
  7. <CommonTabs class="commonTabs" :list="categoryList" @change="change" :current="current" ref="CommonTabs"
  8. :icon="icon" type="doc" @iconClick="iconClick">
  9. </CommonTabs>
  10. </view>
  11. </template>
  12. <script>
  13. import mixin from "../mixin.js"
  14. import CommonTabs from '@/components/CommonTabs'
  15. export default {
  16. mixins: [mixin],
  17. components: {
  18. CommonTabs
  19. },
  20. data() {
  21. return {
  22. icon: 'icon-ym icon-ym-thumb-mode',
  23. keyword: '',
  24. current: 0,
  25. categoryList: [{
  26. fullName: '我的文档',
  27. }, {
  28. fullName: '我的共享'
  29. }, {
  30. fullName: '共享给我'
  31. }, {
  32. fullName: '回收站'
  33. }],
  34. commonTabs: 0,
  35. noticeWarpH: 0
  36. }
  37. },
  38. mounted() {
  39. this.getContentHeight()
  40. },
  41. methods: {
  42. async getContentHeight() {
  43. const windowHeight = this.$u.sys().windowHeight;
  44. const [commonTabs, searchBox] = await Promise.all([
  45. this.$uGetRect('.search-box'),
  46. this.$uGetRect('.commonTabs')
  47. ]);
  48. this.commonTabs = commonTabs.height
  49. this.searchBox = searchBox.height
  50. this.noticeWarpH = this.commonTabs + this.searchBox
  51. // #ifdef MP
  52. this.$emit('mescrollTop', this.commonTabs + 10)
  53. // #endif
  54. // #ifndef MP
  55. this.$emit('mescrollTop', this.noticeWarpH)
  56. // #endif
  57. },
  58. search() {
  59. this.searchTimer && clearTimeout(this.searchTimer);
  60. this.searchTimer = setTimeout(() => {
  61. this.$emit('search', this.keyword)
  62. }, 300);
  63. },
  64. change(e) {
  65. this.current = e;
  66. this.keyword = ''
  67. this.$emit('change', this.current)
  68. },
  69. iconClick(e) {
  70. this.$emit('iconClick')
  71. },
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. .notice-warp {
  77. z-index: 9;
  78. position: fixed;
  79. top: var(--window-top);
  80. left: 0;
  81. width: 100%;
  82. height: 200rpx;
  83. /*对应mescroll-body的top值*/
  84. font-size: 26rpx;
  85. text-align: center;
  86. background-color: #fff;
  87. }
  88. </style>